Answer to Question #200455 in C++ for Adib

Question #200455

Suppose a business has hired you as a programmer to develop their profit and lost System. And being software developer you have to analyze their last three years data. The business requirements are as follow. If the price of selling and price of cost of a good or product is entered through keyboard. You need to write the code for finding whether the seller (business) has made profit out of business or has suffered loss, you should also find out how much profit or loss has been made by the business in these three years


1
Expert's answer
2021-05-30T07:10:55-0400
#include <iostream>
#include <string>


using namespace std;


//main method
int main(){
	float sellingPrice;
	float priceGood;
	float profit=0;
	float loss=0;
	// If the price of selling and price of cost of a good or product is entered through keyboard.
	for(int year=1; year<=3; year++){
		cout<<"Enter the price of selling for year "<<year<<": ";
		cin>>sellingPrice;
		cout<<"Enter the price of cost of a good or product for year "<<year<<": ";
		cin>>priceGood;
		// finding whether the seller (business) has made profit out of business or has suffered loss, 
		if(sellingPrice>priceGood){
			cout<<"\nThe seller (business) has made profit.\n\n";	
			//find out how much profit or loss has been made by the business in these three years
			profit+=(sellingPrice-priceGood);
		}else{
			cout<<"\nThe seller (business) has suffered loss.\n\n";	
			loss+=(priceGood-sellingPrice);
		}
	}


	cout<<profit<<" profit has been made by the business in these three years.\n";
	cout<<loss<<" loss has been made by the business in these three years.\n\n\n";
	
	system("pause");
	return 0;
}




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