You are viewing this question as it will appear in the manual grading interface. Return to the normal view when you are done.

Autograder Demo: Sales Tax in C++

Write a program in C++ that prompts the user for the price of an article (before taxes) and that prints the price of the article including state sales tax at 6.25%, county sales tax at 1.00%, and city sales tax at 1.50%. The result must be printed with two decimal places.

tax.cpp

Correct answer

Reveal suggested answer
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <iomanip>

using namespace std;

#define STATE_TAX  6.25
#define COUNTY_TAX 1.00
#define CITY_TAX   1.50

int main(void) {

    double price;
    double tax;
    
    cin >> price;
    
    tax = price * (STATE_TAX + COUNTY_TAX + CITY_TAX) / 100;
    cout << fixed << setprecision(2) << price + tax << endl;


    return 0;
}

Student view placeholder

In student views this area is used for assessment and score info.
Tools

Staff information

Question

Title:
Autograder Demo: Sales Tax in C++

Variant

Started at:
2026-09-19 10:07:03 (CDT)
Duration:
0s
Show/Hide answer
{}
History
dec frac
rad deg