I need help with Program Please

A program that calculates the total of a retail sale. The program must ask user for retail price of item purchased and the sales tax rate. The program should then calculate and display on screen the sales tax amount for purchase and the total.


If someone can write out program for me I'm kinda stuck I'm a new c ++ student


#include <iostream>
using namespace std;
int main()
{
float cost;
cout << "Retail Price: ";
cin >> cost;
cout << "Sales Tax Rate is .1" << endl;
float price = ( cost * .1 ) + cost;
cout << price << endl;
float total;
cout << "total " << endl;
system("pause");
return 0;
}
Last edited on
closed account (48T7M4Gy)
Standby, our duty homework programming team have been assigned to your project and will report to you very soon.
Thanks :)
closed account (48T7M4Gy)
Cheeky. :]

Actually, the team had trouble with it too and decided to flick it to StackOverflow. Shouldn't be too long now.
closed account (E0p9LyTq)
If someone can write out program for me I'm kinda stuck I'm a new c ++ student


Here's the program:

1
2
3
4
5
6
7
8
#include <iostream>

int main ()
{
   std::cout << "Write your own homework.\n";

   return 0;
}
closed account (48T7M4Gy)
LOL

(BTW you should have used vectors and not C-style arrays)
Last edited on
real funny lol well this is what i got i need to display total and sales tax amount


#include <iostream>
using namespace std;
int main()
{
float cost;
cout << "Retail Price: ";
cin >> cost;
cout << "Sales Tax Rate is .1" << endl;
float price = ( cost * .1 ) + cost;
cout << price << endl;
float total;
cout << "total " << endl;
system("pause");
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <iostream>
#include <iomanip>

int main()
{
    // ask user for retail price of item purchased
    std::cout << "please enter the retail price of item purchased: " ;

    // read the user input into a variable
    double retail_price ;
    std::cin >> retail_price ;

    // ask user for sales tax rate
    std::cout << "please enter the sales tax rate as a percentage: " ;

    // read the user input into another variable
    double percent_sales_tax ;
    std::cin >> percent_sales_tax ;

    // if the retail price and sales tax rate are positive values
    if( retail_price > 0 && percent_sales_tax > 0 )
    {
        // compute sales tax amount
        const double sales_tax_amount = retail_price * percent_sales_tax / 100.0 ;

        // calculate total amount
        const double gross_amount = retail_price + sales_tax_amount ;

        // display on screen the sales tax amount for purchase and the total.
        std::cout << std::fixed // fixed point format,
                  << std::setprecision(2) // with two digits after the decimal point
                  << "sales tax amount: " << sales_tax_amount << '\n'
                  << "    total amount: " << gross_amount << '\n' ;
    }

    else std::cout << "there was an error in the data that was entered.\n" ; // invalid input
}
closed account (48T7M4Gy)
Good on you rave2014e well done.

maybe

1
2
float tax = cost *.1;
float price = cost + tax;


1
2
3
cout << " Cost: " << cost<< endl;
cout << "  Tax: " << tax << endl;
cout << "Price: " << price << endl;
Last edited on
Thanks everyone you saved the day :)
Topic archived. No new replies allowed.