Answer to Question #263548 in C++ for DANISH

Question #263548

Suppose that sale and bonus are double variables. Write an if...else


statement that assigns a value to bonus as follows: If sale is greater


than $20,000, the value assigned to bonus is 0.10, that is 10%; If sale


is greater than $10,000 and less than or equal to $20,000, the value


assigned to bonus is 0.05, that is 5%; otherwise the value assigned to


bonus is 0, that is 0%.


1
Expert's answer
2021-11-09T13:24:47-0500
#include <iostream>
#include <string>
using namespace std;


void main(){
	double sale, bonus;


	cout<<"Enter sale: ";
	cin>>sale;
	//if sale is greater than $20,000, the value assigned to bonus is 0.10, that is 10%; 
	if(sale>20000){
		bonus=sale*0.10;
	}
	//If sale is greater than $10,000 and less than or equal to $20,000, 
	//the value assigned to bonus is 0.05, that is 5%; 
	else if(sale>10000 && sale<=20000){
		bonus=sale*0.05;
	}
	//otherwise the value assigned to bonus is 0, that is 0%.
	else{
		bonus=0;
	}
	cout<<"Bonus = "<<bonus<<"\n\n";


	cin>>sale;
}

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