SlideShare una empresa de Scribd logo
1 de 2
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 c++ program that asks for the number of units purchased and computes the total cost of
the purchase.
Solution
#include <iostream>
using namespace std;
int main ()
{
int units;
float totalCost;
cout << "Please enter the number of units purchased : ";
cin >> units;
if((units >= 10) && (units <= 19)){
totalCost = (99 * units) - ((99 * units * 20)/100);
cout<<"Total Cost : " << totalCost;
}
else if((units >= 20) && (units <= 49)){
totalCost = (99 * units) - ((99 * units * 30)/100);
cout<<"Total Cost : " << totalCost;
}
else if((units >= 50) && (units <= 99)){
totalCost = (99 * units) - ((99 * units * 40)/100);
cout<<"Total Cost : " << totalCost;
}
else if(units >= 100){
totalCost = (99 * units) - ((99 * units * 50)/100);
cout<<"Total Cost : " << totalCost;
}
else{
totalCost = 99 * units;
cout<<"Total Cost : " << totalCost;
}
return 0;
}

Más contenido relacionado

Similar a A software company sells a package that retails for $99- Quantity disc.docx

#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx
mayank272369
 

Similar a A software company sells a package that retails for $99- Quantity disc.docx (19)

Cis 115 Enhance teaching / snaptutorial.com
Cis 115  Enhance teaching / snaptutorial.comCis 115  Enhance teaching / snaptutorial.com
Cis 115 Enhance teaching / snaptutorial.com
 
CIS 115 Become Exceptional--cis115.com
CIS 115 Become Exceptional--cis115.comCIS 115 Become Exceptional--cis115.com
CIS 115 Become Exceptional--cis115.com
 
Programada chapter 4
Programada chapter 4Programada chapter 4
Programada chapter 4
 
2014 computer science_question_paper
2014 computer science_question_paper2014 computer science_question_paper
2014 computer science_question_paper
 
Lab-11-C-Problems.pptx
Lab-11-C-Problems.pptxLab-11-C-Problems.pptx
Lab-11-C-Problems.pptx
 
Cis 115 Extraordinary Success/newtonhelp.com
Cis 115 Extraordinary Success/newtonhelp.com  Cis 115 Extraordinary Success/newtonhelp.com
Cis 115 Extraordinary Success/newtonhelp.com
 
CIS 115 Achievement Education--cis115.com
CIS 115 Achievement Education--cis115.comCIS 115 Achievement Education--cis115.com
CIS 115 Achievement Education--cis115.com
 
#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx#include iostream#includectimeusing namespace std;void.docx
#include iostream#includectimeusing namespace std;void.docx
 
CIS 115 Education for Service--cis115.com
CIS 115 Education for Service--cis115.com  CIS 115 Education for Service--cis115.com
CIS 115 Education for Service--cis115.com
 
CIS 115 Redefined Education--cis115.com
CIS 115 Redefined Education--cis115.comCIS 115 Redefined Education--cis115.com
CIS 115 Redefined Education--cis115.com
 
CIS 115 Education Counseling--cis115.com
CIS 115 Education Counseling--cis115.comCIS 115 Education Counseling--cis115.com
CIS 115 Education Counseling--cis115.com
 
CIS 115 Education in iCounseling ---cis115.com
CIS 115 Education in  iCounseling ---cis115.comCIS 115 Education in  iCounseling ---cis115.com
CIS 115 Education in iCounseling ---cis115.com
 
Production Theory
Production TheoryProduction Theory
Production Theory
 
Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++Aplikasi menghitung matematika dengan c++
Aplikasi menghitung matematika dengan c++
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo JobyC++ and OOPS Crash Course by ACM DBIT | Grejo Joby
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
 
C#.net
C#.netC#.net
C#.net
 
Go vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoFGo vs C++ - CppRussia 2019 Piter BoF
Go vs C++ - CppRussia 2019 Piter BoF
 
CIS 115 Education Specialist / snaptutorial.com
CIS 115  Education Specialist / snaptutorial.comCIS 115  Education Specialist / snaptutorial.com
CIS 115 Education Specialist / snaptutorial.com
 
Exercises
ExercisesExercises
Exercises
 

Más de mrichard5

A process or task in Linux is represented by a Answer data structure-S.docx
A process or task in Linux is represented by a Answer data structure-S.docxA process or task in Linux is represented by a Answer data structure-S.docx
A process or task in Linux is represented by a Answer data structure-S.docx
mrichard5
 
Crystal clear water sports has 14-000 shares of $1 par value common st.docx
Crystal clear water sports has 14-000 shares of $1 par value common st.docxCrystal clear water sports has 14-000 shares of $1 par value common st.docx
Crystal clear water sports has 14-000 shares of $1 par value common st.docx
mrichard5
 
