20.0k views
2 votes
List all information for each order item. Include an item total, which can be calculated by multiplying the Quantity and Paid each columns. Use a column alias for the calculated value to show the heading "Item Total" in the output

User Chui Tey
by
4.9k points

1 Answer

1 vote

Answer:

#include<iostream>

Using namespace std;

int main()

{

int n, qty;

double price, amount;

cout<<"Number of items ";

cin>>n;

cout<<"ITEM<<"\t"<<"QUANTITY"<<"\t"<<"PRICE"<<"\t"<<"ITEM TOTAL";

for(int i= 1; I<= n; i++)

{

cin>>qty;

cin>>price;

amount = qty * price;

cout<<i<<"\t "<<qty<<"\t"<<price<<"\t"<<amount;

}

}

Step-by-step explanation

The above program is written in C++ programming language

5 variables are declared and used in the program

n is declared as an integer to represent the total number of items

qty is declared as integer to represent the total quantity of each item

price is declared as double to represent the amount of each individual item

amount is declared as double to represent the total amount of an item; it is gotten by qty * price

i is declared as integer to iterated between each items

The amount of each item is calculated within the iteration and also printed immediately

User Tauquir
by
4.4k points