-
#include<iostream.h>
-
#include<conio.h>
-
-
void intro ();
-
void input(int& , int& );
-
float calculate1 ( int );
-
float calculate2 (int , int );
-
float calculate3 (int , int );
-
float calculate4 (int , int );
-
void close (int , int , int ) ;
-
-
int main()
-
{
-
int finance, month, totalMoney, totalMoneyMonth, spendMoney, useMonth, useDay, totalSave ;
-
-
-
intro ();
-
input ( finance, month);
-
calculate1 ( month);
-
calculate2 ( totalMoneyMonth, finance );
-
calculate3 ( totalMoney, totalSave);
-
calculate4 ( month, spendMoney);
-
close ( totalSave, useMonth, useDay);
-
-
getch ();
-
return 0;
-
}
-
-
void intro () //greeting the user
-
{
-
cout<<"Hello there! Want to save money and help yourself to minimize money loss?"<<endl;
-
cout<<"If yes, please entered the question below."<<endl;
-
cout<<"We will be happy if this program will help you."<<endl;
-
cout<<"Thanks from us. - Hilal and Saffiq "<<endl;
-
}
-
-
void input(int& finance, char& month) //ask the user to enter basic question
-
{
-
cout<<"Enter here if there any other finance you receive in one semester. E.g PTPTN : ";
-
cin>>finance;
-
cout<<"Enter how much month you want to be calculated : ";
-
cin>>month;
-
-
}
-
-
float calculate1 ( int month) //finding the total saving and total money
-
{
-
float totalMoneyMonth = 0, count = 1, pocket, totalSave = 0,save;
-
-
while (count <= month);
-
{
-
cout<<" Enter the amount of money you receive in the "<<count<<" month : ";
-
cin>>pocket;
-
cout<<"How much money you want to save this month? : ";
-
cin>>save;
-
totalSave = totalSave + save;
-
totalMoneyMonth = totalMoneyMonth + pocket;
-
count++;
-
}
-
return totalSave, totalMoneyMonth;
-
}
-
-
-
float calculate2 (int totalMoneyMonth, int finance ) //finding the total money the user have
-
{
-
float totalMoney;
-
totalMoney = totalMoneyMonth + finance;
-
return totalMoney;
-
}
-
-
-
-
float calculate3 (int totalMoney, int totalSave) //finding the total money the user can use
-
{
-
float spendMoney =0 ;
-
spendMoney = totalMoney - totalSave;
-
-
return spendMoney;
-
}
-
-
-
-
float calculate4 (int month, int spendMoney) //finding the total money the user can use
-
{
-
int days = 180, useDay, useMonth;
-
useMonth = spendMoney / month;
-
useDay = spendMoney / days;
-
return useDay, useMonth;
-
}
-
void close (int totalSave, int useMonth, int useDay) //tell the user about the result
-
{
-
cout<<"The money you can save for this semester is : "<<totalSave<<endl;
-
cout<<"You have this amount of money in a month to achieve the saving : "<<useMonth<<endl;
-
cout<<"You have to spend this amount of money for a day : "<<useDay<<endl;
-
}
-
3 1414
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.
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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',...
|
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...
|
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#...
|
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 ...
|
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". ...
|
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...
|
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...
|
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...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
| |