Question: 1. Given below is a C++ program which interactively gets data from standard input (keyboard) and displays output on standard output (screen). The program calculates
1. Given below is a C++ program which interactively gets data from standard input (keyboard) and displays output on standard output (screen). The program calculates and print bills for customers of Patrick gas station. Whenever a customer wants to fill up his gas tank, he will be asked for the gas amount to be filled in ringgit. He will also be asked if he needs any assistance from pump attendant. If yes (code 1) and his gas purchase is below 50 ringgit, an additional of 50 sen will be added to the gas bill, otherwise there will be no extra charge. The customer can make payment for his bill by cash (code -- 0) or by card (code -- 1). If he opts for the second method, his printed bill will show an extra 5% service charge (of total).
[NOTE: the program stops when there is no more customer to input]
#include
#include
using namespace std;
int main(){
double amt, total;
int assist, payment;
int count = 0;
char ans;
cout
do {
total = 0;
cout
cout
cin >> amt;
cout
cin >> assist;
cout
cin >> payment;
if (assist == 0)
total = amt;
else {
if (amt
total = amt + 0.50;
else
total = amt;
}
if (payment == 1)
total = total + 0.05 * total;
cout
cout RM "
total
a Copy and paste the code into your Dexcoo editor (NOTE you can get the softcopy of the lab question from e-learning). b. Compile and run the code c. Add/modify/delete the necessary codes in order to make the program reads data from input file, instead of the keyboard, and writes output into an output file, instead of the screen Below are sample inputs and outputs for the program. Sample input Sample output (total payment) 30.00 10 50 20.00 0 0 20 100.000 1 105 80.00 11 84 8.00 1 0 8.5 Ans
cout
cout
cin >> ans;
cout
} while (toupper(ans)!= 'N');
return 0;
}
a. Copy and paste the code into your DevCpp editor [NOTE: you can get the softcopy of the lab question from e-learning].
b. Compile and run the code
c. Add/modify/delete the necessary codes in order to make the program reads data from input file, instead of the keyboard, and writes output into an output file, instead of the screen.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
