Answer to Question #266079 in C++ for DANISH

Question #266079

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

Write a program that displays the following menu to the user:


Press 1 for Permanent Employee

Press 2 for Daily wages Employee


After selecting the appropriate employee calculate salary and medical charges for the employees. Following 

menu would be displayed:


Press a to calculate Salary

Press b to calculate medical charges.


The daily wages employees are paid 400 per hour while permanent employees are paid 800 per hour. 

When you would calculate the salary, first you need to ask for the number of hours for which the 

employee has worked so far. The permanent employees are paid 5% medical charges of their total 

salary while daily wages are paid 3% of medical charges. For calculating medical allowance no further 

selection/input is required.


1
Expert's answer
2021-11-15T12:36:37-0500
#include <iostream>
#include <iomanip>


using namespace std;




int main()
{
	float hours;
	float salary;
	float medicalCharges;
	int choice12;
	char choiceAB;
	cout<<"Press 1 for Permanent Employee\n";
	cout<<"Press 2 for Daily wages Employee\n";
	cout<<"Your choice: ";
	cin>>choice12;


	cout<<"Press a to calculate Salary\n";
	cout<<"Press b to calculate medical charges.\n";
	cout<<"Your choice: ";
	cin>>choiceAB;
	cout<<"Enter the number of hours: ";
	cin>>hours;


	//for Permanent Employee
	if(choice12==1){
		salary=hours*800.0;
		//permanent employees are paid 800 per hour.
		if(choiceAB=='a' || choiceAB=='A'){
			cout<<fixed<<"The salary = "<<setprecision(2)<< salary<<"\n\n";
		}else if(choiceAB=='B' || choiceAB=='b'){
			//The permanent employees are paid 5% medical charges of their total salary 
			 medicalCharges=salary*0.05;
			cout<<fixed<<"The medical charges of the total salary = "<<setprecision(2)<< medicalCharges<<"\n\n";
		}
	}
	//for Daily wages Employee
	if(choice12==2){
		//The daily wages employees are paid 400 per hour 
		salary=hours*400.0;
		if(choiceAB=='a' || choiceAB=='A'){
			cout<<fixed<<"The salary = "<<setprecision(2)<< salary<<"\n\n";
		}else if(choiceAB=='B' || choiceAB=='b'){
			//daily wages are paid 3% of medical charges
			 medicalCharges=salary*0.03;
			cout<<fixed<<"The medical charges of the total salary = "<<setprecision(2)<< medicalCharges<<"\n\n";
		}
	}




	cin>>hours;
	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