SlideShare ist ein Scribd-Unternehmen logo
1 von 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;
}

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

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
 
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
 
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
 

Kürzlich hochgeladen (20)

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
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
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
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
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
 
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...
 
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
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
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
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
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
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
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Ữ Â...
 
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
 

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; }