Question: Why does this c++ program close after entering the quantity and price instead of displaying the total bill? #include #include using namespace std; int main()
Why does this c++ program close after entering the quantity and price instead of displaying the total bill?
#include
int main() { int quantity; // contains the amount of items purchased float itemPrice; // contains the price of each item float totalBill; // contains the total bill. cout << setprecision(2) << fixed << showpoint; // formatted output cout << "Please input the number of items bought " << endl; cin >> quantity; // Fill in the prompt to ask for the price. cout << "Please enter Item Price" << endl; // Fill in the input statement to bring in the price of each item. cin >> itemPrice; // Fill in the assignment statement to determine the total bill. totalBill = quantity * itemPrice; // Fill in the output statement to print total bill, // with a label to the screen. cout << "The bill is $" << totalBill << endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
