Code:
#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;
}
Comment