auto and const
Completed
Read an integer n. Declare const double RATE = 0.075; and use auto for the variables tax = n * RATE and total = n + tax. Print tax and total with 2 decimals.
Input
One integer.
Output
Two lines.
Example
Input
100
Output
7.50 107.50
Editor
C++
Hints
auto lets the compiler work out the type from the initial value.
const values can't be changed later.
Solution explanation
Here auto deduces double because n * RATE is a double.
Show solution
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
const double RATE = 0.075;
int n;
cin >> n;
auto tax = n * RATE;
auto total = n + tax;
cout << fixed << setprecision(2) << tax << "\n" << total << "\n";
return 0;
}