Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Budget Analysis Write a program that asks the user to enter the amount that he o

ID: 3599938 • Letter: B

Question

Budget Analysis


Write a program that asks the user to enter the amount that he or she has budgeted
for a month. A loop should then prompt the user to enter each of his or her expenses
for the month and keep a running total. When the loop finishes, the program should
display the amount that the user is over or under budget.

Enter your budget for the month: 900 Enter an expense anount. or a negative number to quit 300 Enter an expense amount. or a negative number to quit: 150 Enter an expense amount. or a negative number to quit: 150 Enter an expense amount. or a negative number to quit: 250 Enter an expense anount. or a negative number to quit 100 Enter an expense amount. or a negative number to quit: 200 Enter an expense amount or a negative number to quit: -1 You are OUER budget by $250.00

Explanation / Answer

C++ program to do this -

#include<iostream>
using namespace std ;
int main()
{
float a , ch=1 , b , c=0;
cout<<"Enter your budget for the month : ";
cin >> a;
cout<<endl;
  
while(ch)
{
cout <<"Enter an expense amount , or a negative number to quit :" ;
cin >> b ;
if(b>=0)
{
c=c+b;
}
else
if(b<0)
{
ch=0;
}
}
if(c>a)
{
cout<<"You are over budget by $"<<c-a<<endl;
}
else
if(a>c)
{
cout<<"You are lower budget by $"<<a-c<<endl;
}
else
{
cout<<"You spent the budget amount exactly"<<endl;
}
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote