Answer to Question #251280 in C++ for Hazzy

Question #251280

At the end of a financial year a company decided to give bonus for their employees. The bonus for each employee is calculated as n times of their basic salary. n is a number between 0 and 2.

 

You are asked to write a C program to calculate the bonus given for the employees.

 

Write a function called calcNoOfTimes() to calculate and return the number of times for each employee. Number of times depend on the employee category as shown in the following table.

 

Employee Category No of times


1 1.0

2 1.5

Other ( 3 - 9) 2.0


In your main function enter the employee category and the salary of an employee from the keyboard. Calculate and display the bonus given for the employee using the above implemented functions.

 

Enter Salary : 15000.00

Enter employee number : 2

Bonus : 22500.00



1
Expert's answer
2021-10-15T01:28:11-0400
#include<iostream>
using namespace std;
void calcNoOfTimes()
{ 
    int n,sal;
	double bonus;
	cout<<"Enter the basic salary: ";
	cin>>sal;
	cout<<"Enter the employee number: ";
	cin>>n;
	if(n==1){
		
	bonus=1.0*sal;
    cout<<"Bonus is: "<<bonus;	
	}
	else if(n==2){
	 bonus=1.5*sal;
    cout<<"Bonus is: "<<bonus;	
	}
	else if(n>=3 && n<=9){
    bonus=2.0*sal;
    cout<<"Bonus is: "<<bonus;}
    else{
    	cout<<"Invalid employee number";
	}
}
int main()
{
	calcNoOfTimes();
	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