473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

need help... it keep warn me bout possible use and never used..

1
Expand|Select|Wrap|Line Numbers
  1. #include<iostream.h>
  2. #include<conio.h>
  3.  
  4. void intro ();
  5. void input(int& , int& );
  6. float calculate1 ( int );
  7. float calculate2 (int , int );
  8. float calculate3 (int , int  );
  9. float calculate4 (int , int );
  10. void close (int , int , int ) ;
  11.  
  12. int main()
  13. {
  14.     int finance, month, totalMoney, totalMoneyMonth, spendMoney, useMonth, useDay, totalSave ;
  15.  
  16.  
  17. intro ();
  18.    input ( finance, month);
  19.    calculate1 ( month);
  20.    calculate2 ( totalMoneyMonth,  finance );
  21.    calculate3 ( totalMoney, totalSave);
  22.    calculate4 ( month, spendMoney);
  23.    close ( totalSave,  useMonth,  useDay);
  24.  
  25. getch ();
  26. return 0;
  27. }
  28.  
  29. void intro ()                                                                   //greeting the user
  30. {
  31.     cout<<"Hello there! Want to save money and help yourself to minimize money loss?"<<endl;
  32.    cout<<"If yes, please entered the question below."<<endl;
  33.    cout<<"We will be happy if this program will help you."<<endl;
  34.    cout<<"Thanks from us. - Hilal and Saffiq "<<endl;
  35. }
  36.  
  37. void input(int& finance, char& month)   //ask the user to enter basic question
  38. {
  39.    cout<<"Enter here if there any other finance you receive in one semester. E.g PTPTN : ";
  40.    cin>>finance;
  41.    cout<<"Enter how much month you want to be calculated : ";
  42.    cin>>month;
  43.  
  44. }
  45.  
  46. float calculate1 ( int month)    //finding the total saving and total money
  47. {
  48.     float totalMoneyMonth = 0, count = 1, pocket, totalSave = 0,save;
  49.  
  50.         while (count <= month);
  51.       {
  52.           cout<<" Enter the amount of money you receive in the "<<count<<" month : ";
  53.          cin>>pocket;
  54.          cout<<"How much money you want to save this month? : ";
  55.          cin>>save;
  56.          totalSave = totalSave + save;
  57.           totalMoneyMonth = totalMoneyMonth + pocket;
  58.          count++;
  59.       }
  60. return totalSave, totalMoneyMonth;
  61. }
  62.  
  63.  
  64. float calculate2 (int totalMoneyMonth, int finance )      //finding the total money the user have
  65. {
  66.     float totalMoney;
  67.     totalMoney = totalMoneyMonth + finance;
  68. return totalMoney;
  69. }
  70.  
  71.  
  72.  
  73. float calculate3 (int totalMoney, int totalSave)          //finding the total money the user can use
  74. {
  75.     float spendMoney =0 ;
  76.     spendMoney = totalMoney - totalSave;
  77.  
  78. return spendMoney;
  79. }
  80.  
  81.  
  82.  
  83. float calculate4 (int month, int spendMoney)        //finding the total money the user can use
  84. {
  85.     int days = 180, useDay, useMonth;
  86.     useMonth = spendMoney / month;
  87.    useDay = spendMoney / days;
  88. return useDay, useMonth;
  89. }
  90. void close (int totalSave, int useMonth, int useDay)                       //tell the user about the result
  91. {
  92.     cout<<"The money you can save for this semester is : "<<totalSave<<endl;
  93.    cout<<"You have this amount of money in a month to achieve the saving : "<<useMonth<<endl;
  94.    cout<<"You have to spend this amount of money for a day : "<<useDay<<endl;
  95. }
  96.  
Mar 10 '17 #1
3 1414
weaknessforcats
9,208 Expert Mod 8TB
None of your variables are initialized before you use them. That means you can't trust your results.

Initialize all your float variables to 0.0 and all of your int variables to 0 before you use any of them.
Mar 10 '17 #2
dev7060
636 Expert 512MB
Here are the few things I noticed:

1: On line 37, change 'char &month' to 'int &month'.
2: On line 60 and 88, the functions are trying to return more than one values. A function can return only one value.
[ left operand of comma operator has no effect [-Wunused-value] ]
3: As mentioned by @weaknessforcats, initialise the variables.

Also, try to mention some theoretical concept of the program as by that it would be easy for others to analyse the program well.
Mar 12 '17 #3
dev7060
636 Expert 512MB
Here are the few things I noticed:

1: On line 37, change 'char &month' to 'int &month'.
2: On line 60 and 88, the functions are trying to return more than one values. A function can return only one value.
[ left operand of comma operator has no effect [-Wunused-value] ]
3: As mentioned by @weaknessforcats, initialise the variables.

Also, try to mention some theoretical concept of the program as by that, it would be easy for others to analyse the program well.
Mar 12 '17 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: CptPicard | last post by:
Hi, I am currently trying to use pymedia so to get the following informations (author, song title, ...) from a mp3 file. The documentation I downloaded is quite limited : It gives some clues on...
4
by: sah | last post by:
I need some help with the following query: DECLARE @SRV VARCHAR(20), @date smalldatetime SET @SRV = (select @@servername) SET @date = '20040901' select Srv_Name = @SRV, DB_Name = 'DB_NAME',...
0
by: Dale McGorman | last post by:
The following is some code that I am trying to bring over from VB 6.0, that I have working there. I am trying to get to where I can talk to a USB device. I am stuck on how to correctly pass params...
8
by: harry | last post by:
Hi, During compilation, a C# project in my solution triggers the following warning: "warning CS0168: The variable 'ex' is declared but never used" To trigger this warning, it appears the C#...
19
by: hpy_awad | last post by:
What should I do to avoid the message : parameter 'argc' is never used My program is down : *-------------------- /* Book name : The prodessional programmers guide to C File name ...
0
by: Lloyd Sheen | last post by:
Everything was working a couple of days ago. I changed a password on SQL Server and had to debug to see where in app it was not using new password. I now get the msg "Unable to start debugging". ...
9
by: Terry Olsen | last post by:
I'm running an asynchronous Socket. In the ReceiveCallback method, I need to append what is received to a textbox on the main form. I have this code: Private Sub ToChatWindow(ByVal msg As...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
13
by: =?Utf-8?B?TWFyaw==?= | last post by:
Need help with a variable... This variable is used to keep track of permissions and can contain 1,2,4,8,16,32,64,128 Or it can contain a sum of one more of the above values. For example, if...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.