Question: Introduction to Programming with C++ 8th Edition Chapter 13 Exercise 37 - Swat The Bugs. Follow the instructions for starting C++ and viewing the SwatTheBugs37.cpp
Introduction to Programming with C++ 8th Edition Chapter 13 Exercise 37 - Swat The Bugs.
Follow the instructions for starting C++ and viewing the SwatTheBugs37.cpp file, which is contained in either the Cpp8\Chap13\SwatTheBugs37 Project folder or the Cpp8\Chap13 folder. (Depending on your C++ development tool, you may need to open the project/solution file first.) The program should calculate and display the total of the prices entered by the user. Run the program. Use your own data to test the program. Notice that the program is not working correctly. Debug the program.
ORIGINAL PROGRAM CODE TO BE DEBUGGED______________________________________
#include
int main() { string item = ""; double price = 0.0; double total = 0.0;
cout << "Item name (X to end): "; getline(cin, item);
while (item != "X" && item != "x") { cout << "Item price: "; cin >> price; total += price; cout << "Item name (X to end): "; getline(cin, item); } //end while
cout << fixed << setprecision(2); cout << "Total: $" << total << endl; return 0; } //end of main function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
