Question

NOTE: All C++ programs that you write must have comments at the top with the program...

NOTE: All C++ programs that you write must have comments at the top with the program name, your name, and the pseudocode describing what the program will do.
1. Create a new program that will calculate the total cost for software purchased from a store. Each software package costs $99.00, but discounts are given on the total cost, based on the number of packages purchased.
a. Ask the user for the number of packages they want to buy
b. Calculate the total price, using the discount based on the table below.
c. Print the number of packages and total cost with labels.
Quantity​ ​Discount
10-19​​​ 20%
20-49​​​ 30%
50-99​​​ 40%
100 or more​​ 50%

comment: Please use a C++ compiler, also the using namespace std; to run the program. Thank you
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program:

// totalCost.cpp

// this program will calculate the total price, using the discount given in the question

// declare variable numberOfPackages

// declare variable totalPrice, discount

// get the value of numberOfPackages from user

// then, set the value of discount

//     if (numberOfPackages >= 10 && numberOfPackages <= 19)

//     {

//         discount = 20.0;

//     }

//     else if (numberOfPackages >= 20 && numberOfPackages <= 49)

//     {

//         discount = 30.0;

//     }

//     else if (numberOfPackages >= 50 && numberOfPackages <= 99)

//     {

//         discount = 40.0;

//     }

//     else if (numberOfPackages >= 100)

//     {

//         discount = 50.0;

//     }

// totalPrice = numberOfPackages * (99.0 - ((discount / 100) * 99.0))

// print numberOfPackages, totalPrice

#include <iostream>

using namespace std;

int main()

{

    int numberOfPackages;        // declare variable numberOfPackages

    double totalPrice, discount; // declare variable totalPrice, discount

    // Ask the user for the number of packages they want to buy

    cout << "Enter the number of Packages you want to buy: ";

    cin >> numberOfPackages;

    // set the value of discount variable as per the table

    if (numberOfPackages >= 10 && numberOfPackages <= 19)

    {

        discount = 20.0;

    }

    else if (numberOfPackages >= 20 && numberOfPackages <= 49)

    {

        discount = 30.0;

    }

    else if (numberOfPackages >= 50 && numberOfPackages <= 99)

    {

        discount = 40.0;

    }

    else if (numberOfPackages >= 100)

    {

        discount = 50.0;

    }

    // calculate the total price, using the discount given in the question

    totalPrice = numberOfPackages * (99.0 - ((discount / 100) * 99.0));

    // Print the number of packages and total cost with labels

    cout << "Number of packages: " << numberOfPackages << endl;

    cout << "Total Cost: " << totalPrice;

    return 0; // return 0

}

Note: Please refer to the screenshot of the code to understand the indentation of the code.

Screenshot of the code:

Output and Input:

Add a comment
Know the answer?
Add Answer to:
NOTE: All C++ programs that you write must have comments at the top with the program...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Computer science help! A software company sells their software packages for $99.00 each. They would like...

    Computer science help! A software company sells their software packages for $99.00 each. They would like you to write a program that will calculate and display an invoice for their customers. Quantity discounts are given according to the following table: Quantity   Discount 1 - 9 No discount 10 – 19 20% 20 – 49 30% 50 - 99 40% 100 or more 50% Write a C++ program that asks for the customer’s name and the number of software packages sold...

  • Write a C++ Program Write a program that prompts the user to input a number. The...

    Write a C++ Program Write a program that prompts the user to input a number. The program should then output the number and a message saying whether the number is positive, negative, or zero. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: 1 Name: Your Name ID: Your ID #include <iostream> using namespace std; din main YOUR CODE HERE

  • Part II – Cost Calculator (15 Points) A software company sells a package that retails for...

    Part II – Cost Calculator (15 Points) A software company sells a package that retails for $ 99. Quantity discounts are given according to the following table: Quantity Discount 10 to 19 20% 20 to 49 30% 50 to 99 40% 100 or more 50% Write a program that asks the user to enter the number of packages purchased. The program should then display the discount percentage, amount of the discount (can be 0) and the total amount of the...

  • NOTE: ALL C PROGRAMS MUST BE DONE IN UNIX SYSTEM WITH VI EDITOR 1. Write a...

    NOTE: ALL C PROGRAMS MUST BE DONE IN UNIX SYSTEM WITH VI EDITOR 1. Write a program that asks the user to enter a U.S. dollar amount and then shows how to pay that amount using the smallest number of $20, $10, $5 and $1 bills. Save the file as dollarAmountToNotesFirstinitialLastname.c Sample output: Enter a dollar amount: 93 $20 bills: 4 $10 bills: 1 $5 bills: 0 $1 bills: 3 Hint: Divide the amount by 20 to determine the number...

  • Q4 130 Quantity discounts are given according to the following table O points) A software company...

    Q4 130 Quantity discounts are given according to the following table O points) A software company sells one software package regularly for 99 QR Quantity Discount 20% 10-19 20-49 50-99 |00 or more 40% 50% write ρ program that asks for the number of items sold, and computes the total cost of the purchase. if the user enters an invalid number of items, the program displays invalid Purchasel" message. Sample output Enter number of items: 25 Total cost is 1732.5...

  • THIS MUST BE DONE ON VISUAL STUDIO Write a C# program that computes a the cost...

    THIS MUST BE DONE ON VISUAL STUDIO Write a C# program that computes a the cost of donuts at your local Rich Horton’s store. The cost, of course, depends on the number of donuts you purchase. The following table gives the break down: Donuts Purchased Cost per Donut ($) = 15 0.75 A customer can save on the HST (13%) if they buy 12 or more donuts so only charge HST (use a constant) on the purchase if the customer...

  • C++ Model rocket engines (or motors) are generally purchases in boxes of 24 or packages of...

    C++ Model rocket engines (or motors) are generally purchases in boxes of 24 or packages of 3. If I want 32 engines I would need to purchase 1 box of 24 and 3 packages of 3 (I would end up with 1 extra engine). Write a program that calculates how many boxes and packages you must purchase to get a specific number of engines. Also enter the price of a box and a package and calculate the total cost of...

  • <Program 1: 50 points> software.cpp A software company sells a package that retails for $99. Quantity...

    <Program 1: 50 points> software.cpp A software company sells a package that retails for $99. Quantity discounts are given according to the following table. Quantity Discount 10-19 20% 20-49 30% 50-99 40% 100 or more 50% Write a program that asks for today's date (you MUST use cin >> date. Do not use getline(cin, date)), the company name and the quantity they wish to buy and computes the total cost of the purchase. If the user enters a negative value...

  • Code in c++ please Q1: Software Sales A software company sells a package that retails for...

    Code in c++ please Q1: Software Sales A software company sells a package that retails for $99. Quantity discounts are given according to the following table: QuantityDiscount 10-19 20-49 50-99 100 or more 20% 30% 40% 50% : Write a program that asks for the number of units sold and computes the total cost of the purchase. Input validation: Make sure the number of units is greater than 0. Q2: Book Club Points Community Booksellers has a book club that...

  • Python Language 3. Shipping Charges The Fast Freight Shipping Company charges the following rates (per 500...

    Python Language 3. Shipping Charges The Fast Freight Shipping Company charges the following rates (per 500 miles shipped): 1. Number Guessing Game Write a program for players to guess the number that the program randomly generated. Your program should randomly generate an integer between 1 and 10. After a player guessing a number, your program should display "Too small", "Too large", or "That's it!". Weight of Package (in Kilograms) 2 kg or less Over 2 kg but not more than...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT