You are given two variables, already declared and assigned values, one of type double, named price, containing the price of an order, and the other of type int, named totalNumber, containing the number of orders. Write an expression that calculates the total price for all orders.

Respuesta :

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main() {

//variable to store input

double price;

int totalNumber;

// variable to store total price

double total_price;

cout<<"Enter the price of an order:";

// read the price of an order

cin>>price;

cout<<"Enter the number of orders:";

// read the total number of orders

cin>>totalNumber;

// calculate total price of all orders

total_price=price*totalNumber;

cout<<"total price of all orders: "<<total_price<<endl;

return 0;

}

Explanation:

Declare three variables "price" of double type,"totalNumber" of int type And "total_price" of type double.Read the value of an order and number of orders. The calculate the total price by multiply "price" with "totalNumber" and assign it to variable "total_price". Print the total price.

Output:

Enter the price of an order:12.5                                                                                                                              

Enter the number of orders:3                                                                                                                                  

total price of all orders: 37.5