Answer to Question #240310 in C++ for adil

Question #240310

Write a pseudo code of a program that calculates and outputs how much a products

price has increased or decreased in percentage. If the new price is more than the original price, output

“Increased”, similarly If the new prince is less then original price output “decreased”.

ID

1

2

3

4

Original Price

4950

995521

56702

95040

New Price

7890

447984

28351

19008

Your output should have this format

ID X percent Increase

ID X percent decreased

Example

ID:5 65 percent Increased

ID:6 40 percent decreased


1
Expert's answer
2021-09-22T03:48:44-0400
#include<iostream>
using namespace std;
int main()
{
	int ID1,ID2,ID3,ID4,ID5;
	int P1,P2,P3,P4,P5,N1,N2,N3,N4,N5;
	double profit,loss;
	for(int i=0;i<5;i++){
	cout<<"Enter the ID of the product: ";
	cin>>ID1;
	cout<<"Enter the original price: ";
	cin>>P1;
	cout<<"Enter the new price: ";
	cin>>N1;
	cout<<"Enter the ID of the product: ";
	cin>>ID2;
	cout<<"Enter the original price: ";
	cin>>P2;
	cout<<"Enter the new price: ";
	cin>>N1;
	cout<<"Enter the ID of the product: ";
	cin>>ID3;
	cout<<"Enter the original price: ";
	cin>>P3;
	cout<<"Enter the new price: ";
	cin>>N3;
	cout<<"Enter the ID of the product: ";
	cin>>ID4;
	cout<<"Enter the original price: ";
	cin>>P4;
	cout<<"Enter the new price: ";
	cin>>N4;
	cout<<"Enter the ID of the product: ";
	cin>>ID5;
	cout<<"Enter the original price: ";
	cin>>P5;
	cout<<"Enter the new price: ";
	cin>>N5;
	
	if(N1>P1){
		double P11=(((N1-P1)/P1)*100);
		cout<<"ID: "<<ID1<<" "<<P11<<" percentage increased"<<endl;
	}
	else if(P1>N1){
	double L11=(((P1-N1)/P1)*100);
	cout<<"ID: "<<ID1<<" "<<L11<<" percentage decreased"<<endl;
	}
		if(N2>P2){
		double P22=(((N2-P2)/P2)*100);
		cout<<"ID: "<<ID2<<" "<<P22<<" percentage increased"<<endl;
	}
	else if(P2>N2){
	double L22=(((P2-N2)/P2)*100);
	cout<<"ID: "<<ID2<<" "<<L22<<" percentage decreased"<<endl;
	}
		if(N3>P3){
		double P33=(((N3-P3)/P3)*100);
		cout<<"ID: "<<ID3<<" "<<P33<<" percentage increased"<<endl;
	}
	else if(P3>N3){
	double L33=(((P3-N3)/P3)*100);
	cout<<"ID: "<<ID3<<" "<<L33<<" percentage decreased"<<endl;
	}
		if(N4>P4){
		double P44=(((N4-P4)/P4)*100);
		cout<<"ID: "<<ID4<<" "<<P44<<" percentage increased"<<endl;
	}
	else if(P4>N4){
	double L44=(((P4-N4)/P4)*100);
	cout<<"ID: "<<ID4<<" "<<L44<<" percentage decreased"<<endl;
	}
		if(N5>P5){
		double P55=(((N5-P5)/P5)*100);
		cout<<"ID: "<<ID5<<" "<<P55<<" percentage increased"<<endl;
	}
	else if(P5>N5){
	double L55=(((P5-N5)/P5)*100);
	cout<<"ID: "<<ID5<<" "<<L55<<" percentage decreased"<<endl;
	}
	
}}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS