#include<iostream>
using namespace std;
void main() {
double thisYearFee, lastYearFee, percentage;
cout << "Please enter last year's tuition fee: ";
cin >> lastYearFee;
cout << "Please enter this year's tuition fee: ";
cin >> thisYearFee;
percentage = (thisYearFee - lastYearFee)/lastYearFee;
cout << "The tuition increases " << percentage*100 << "%.\n";
char line[100];
cin.getline(line,100);
cin.getline(line,100);
}
|
Please enter last year's tuition fee: 42310 Please enter this year's tuition fee: 45678 The tuition increases 7.96029%. |
double thisYearFee, lastYearFee, percentage;
You type
doule thisYearFee, lastYearFee, percentage;
Then there will be an error message.
#include<iostream> /_____________ these two lines are
included
using namespace std; \
so that the libaries
about input/output
are available to the program
void main() {
<----------------- fill your codes
here
}
| Code |
Explanation |
|---|---|
double thisYearFee, lastYearFee,
percentage; |
declare 3 decimal numbers |
cout << "Please enter last year's
tuition fee: "; |
cout <<"blah blah blah"; outputs blah blah blah on the screen |
cin >> lastYearFee; |
cin >> x; asks the user to input a
value. The value will be stored in a variable named x. |