Answer to Question #305136 in C++ for reek

Question #305136

a. (overSpeed > 10) ? fine = 200 : fine = 75;

b. (fuel >= 10) ? drive = 150 : drive = 30;

c. (bill >= 50.00) ? tip = 0.20 : tip = 0.10;

1
Expert's answer
2022-03-02T15:33:52-0500
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
	//a. (overSpeed > 10) ? fine = 200 : fine = 75;
	int overSpeed, fine;
	cout << "Please, enter an overspeed: ";
	cin >> overSpeed;
	if (overSpeed > 10)
		fine = 200;
	else
		fine = 75;
	cout << "fine = " << fine << endl;
	
	//b. (fuel >= 10) ? drive = 150 : drive = 30;
	int fuel, drive;
	cout << "Please, enter a fuel: ";
	cin >> fuel;
	if (fuel >=10)
		drive = 150;
	else
		drive = 30;
	cout << "drive = " << drive << endl;
	//c. (bill >= 50.00) ? tip = 0.20 : tip = 0.10
	float bill, tip;
	cout << "Please, enter a bill: ";
	cin >> bill;
	if (bill >= 50.00)
		tip = 0.20;
	else
		tip = 0.10;
	cout << fixed << setprecision(2) << "tip = " << tip << 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