Critical thinking question- what structural features (hint- there are.docx
Critical thinking question- what structural features (hint- there are.docxCritical thinking question- what structural features (hint- there are.docx
Critical thinking question- what structural features (hint- there are.docx
mrichard5
 
Create an array of size 10 Assign values to the array Print the arra.docx
Create an array of size 10  Assign values to the array  Print the arra.docxCreate an array of size 10  Assign values to the array  Print the arra.docx
Create an array of size 10 Assign values to the array Print the arra.docx
mrichard5
 
Create a text file that contains ten person objects where each object.docx
Create a text file that contains ten person objects where each object.docxCreate a text file that contains ten person objects where each object.docx
Create a text file that contains ten person objects where each object.docx
mrichard5
 
Create a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docxCreate a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docx
mrichard5
 
Could someone help me with this Linux system program- Using C language.docx
Could someone help me with this Linux system program- Using C language.docxCould someone help me with this Linux system program- Using C language.docx
Could someone help me with this Linux system program- Using C language.docx
mrichard5
 

Más de mrichard5 (19)

A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docx
A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docxA rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docx
A rigid- well-insulated gas cylinder contains N0 moles of an ideal gas.docx
 
A soil is shaken with water and then allowed to stand- After standing-.docx
A soil is shaken with water and then allowed to stand- After standing-.docxA soil is shaken with water and then allowed to stand- After standing-.docx
A soil is shaken with water and then allowed to stand- After standing-.docx
 
a societal right- None of the above- a group right- Both A and B- an i.docx
a societal right- None of the above- a group right- Both A and B- an i.docxa societal right- None of the above- a group right- Both A and B- an i.docx
a societal right- None of the above- a group right- Both A and B- an i.docx
 
A simple camera telephoto lens consists of two How far behind the conc.docx
A simple camera telephoto lens consists of two How far behind the conc.docxA simple camera telephoto lens consists of two How far behind the conc.docx
A simple camera telephoto lens consists of two How far behind the conc.docx
 
A priniciple purpose of a representation letter from management is to-.docx
A priniciple purpose of a representation letter from management is to-.docxA priniciple purpose of a representation letter from management is to-.docx
A priniciple purpose of a representation letter from management is to-.docx
 
A process or task in Linux is represented by a Answer data structure-S.docx
A process or task in Linux is represented by a Answer data structure-S.docxA process or task in Linux is represented by a Answer data structure-S.docx
A process or task in Linux is represented by a Answer data structure-S.docx
 
Crystal clear water sports has 14-000 shares of $1 par value common st.docx
Crystal clear water sports has 14-000 shares of $1 par value common st.docxCrystal clear water sports has 14-000 shares of $1 par value common st.docx
Crystal clear water sports has 14-000 shares of $1 par value common st.docx
 
Critical thinking question- what structural features (hint- there are.docx
Critical thinking question- what structural features (hint- there are.docxCritical thinking question- what structural features (hint- there are.docx
Critical thinking question- what structural features (hint- there are.docx
 
Create an array of size 10 Assign values to the array Print the arra.docx
Create an array of size 10  Assign values to the array  Print the arra.docxCreate an array of size 10  Assign values to the array  Print the arra.docx
Create an array of size 10 Assign values to the array Print the arra.docx
 
Create a text file that contains ten person objects where each object.docx
Create a text file that contains ten person objects where each object.docxCreate a text file that contains ten person objects where each object.docx
Create a text file that contains ten person objects where each object.docx
 
Create a polynomial function that meets the following conditions- Expl.docx
Create a polynomial function that meets the following conditions- Expl.docxCreate a polynomial function that meets the following conditions- Expl.docx
Create a polynomial function that meets the following conditions- Expl.docx
 
Create a method assuming we have a listed list- use linear search in j.docx
Create a method assuming we have a listed list- use linear search in j.docxCreate a method assuming we have a listed list- use linear search in j.docx
Create a method assuming we have a listed list- use linear search in j.docx
 
Create a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docxCreate a JAVA Program that traverses through an array recursively- rat.docx
Create a JAVA Program that traverses through an array recursively- rat.docx
 
Create a Java Applet that uses two integer (int) variables x and y to.docx
Create a Java Applet that uses two integer (int) variables x and y to.docxCreate a Java Applet that uses two integer (int) variables x and y to.docx
Create a Java Applet that uses two integer (int) variables x and y to.docx
 
Create a function called findChar that will return the index of where.docx
Create a function called findChar that will return the index of where.docxCreate a function called findChar that will return the index of where.docx
Create a function called findChar that will return the index of where.docx
 
Could someone help me with this Linux system program- Using C language.docx
Could someone help me with this Linux system program- Using C language.docxCould someone help me with this Linux system program- Using C language.docx
Could someone help me with this Linux system program- Using C language.docx
 
Contrast the argument that terrorist acts are easy to predict with the.docx
Contrast the argument that terrorist acts are easy to predict with the.docxContrast the argument that terrorist acts are easy to predict with the.docx
Contrast the argument that terrorist acts are easy to predict with the.docx
 
contemporary financial management What are the differences between the.docx
contemporary financial management What are the differences between the.docxcontemporary financial management What are the differences between the.docx
contemporary financial management What are the differences between the.docx
 
Constants Part A By measurement you determine that sound waves are spr.docx
Constants Part A By measurement you determine that sound waves are spr.docxConstants Part A By measurement you determine that sound waves are spr.docx
Constants Part A By measurement you determine that sound waves are spr.docx
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

A software company sells a package that retails for $99- Quantity disc.docx

  • 1. 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 c++ program that asks for the number of units purchased and computes the total cost of the purchase. Solution #include <iostream> using namespace std; int main () { int units; float totalCost; cout << "Please enter the number of units purchased : "; cin >> units; if((units >= 10) && (units <= 19)){ totalCost = (99 * units) - ((99 * units * 20)/100); cout<<"Total Cost : " << totalCost; } else if((units >= 20) && (units <= 49)){ totalCost = (99 * units) - ((99 * units * 30)/100); cout<<"Total Cost : " << totalCost;
  • 2. } else if((units >= 50) && (units <= 99)){ totalCost = (99 * units) - ((99 * units * 40)/100); cout<<"Total Cost : " << totalCost; } else if(units >= 100){ totalCost = (99 * units) - ((99 * units * 50)/100); cout<<"Total Cost : " << totalCost; } else{ totalCost = 99 * units; cout<<"Total Cost : " << totalCost; } return 0; }