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 purchase after the discount. Format the output to two decimal places, include % sign after the discount percentage and $ before the discount amount & total amount. Your program should include the following functions:
Run Number |
Quantity |
Output |
||
Discount Percentage |
Discount Amount |
Total Amount |
||
1 |
abc |
Display Error Message |
||
2 |
-5 |
Display Error Message |
||
3 |
5 |
0.00% |
$0.00 |
$495.00 |
4 |
19 |
20.00% |
$376.20 |
$1504.80 |
5 |
55 |
40.00% |
$2178.00 |
$3267.00 |
6 |
105 |
50% |
$5197.50 |
$5197.50 |
Once you are satisfied with your results then take a screen shot of run number 1, 3 and 6 and past them below.Paste your screen shot below this line
PROGRAM
//-----------------------------------------//
//Program to calculate discount
//-----------------------------------------//
//include header files
#include<iostream>
#include<iomanip>
//include std namespace
using namespace std;
//--------------------------------------
//Function to find and return discount rate
//Input: number of packages
//Output: Discount rate
//Side Effects: None
//--------------------------------------
float discount_percentage(int p)
{
if(p>=100) return 50.0;
if(p>=50) return 40.0;
if(p>=30) return 30.0;
if(p>=20) return 20.0;
return 0;
}
//main function
int main(void)
{
int packages; //holds number of packages
float amount, //holds total amount
discountAmt,//holds discount amount
discountPercentage; //holds discount percentage
char c; //temporary variable
//repeat until user opt to stop
do{
//read quantity from user
cout<<endl<<"Enter the number of packages purchased: ";
//handle data exception
try
{
cin>>packages;
if(packages < 1)throw(packages);
}
catch(int packages)
{
cout<<endl<<"Invalid input. \nQuantity must be a whole number greater than 0\n\n";
return 0;
}
//calculate and display the results
discountPercentage = discount_percentage(packages);
discountAmt = packages*99*discountPercentage/100.0;
amount = packages*99 - discountAmt;
cout<<fixed<<setprecision(2);
cout<<"Discount percentage = "<< discountPercentage <<" %"
<<endl<<"Amount of discount = "<<"$ "<< discountAmt<<" and"
<<endl<<"Total amount = "<<amount;
cout<<endl<<endl<<"Calculate more (y/n): ";
cin>>c;
}
while(c=='y'||c=='Y');
}
SCREENSHOT OF PROGRAM
OUT OF THE PROGRAM IN CODE::BLOCK
Enter the number of packages purchased: aaa
Invalid input.
Quantity must be a whole number greater than 0
Enter the number of packages purchased: -5
Invalid input.
Quantity must be a whole number greater than 0
Enter the number of packages purchased: 5
Discount percentage = 0.00 %
Amount of discount = $ 0.00 and
Total amount = 495.00
Calculate more (y/n): y
Enter the number of packages purchased: 19
Discount percentage = 0.00 %
Amount of discount = $ 0.00 and
Total amount = 1881.00
Calculate more (y/n): y
Enter the number of packages purchased: 55
Discount percentage = 40.00 %
Amount of discount = $ 2178.00 and
Total amount = 3267.00
Calculate more (y/n): y
Enter the number of packages purchased: 105
Discount percentage = 50.00 %
Amount of discount = $ 5197.50 and
Total amount = 5197.50
Calculate more (y/n):
SCREENSHOT OF THE OUTPUT IN CODE::BLOCK
Part II – Cost Calculator (15 Points) A software company sells a package that retails for...
<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...
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...
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...
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...
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...
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...
Python 3.7 to be used. Just a simple design a program that depends on its own. You should also not need to import anything. No code outside of a function! Median List Traversal and Exception Handling Create a menu-driven program that will accept a collection of non-negative integers from the keyboard, calculate the mean and median values and display those values on the screen. Your menu should have 6 options 50% below 50% above Add a number to the list/array...
Lab #2 - Book Sale Calculator Submit Assignment Download Work file Download Runtime Be sure to include comments at the top of each procedure and at the top of the file. Be sure to use meaningful names for all buttons and labels. In this project, R 'n R Refreshment needs to expand the book sale project done previously. In addition to calculating individual sales and discounts, management wants to know the total number of books sold, the total number of...
excel for accounting Buckeye Company sells three products and offers quantity discounts to the customers. Buckeye Company wants you to make a worksheet that will allow the salesperson (the user) to input the item and the quantity of the item that their customer wants to purchase. The worksheet will then calculate a price quote that the salesperson can give to the customer. The three products and the selling price are as follows: Item Unit Price Portable hard drive $99.00 Thumb...
The procedure is a sample and needs to be modified. The software used is oracle 11g. Provide screen shot of the program running. EX:NO:7 PLISOL PROCEDURE & FUNCTION AIM To develop the package for finding the number of students under each percentage for individual courses using PLISQL procedure and function. DATABASE SCHEMA STUDENT (ST_ID, NAME, COURSECODE, COURSENAME, TOTAL MARKS, PERCENTAGE) PROCEDURE STEP 1: Start STEP 2: Create a table with table name student. STEP 3: Insert at least 4 records...