a. (overSpeed > 10) ? fine = 200 : fine = 75;
b. (fuel >= 10) ? drive = 150 : drive = 30;
c. (bill >= 50.00) ? tip = 0.20 : tip = 0.10;
#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;
}
Comments
Leave a comment