Question: This question looks long but it has a quick answer. working in c++, I have a sentient controlled while loop (see the below picture for

This question looks long but it has a quick answer.

working in c++, I have a sentient controlled while loop (see the below picture for the details), basically the user chooses either a hard or soft copy and whether or not they want a discount. They can then choose to check out another book and the loop starts over, it is cancelled when the user enters something other than "c" when prompted to check out another book and the program then outputs a sale summary. I am have a lot of issues with the math. The problem is that the summary includes "the total before the tax and discount" and also "the total after the tax and discount (6% tax)" Hence the need for both total1 and total2. My code works as long as the first book the user gets applies a discount otherwise it doesn't work... i'll attach the output for my code and the output that my code is supposed to match, any help would be appreciated, thanks!!

This question looks long but it has a quick answer. working in

MY OUTPUT:

c++, I have a sentient controlled while loop (see the below picture

THE OUTPUT THAT THE SUMMARY NEEDS TO MATCH

for the details), basically the user chooses either a hard or soft

MY CODE (Non-image form)

while ((action1 == 'c') || (action1 == 'C'))

{

cout

cout

cin >> cost;

cout

cin >> action3;

if (action3 == 'h' || action3 == 'H')

{

total1 += cost + 5;

}

else

{

total1 += cost + 2;

}

cout

cin >> action;

if (action == 'd')

{

total2 += total1 - (total1 * .1);

}

else

{

if (action3 == 'h' || action3 == 'h')

{

total2 = total2 + (cost + 5);

}

else

total2 = total2 + (cost + 2);

}

cout

cin >> action1;

checked++;

}

cout

cout

cout

total7 = (total2 + (total2 * tax));

cout

while ((action! == ) 11 (action! 'C')) = cout action3; total! += cost + 5; else total! += cost + 2; cout action3; total! += cost + 5; else total! += cost + 2; cout

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 Databases Questions!