Answer to Question #298858 in C++ for Caleb

Question #298858

create a C++ program using Microsoft Visual Studio to do the following tasks:



Prompt the user for the salary per year and calculate a Christmas bonus based on the number of years worked as follow. Between 1 to 5 years 1% of salary, and more than five years 2% of salary. Any other values should be considered as an error message.




1
Expert's answer
2022-02-17T05:21:04-0500
#include <iostream>
#include <string>


using namespace std;


int main() {
	float salaryPerYear;
	float christmasBonus=-1;
	int numberYearsWorked;
	cout<<"Ente the salary per year: ";
	cin>>salaryPerYear;
	cout<<"Ente the number of years worked: ";
	cin>>numberYearsWorked;


	if(numberYearsWorked>=1 && numberYearsWorked<=5){
		christmasBonus=0.01*salaryPerYear;
	}else if(numberYearsWorked>5 ){
		christmasBonus=0.02*salaryPerYear;
	}else{
		christmasBonus=-1;	
	}


	if(christmasBonus>0 && salaryPerYear>0){
		cout<<"Christmas bonus: "<<christmasBonus<<"\n\n";
	}else{
		cout<<"Wrong data\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