Answer to Question #266075 in C++ for DANISH

Question #266075

(only by if-else or nested if-else) (not by loops)

Write a program which calculates the monthly Budget of a person. The program will read the

monthly salary of the person. Then give following options:


Press 1 to calculate gas bill charges

Press 2 to calculate electricity bill charges

Press 3 to calculate fueling charges.

Press 4 to calculate house rent charges


His monthly gas bill charges are 10% of his salary, electricity bill charges are 5% of his salary. His monthly

fueling charges are 10% of his salary, and his house rent charges are 15 %. Your program will calculate and

display the corresponding charges based on the selection (1, 2, 3, or 4)


1
Expert's answer
2021-11-15T00:30:54-0500
#include<iostream>
using namespace std;


int main(){
	cout<<"Press 1 to calculate gas bill charges\nPress 2 to calculate electricity bill charges"<<endl;
	cout<<"Press 3 to calculate fueling charges.\nPress 4 to calculate house rent charges\n";
	int x;
	cin>>x;
	cout<<"Enter the monthly salary\n";
	float sal;
	cin>>sal;
	if(x==1){
		cout<<"Gas bill charges are: "<<0.1 * sal<<endl;
	}
	else if(x==2){
		cout<<"Electricity bill charges: "<<0.05 * sal<<endl;
	}
		else if(x==3){
		cout<<"Fueling charges are: "<<0.1 * sal<<endl;
	}
	else if(x==4){
		cout<<"House rent charges: "<<0.15 * sal<<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