In: Computer Science
Plan for a solution by drawing a flowchart
EFG Co wants you to develop a C++ program to calculate the total invoice based on the user inputs item price and the quantity of the item purchased, taking into consideration the discount given for each category as follow:
C++ PROGRAM
#include <iostream>
using namespace std;
int main()
{
int itemprice,quantity;
float total,temp;
cout<<"Enter item Price: ";
//reads input from user
cin>>itemprice;
cout<<"Enter Quantity: ";
//reads inout from user
cin>>quantity;
// calculates total
total = itemprice*quantity;
//checks the condition for Quantity
if(quantity<10)
{
cout<<"Total invoice: "<<total;
}
else if(quantity>=10 && quantity <=20)
{
//calculates the discount
temp = total/100;
temp = temp *10;
total = total - temp;
cout<<"Total invoice: "<<total;
}
else if(quantity>20)
{
//calculates the discount
temp = total/100;
temp = temp *20;
total = total - temp;
cout<<"Total invoice: "<<total;
}
return 0;
}
OUTPUT