A software company sells a package that re discounts are given according to the followi A software company sells a package that retails for $99. Quantity discoun according to the following table. Quantity Discount

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%
Bb https://bb-morte
A software company sells a package that retails for $99. Quantity
discounts are given according to the following table.
A software company sells a package that retails for $99. Quantity discounts are given
according to the following table.
Quantity
Discount
10-19
20-49
20%
30%
50-99
100 or more
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.
Sample Output1:
stv
888 F4
23
2$
%
&
2
3
4
5
6.
8
9
Q
E
R
T
Y
A
S
F
G
H
K
C
V
alt
ion
command
command
..
Transcribed Image Text:Bb https://bb-morte A software company sells a package that retails for $99. Quantity discounts are given according to the following table. A software company sells a package that retails for $99. Quantity discounts are given according to the following table. Quantity Discount 10-19 20-49 20% 30% 50-99 100 or more 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. Sample Output1: stv 888 F4 23 2$ % & 2 3 4 5 6. 8 9 Q E R T Y A S F G H K C V alt ion command command ..
Upload Assignment: Homework .
Sample Output1:
HOMEWORK#4 PART 1
How many units were sold? 0
Units sold must be greater than zero.
Programmer: insert your name here
Sample Output2:
HOMEWORK#4 PART 1
How many units were sold? 57
The total cost of the purchase is $3385.80
Programmer: insert your name here
24
dtv
888
* ES
F1
F3
F4
4)
F9
#3
2$
%
&
*
2
3
4
5
6.
7
8
Q
R
Y
U
A
S
D
F
K
C
V
alt
B
EI
Transcribed Image Text:Upload Assignment: Homework . Sample Output1: HOMEWORK#4 PART 1 How many units were sold? 0 Units sold must be greater than zero. Programmer: insert your name here Sample Output2: HOMEWORK#4 PART 1 How many units were sold? 57 The total cost of the purchase is $3385.80 Programmer: insert your name here 24 dtv 888 * ES F1 F3 F4 4) F9 #3 2$ % & * 2 3 4 5 6. 7 8 Q R Y U A S D F K C V alt B EI
Expert Solution
Step 1

GIVEN:

Write a program to compute the total cost of a purchase after applying discounts.

 

NOTE: As the programming language is not mentioned, we have executed it in C++.

 

PROGRAM:

#include <iostream>

using namespace std;

 

int main()

{

    //Initialize the variables

    float Initial_cost, discount, total_cost;

    int unit;

    

    //Get the number of units from user

    cout<<"How many units were sold : ";

    cin>>unit;

    

    //When unit is zero, print that the units must be greater than 0

    if (unit==0)

    {

        cout<<"Units sold must be greater than 0";

    }

    else

    {

        //cost of one unit is $99

        //So, Initial cost= number of units * 99

        Initial_cost= unit * 99;

        

        //when number of units is between 10 and 19, discount is 20%

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

        {

            discount=0.20;

            total_cost= Initial_cost - (Initial_cost * discount);

        }

        //when number of units is between 20 and 49, discount is 30%

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

        {

            discount=0.30;

            total_cost= Initial_cost - (Initial_cost * discount);

            

        }

        

        //when number of units is between 50 and 99, discount is 40%

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

        {

            discount=0.40;

            total_cost= Initial_cost - (Initial_cost * discount);

            

        }

        //when number of units is greater than and equal to 100, discount is 50%

        else if (unit >= 100 )

        {

            discount=0.50;

            total_cost= Initial_cost - (Initial_cost * discount);

           

        }

         cout<<"The total cost of the purchase is $"<<total_cost;

    }

 

    return 0;

}

 

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 3 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY