In: Computer Science
Complete the attached code so that if the user enters the number 22 for the number of items purchased and 10.98 for the price of each, the following results are displayed:
The total bill is $241.56
Hint: It must include cin and variables.
// This program will read the quantity of an item and its price
// Then print the total price.
// The input will come from the keyboard and the output will go to the monitor.
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int quantity; // number of item purchased
float itemprice; // price of every article
float totalbill; // total account
cout << setprecision(2) << fixed << showpoint;
cout << “please, enter number of items purchased” << endl;
// indicate the instruction to record the amount
// indicate the instruction to ask the price
// indicate the instruction to record the price of each item
// indicate the assignment instruction to determine the total account
// indicate the instruction to show the total on the monitor
return 0;
}
#include <iostream> #include <iomanip> using namespace std; int main() { int quantity; // number of item purchased float itemprice; // price of every article float totalbill; // total account cout << setprecision(2) << fixed << showpoint; cout << "please, enter number of items purchased" << endl; // indicate the instruction to record the amount cin >> quantity; // indicate the instruction to ask the price cout << "please, enter price of item" << endl; // indicate the instruction to record the price of each item cin >> itemprice; // indicate the assignment instruction to determine the total account totalbill = quantity * itemprice; // indicate the instruction to show the total on the monitor cout << "The total bill is $" << totalbill << endl; return 0; }