Write a C++ program that asks for the number of units sold and computes the total cost of the purchase.

Write a C++ program that asks for the number of units sold and computes the total cost of the purchase.

Write a C++ program that asks for the number of units sold and computes the total cost of the purchase.

Object:

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 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. C++ Projects.

Code:

#include<iostream>
#include<conio.h>

using namespace std;
void main()
{
double cost, qunt;
cout<<“\n\t**************************************************************************************\n”;
cout<<“\t\t:S o f t w a r e c o m p a n y sells a p a c k a g e:\n”;
cout<<“\t**************************************************************************************\n\n”;

cout<<“Enter here how many unit sold : “;
cin>>qunt;
if(qunt >0 && qunt <10)
{
cost=qunt*99;
cout<<“\nTotal cost of the purchase is : $”<<cost<<endl;
}
else if(qunt >=10 && qunt <=19)
{
cost=qunt*99*0.2;
cout<<“\nTotal cost of the purchase is : $”<<cost<<endl;
}
else if(qunt >=20 && qunt <=49)
{
cost=qunt*99*0.3;
cout<<“\nTotal cost of the purchase is : $”<<cost<<endl;
}
else if(qunt >=50 && qunt <=99)
{
cost=qunt*99*0.4;
cout<<“\nTotal cost of the purchase is : $”<<cost<<endl;
}
else if(qunt > 100)
{
cost=qunt*99*0.5;
cout<<“\nTotal cost of the purchase is : $”<<cost<<endl;
}
else
{
cout<<“\nInvalid Input!!! Please Enter Greater than 0…”;
}
getch();

}

Output:

Write a C++ program that asks for the number of units sold and computes the total cost of the purchase.

Another Program: Write a program that asks the user to enter a number of seconds.

M.A Siddiqui

Hi, I am M.A Siddiqui. I'm a Computer Science Student, In this website, I'm teaching you Multiple languages and provides Projects and other Subjects Notes.

You may also like...

2 Responses

  1. June 7, 2020

    […] Another Program: Write a C++ program that asks for the number of units sold and computes the total c… […]

  2. June 14, 2020

    […] Write a C++ program that asks for the number of units sold and computes the total cost of the purcha… […]

Leave a Reply

Your email address will not be published. Required fields are marked *