## asas4004

develop a program that can help a person with some calculation that will allow him to decide on how much money he should spend on an expensive item. The program should request four different input data from the user (All are integers):

1- His capital
2- The annual percentage that he receives on his capital
3- The amount he can save per month from his salary.
4- The price of the item to buy

Such as:
Enter the annual percentage rate: 12
Enter your savings per month: 400
Enter the price of the item: 16250

The program should calculate the number of months the user has to wait in order to be able to buy the expensive item and keep a minimum capital of 10000.

Note: Consider the annual percentage to be applied on the initial capital amount and divided over 12 months.

For example:

12% annual percentage rate ==> 20000 * 12 % = 2400
==> 2400 / 12 = 200 per month

In order to buy the item in the above example, the user has to wait till his capital becomes at least 26250 which is 11 months because each month his capital will increase 600 (400 savings + 200) so after 11 months his total capital will become 36600.

The program should present output similar to the following:

If the capital is 20000 and the percentage rate on it is 12% and the monthly saving is 400
You can buy the item after 11 months

If the user does not have to wait the program should recognize that and present a different output, such as:

Enter the annual percentage rate: 9
Enter your savings per month: 500
Enter the price of the item: 12000

If the capital is 23000 and the percentage on it is 9% and the monthly saving is 500
You can buy the item right away!

Note: You should not use a loop for this question

Important: you might want to include the <Math.h> library and use the ceil function which rounds a number upwards.

Example 1
Number = 4.23;
Number = ceil(Number);
//Now Number has the value 5.

Example 2
Number = 4;
Number = ceil(Number);
//Now Number has the value 4.

## ithelp 757

Open the VC++ editor and start typing the code .

## asas4004

some in the starting...

## tkud

``````//This is the code you asked for,with only a slight deviation of instructions...the 4 variables cannot be int because the percentage
//after input is divided by 100 e.g 12 will give 0.12. this is a float value and will be truncated to 0, and you know what that means..
//wrong answers!! so therefore they can either be float or other data types that accept decimals.This is the app i came up with. Hope this helped!!
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
int month=1;//months to wait for
float capital=0;
float percentage=0;//Annual percentage received on capital
float savings=0;//
float price=0;//price of expensive item
float increase=0;//to store the calculated increase
float tempincrease=0;
int choice=0;
int main()
{
cout<<"Welcome to the Budget Master program!!"<<endl;
cout<<"(1)continue,(2)exit..";
cin>>choice;
if(choice==2){
return 1;
}
while(choice==1){
cout<<"Capital(numeric value only)-";
cin>>capital;
capital=ceil(capital);
cout<<endl<<"Annual percentage received on capital(numeric value only)-";
cin>>percentage;
percentage=ceil(percentage);
cout<<endl<<"How much can you save per month?(numeric value only)-";
cin>>savings;
savings=ceil(savings);
cout<<endl<<"What is the price of the item to be purchased?(numeric value only)-";
cin>>price;
price=ceil(price);
cout<<endl<<endl;
//Proceesing begins from here
if((capital-price)>10000)//This is for a well balanced account
{
cout<<"Rest assured that your account is stable."<<endl;
cout<<"Take that from the Budget Master!!"<<endl;
return 1;
}
{
float y=(percentage)/100;
float t=(capital)*y;
tempincrease=t/12;
increase=tempincrease+savings;
capital=capital+increase;
month++;//This statement,as long as the loop keeps executing,keeps incrementing.
//Therefore,the final value is the number of minths the user must wait for.
}
cout<<"Dear user, you will have to wait for "<<month<<" month(s) before you are financially stable to buy that item"<<endl;
cout<<"Take that from the Budget Master!!"<<endl;
cout<<"(1)continue,(2)exit..";
cin>>choice;
}
return 0;
}``````

Hope this helped!!
(I would appreciate it if you add to my reputation, thanks)

commented: Completely doing a persons assignment w/o them even having to put the least amount of effort into it. As well as asking for reputation after giving the code away... +0