auto and const

Lab C++ Beginner 10 points

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
Sample input available Sample output available
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;
}
Output
Answer
HOME LEARN COMMUNITY DASHBOARD