Question: This is the wrong answer #include #include #include #include using namespace std; //function prototypes void input( struct MonthlyBudget rec[]); void printRecord( struct MonthlyBudget r[]); //structure

This is the wrong answer

#include

#include

#include

#include

using namespace std;

//function prototypes

void input( struct MonthlyBudget rec[]);

void printRecord( struct MonthlyBudget r[]);

//structure named player

struct MonthlyBudget

{

float amount;

} ;

int main()

{

//structure array with 12 size

struct MonthlyBudget sarr[10];

//function call to gather information from user

input(sarr);

system("pause"); //console visible purpose

return 0;

}

//function implementation-gathering information from user

void input(struct MonthlyBudget record[])

{

char category[10][20] = {"Housing", "Utilities", "Household", "Expenses","Transportation","Food",

"Medical","Insurance","Entertainment","Clothing"};

int i=0;

//loop to read inputs

for(i=0;i

{

cout

cin>>record[i].amount;

//to ignore space in the name

cin.ignore(256, ' ');

//fflush(stdin);

}

//calling the function to print the student records

printRecord(record);

}

//implementing the function to dispplay the player information

void printRecord( struct MonthlyBudget record[])

{

char category[10][20] = {"Housing", "Utilities", "Household", "Expenses","Transportation","Food",

"Medical","Insurance","Entertainment","Clothing"};

float budget[10]={500,150,65,50,50,250,30,100,150,75};

int i;

cout

//For calculation purpose

int total=0;

string name;

cout

//loop to display the records present in structure

for(i=0;i

{

cout

cout

cout

cout

}

//displyaing ouput

cout

}

This is the wrong answer #include #include #include #include using namespace std;//function prototypes void input( struct MonthlyBudget rec[]); void printRecord( struct MonthlyBudget r[]);//structure named player struct MonthlyBudget { float amount; } ; int main(){ //structure array with 12 size struct MonthlyBudget sarr[10]; //function call to

11.11: Customer Accounts Lab A student has established the following monthly budget: 500.00 Housing 150.00 Utilities 65.00 Household 50.00 Expenses 50.00 Transportation 250.00 Food 30.00 Medical 100.00 Insurance 150.00 Entertainment 75.00 Clothing 50.00 Miscellaneous Write a mgram that has a MonthlyBudget structure designed to hold each of these expense categories. The mgram should pass the structure to a function that asks the user to enter the amounts spent in each budget category during a month. The mgram should then pass the structure to a function that displays a report indicating the amount over or under in each category, as well as the amount over or under for the entire monthly budget. NOTES: For each of the categories listed above, and in that order, the mgram prompts the user for the the amount spent on X: where X is a category from the above list (e.g. "Insurance"). Using the values read into the structure, the pgram generates a table with a heading and in each row there are four items: the category (e.g. "Housing"), followed by the value budgeted for the category (500.00 in the case of Housing), followed by the value that had been read in for that category, followed by the amount that the actual spent was over or under the category budget. Finally, after the table, is an indication of whether the student is over or under budget. Input Validation. None. SAMPLE RUN #1: ./ETest Interactive Session Hide Invisibles Highlight: None v Show Highlighted Only O Enter . the . amount . spent . on . housing: .500- Enter . the . amount . spent . on . utilities : . 150- Enter . the . amount . spent . on . household . expenses : . 65- Enter . the . amount . spent . on . transportation: .50- Enter . the . amount . spent . on . food: . 250- Enter . the . amount . spent . on . medical . expenses : . 30- Enter . the . amount . spent . on . insurance: . 100- Enter . the . amount . spent . on . entertainment: . 150- Enter . the . amount . spent . on . clothing : . 75- Enter . the . amount . spent . on . miscellaneous . expenses : . 49.99- Category . . . . . Budgeted . . . . . Spent . . . Over (-) /Under- Housing . . . . . 500 . 00 . . . . 500.00 . . . . . 0. 00- Utilities . . . 150 . 00 . . . . 150.00 . . . . 0. 00- Household . . . 65 . 00 . . . . . 65.00 . . . . 0.00- Transportation . . . 50 . 00 . . . . . 50.00 . . . . 0. 00- Food . . . . . 250 . 00 . . . . 250.00 . . . . 0. 00H Medical . . . . . 30 . 00 . . . . . 30.00 . . . . . 0.00- Insurance . 100 .00 . . . . 100.00 . . 0.00- Entertainment . . . . 150 .00 . . . . 150.00. . 0. 00- Clothing . . . . . . . . 75 . 00 . . . . . 75.00. . . 0. 00- Miscellanous . . . . . . 50 . 00 . . . . . 49. 99 . . . . . . . . 0. 01+ For . the . month . you . are . under . budget . by . $0. 01-There is an error in your prompts. Standard Output - Wv Hide Invisibles Your Code's Actual Result: The . amount . spent . on . Housing:e The . amount . spent . on .Utilities:- The . amount . spent . on .Household:- The . amount . spent . on . Expenses: - The . amount . spent . on . Transportation: The . amount . spent . on .Food: Expected Result: The . amount . spent . on .Medical:e Enter . the . amount . spent . on . housing: . Enter . the . amount . spent . on .util The . amount . spent . on . Insurance:e Category . . . . . . . . . . .Budgeted . . . . .Spent . . .Over(=) /Undere The . amount . spent . on . Entertainment:- The . amount . spent . on . Clothing: -- Housing . . . . . 500 . 00 . . . . 500.00 . . . . . . 0. 00- Housing-500-500-O- Utilities . . . . . . . 150 .00 . . . . 150.00 . . . . . . . . . . 0. 00- Utilities-150-150-0- Household . . . . . . . 65 . 00 . . . . . 65. 00 . . . . . . . . 0. 00- Household-65-65-0- Transportation . . . . . . . 50 . 00 . . . . . 50.00 . . . . . . . . 0. 00 Expenses-50-50-0- Food . . . . . . . . . . . . . 250 . 00 . . . . 250 .00 . . . . . . . . . . . . 0.00- Transportation-250-50--200- Medical . . . . . . . . . . . . . 30 . 00 . . . . . 30. 00 . . . . . . . . . . . . 0. 00- Food-30-250-220- Insurance . . . . . . 100 . 00 . . . . 100 .00 . . . . . . . . . 0. 00- Medical-100-30--70- Entertainment . . . . . . . . . 150.00. . . . 150.00 . . . . . . . . . . . . 0. 00 Insurance-150-100--50- Clothing . . . . . . . . . . . . . . . 75.00. . . . . 75.00 . . . . . . . . . . . . 0. 00 Entertainment-75-150-75- Miscellanous . . . . . . . . . . .50.00 . . . . .50.01 . . . . . . . . . . .-0.01- Clothing-50. 01-75-24 . 99 For . the . month . you . are . over . budget . by . $-0. 01-The amount spent.on Housing: + Lab The amount spent.on .Utilities: + The amount spent on Household: + The amount spent on .Expenses: + The amount spent on .Transportation:+ The amount spent on .Food: + The amount spent.on.Medical: + The amount spent on .Insurance: + The amount spent.on .Entertainment: + The amount spent on .Clothing: ---- Housing 500 500 0+ Utilities 150 150 0- Household 65 65 0+ Expenses 50 50 0- Transportation 250 50 -200- Food 30 250 2204 Medical 100 30 -70- Insurance 150 100 -50- Entertainment 75 150 75+ Clothing 49.99 75 25.01+ instead of: Enter the amount.spent on housing: .Enter the amount.spent.on utilities: .Enter the amount.spent.on.household.expenses:| Categoryoooooooo. .. Budgeted.....Spent...Over(-)/Under+ Housing oooooooooooo.. 500.00.. 500.00.0.08080..0.004 Utilitiesooooooooo0. 150.00.. 150.00ooooooooo.0.0.004 Transportationoooooo0..50.00oooo.50.00 09090808090 0.004 FOOdoooooooooooooo0 0 250.00ooo. 250.00oooooo0800 0 0.004 Entertainmentooooooooo 150.00ooo. 150.00oooooo0800 0 0.004 Clothingooooooooo008000 75.00ooo.0 75.00ooo0808080 0 0.004 MiscellanouSoooooo080 050.0080..49.99ooooooooo090 0.01+ For the month .you are under.budget.by.$0.01

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!