Answer to Question #261512 in C++ for saliha

Question #261512

IFone, a cellular company, offersthe following three postpaid data packages to its customers.

(5+5 marks)

● Package A: For Rs. 100 per month, 1 GB data is provided. Additional data can be purchased for

Rs. 20 per 100 MB.

● Package B: For Rs. 200 per month, 2.5 GB data is provided. Additional data can be purchased

for Rs. 10 per 100 MB.

● Package C: For Rs. 1000 per month, unlimited access is provided.

Part A: Write a program that calculates a customer’s monthly bill. It should ask how many GBs the

customer has used in the month and which package the customer has subscribed for. It should then

display the total amount due.

Part-B: Modify the program in Part A so that it also displays how much money Package A customers

would save if they purchased packages B or C, and how much money Package B customers would save if

they purchased Package A or C. If there are no savings for a particular package, your program shall print

an appropriate message.


1
Expert's answer
2021-11-06T12:07:51-0400
Part A: 
#include <iostream>


using namespace std;


int main() {
	float GBs;
	char package;
	float totalAmountDue=0;
	//ask how many GBs the customer has used in the month and which package the customer has subscribed for. 
	cout<<"How many GBs the customer has used?: ";
	cin>>GBs;
	cout<<"Which package the customer has subscribed for (A,B or C)?: ";
	cin>>package;
	//Package A: For Rs. 100 per month, 1 GB data is provided. Additional data can be purchased for Rs. 20 per 100 MB.
	if(package=='a' || package=='A'){
		totalAmountDue=100.0;
		if(GBs>1){
			totalAmountDue+=((GBs-1.0))*200;
		}
	}
	//calculates a customer’s monthly bill.
	//Package B: For Rs. 200 per month, 2.5 GB data is provided. 
	//Additional data can be purchased for Rs. 10 per 100 MB.
	if(package=='b' || package=='B'){
		totalAmountDue=200.0;
		if(GBs>2.5){
			totalAmountDue+=((GBs-2.5))*100;	
		}
	}
	//Package C: For Rs. 1000 per month, unlimited access is provided.
	if(package=='c' || package=='C'){
		totalAmountDue=1000.0;
	}
	//display the total amount due.
	cout<<"\nThe total amount due: "<<totalAmountDue<<"\n\n";


	cin>>GBs;
	return 0;
}






Part B: 


#include <iostream>


using namespace std;


int main() {
	float GBs;
	char package;
	float totalAmountDueA=0;
	float totalAmountDueB=0;
	float totalAmountDueC=0;
	//ask how many GBs the customer has used in the month and which package the customer has subscribed for. 
	cout<<"How many GBs the customer has used?: ";
	cin>>GBs;
	cout<<"Which package the customer has subscribed for (A,B or C)?: ";
	cin>>package;
	totalAmountDueA=100.0;
	if(GBs>1){
		totalAmountDueA+=((GBs-1.0))*200;
	}
	totalAmountDueB=200.0;
	if(GBs>2.5){
		totalAmountDueB+=((GBs-2.5))*100;	
	}
	totalAmountDueC=1000.0;
	//Package A: For Rs. 100 per month, 1 GB data is provided. Additional data can be purchased for Rs. 20 per 100 MB.
	if(package=='a' || package=='A'){
		//display the total amount due.
		cout<<"\nThe total amount due: Rs."<<totalAmountDueA<<"\n";
		if(totalAmountDueA>totalAmountDueB){
			double packageAmount=totalAmountDueA-totalAmountDueB;
			cout<<"You will Rs."<<packageAmount<<" save if you purchase packages B\n\n";	
		}
		if(totalAmountDueA>totalAmountDueC){
			double packageAmount=totalAmountDueA-totalAmountDueC;
			cout<<"You will Rs."<<packageAmount<<" save if you purchase packages C\n\n";	
		}
	}
	//calculates a customer’s monthly bill.
	//Package B: For Rs. 200 per month, 2.5 GB data is provided. 
	//Additional data can be purchased for Rs. 10 per 100 MB.
	if(package=='b' || package=='B'){
		//display the total amount due.
		cout<<"\nThe total amount due: Rs."<<totalAmountDueB<<"\n\n";
		if(totalAmountDueA<totalAmountDueB){
			double packageAmount=totalAmountDueB-totalAmountDueA;
			cout<<"You will Rs."<<packageAmount<<" save if you purchase packages A\n\n";	
		}
		if(totalAmountDueB>totalAmountDueC){
			double packageAmount=totalAmountDueB-totalAmountDueC;
			cout<<"You will Rs."<<packageAmount<<" save if you purchase packages C\n\n";	
		}
	}
	//Package C: For Rs. 1000 per month, unlimited access is provided.
	if(package=='c' || package=='C'){
		cout<<"\nThe total amount due: Rs."<<totalAmountDueC<<"\n\n";
		if(totalAmountDueA<totalAmountDueC){
			double packageAmount=totalAmountDueC-totalAmountDueA;
			cout<<"You will Rs."<<packageAmount<<" save if you purchase packages A\n\n";	
		}
		if(totalAmountDueB<totalAmountDueC){
			double packageAmount=totalAmountDueC-totalAmountDueB;
			cout<<"You will Rs."<<packageAmount<<" save if you purchase packages B\n\n";	
		}
	}




	cin>>GBs;
	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
APPROVED BY CLIENTS