Question

In: Computer Science

Complete the attached code so that if the user enters the number 22 for the number...

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;
}

Solutions

Expert Solution

#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;
}

Related Solutions

Write Java code that allows a user to repeatedly enter numbers. Each time the user enters...
Write Java code that allows a user to repeatedly enter numbers. Each time the user enters a number, the program should print out the average of the last 3 numbers (or all numbers if 3 or less have been entered). I would like a detailed explanation so that a beginner level Java programmer could understand.
If you execute the code shown below and the user enters the following sales amounts for...
If you execute the code shown below and the user enters the following sales amounts for Region 1: 25000, 30000, 10000, –1, then, the value stored in totRegSales when the inner loop ends will be __________. int sales = 0; int region = 1; int totRegSales = 0; while (region < 3) {    cout << "First sales amount for Region "         << region << ": ";    cin >> sales;    while (sales > 0)    {      ...
TO BE DONE IN JAvA Complete the calculator program so that it prompts the user to...
TO BE DONE IN JAvA Complete the calculator program so that it prompts the user to enter two integers and an operation and then outputs the answer. Prompt the user three times, don't expect all the inputs on one line. Possible operations are + - * / No other words or symbols should be output, just the answer. Requested files import java.util.Scanner; /** * This is a simple calculator Java program. * It can be used to calculate some simple...
Python 3 Fix the code so if the user enter the same bar code more than...
Python 3 Fix the code so if the user enter the same bar code more than three times, it shows a warning message indicating that the product was already tested 3 times and it reached the limits Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1, weight=1) window.grid_rowconfigure(1, weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20,...
Python 3 Fix the code so if the user enter the same bar code more than...
Python 3 Fix the code so if the user enter the same bar code more than three times, it shows a warning message indicating that the product was already tested 3 times and it reached the limits Code: import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook from tkinter import messagebox from datetime import datetime window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window,...
Python 3 Fix the code so if the user does not select a value in the...
Python 3 Fix the code so if the user does not select a value in the sold by field, it shows a warning message indicating "Choose one value" import tkinter as tk from tkcalendar import DateEntry from openpyxl import load_workbook window = tk.Tk() window.title("daily logs") window.grid_columnconfigure(1,weight=1) window.grid_rowconfigure(1,weight=1) # labels tk.Label(window, text="Bar code").grid(row=0, sticky="W", pady=20, padx=20) tk.Label(window, text="Products failed").grid(row=1, sticky="W", pady=20, padx=20) tk.Label(window, text="Money Lost").grid(row=2, sticky="W", pady=20, padx=20) tk.Label(window, text="sold by").grid(row=3, sticky="W", pady=20, padx=20) tk.Label(window, text="Failed date").grid(row=4, sticky="W", pady=20, padx=20) #...
In python Write the code to ask a user to enter a number in the range...
In python Write the code to ask a user to enter a number in the range of 1-100. Have the code checked to make sure that it is in this range. If it is not, let the user re-enter the number. The user should be able to re-enter numbers until the number is within the correct range.
4. Prompt user to enter a double number from console. Round this number so it will...
4. Prompt user to enter a double number from console. Round this number so it will keep 2 places after the decimal point. Display new number. For example, number 12.3579 will round to 12.36; number 12.4321 will round to 12.43 This is meant to be written in Java 14.0
Python. Write a code that asks the user to enter a string. Count the number of...
Python. Write a code that asks the user to enter a string. Count the number of different vowels ( a, e, i, o, u) that are in the string and print out the total. You may need to write 5 different if statements, one for each vowel. Enter a string: mouse mouse has 3 different vowels
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT