Question

In: Computer Science

Make a program that calculates the total of a retail sale. The program should ask the...

Make a program that calculates the total of a retail sale. The program should ask the user for the following: the retail price of the item being purchased and the sales tax rate. Once the information has been entered, the program should calculate and display the following: the sales tax for the purchase and the total sale.

Solutions

Expert Solution

CODE IN C++->

#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
}

OUTPUT->

NOTE-> FOR ANY DOUBTS AND QUERIES PLEASE COMMENT AND IF YOU LIKED MY ANSWER PLEASE UPVOTE.


Related Solutions

Write a program that calculates the area and circumference of a circle. It should ask the...
Write a program that calculates the area and circumference of a circle. It should ask the user first to enter the number of circles n, then reads the radius of each circle and stores it in an array. The program then finds the area and the circumference, as in the following equations, and prints them in a tabular format as shown in the sample output. Area = πr2 , Circumference = 2πr, π = 3.14159 Sample Output: Enter the number...
Write a program in C++ that calculates the sum of two fractions. The program should ask...
Write a program in C++ that calculates the sum of two fractions. The program should ask for the numerators and denominators of two fractions and then output the sum of the two fractions. You will need to write four functions for this program, one to read the inputted data, one to calculate the sum of the two fractions, one to find the Greatest Common Divider (GCD) between the numerator and denominator and a function that will display the end result....
Write a C program that calculates a student grade in the C Programming Class. Ask the...
Write a C program that calculates a student grade in the C Programming Class. Ask the user to enter the grades for each one of the assignments completed in class: Quiz #1 - 25 points Quiz #2 - 50 points Quiz #3 - 30 points Project #1 - 100 points Project #2 - 100 points Final Test - 100 points The total of the quizzes count for a 30% of the total grade, the total of the projects counts for...
Write a program that calculates the salary of employees. The program should prompt the user to...
Write a program that calculates the salary of employees. The program should prompt the user to enter hourly rate and number of hours of work a day. Then, the program should display the salary daily, bi-weekly (5 days a week), and monthly. Sample program: Enter your hourly rate: >>> 20 Enter how many hours you work a day: >>> 8 Your daily salary is: $160 Your bi-weekly salary is: $1600 Your monthly: $3200
Please use Phyton to write a program: Write a program that calculates and displays the total...
Please use Phyton to write a program: Write a program that calculates and displays the total bill at a restaurant for a couple that is dining. The program should collect from the couple, cost of each meal, and the percentage of the final cost that they would like to tip. The sales tax in the state where the restaurant exists is 7.5%. Display to the user, line by line: Total Cost of Both Meals Sales Tax in dollars Tip in...
Note that the question does not ask for the total make costs and the total buy...
Note that the question does not ask for the total make costs and the total buy costs but instead asks for the difference between the two. ______________________________________________________ BKF.com provides banks access to sophisticated financial information and analysis via the web, enabling them to instantly evaluate both personal and commercial loan applications. To better focus on its client services, BKF.com is considering outsourcing some of its internal functions. Its controller, Jenny Lee, suggests starting with the company's internal email system. She...
/******************************************************************************** * INSTRUCTIONS * * This program calculates the total fee charged for multiple accounts *...
/******************************************************************************** * INSTRUCTIONS * * This program calculates the total fee charged for multiple accounts * * Fix the errors so the program compiles and can produce the following output * * How many accounts do you have?: 2 * * Enter number of checks for account 1: 10 * * Enter number of checks for account 2: 10 * * The sum of the fees for 2 accounts is $22.00 * *********************************************************************************/ import java.util.Scanner; public class BankCharges { public...
In Java write an application that calculates total retail values for 5 different shoes entered by...
In Java write an application that calculates total retail values for 5 different shoes entered by the user. Shoe 1 $15.50 Shoe 2 $27.30 Shoe 3 $34.50 Shoe 4 $42.11 Shoe 5 $54.25 Application must read shoe number and quantity sold for each product stdin, compute the total value of that sale, and add the value of that sale to a grand total for that shoe. After all data has been entered, display the total value of each of the...
In C++ write an application that calculates total retail values for 5 different shoes entered by...
In C++ write an application that calculates total retail values for 5 different shoes entered by the user. Shoe 1 $15.50 Shoe 2 $27.30 Shoe 3 $34.50 Shoe 4 $42.11 Shoe 5 $54.25 Application must read shoe number and quantity sold for each transaction stdin, compute the total value of that sale, and add the value of that sale to a grand total for that shoe. After all data has been entered, display the total value of each of the...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT