Case Study 1: The following fragment of code in Figure 1 show the function to calculating the total price of soft drink orders. The soft drink is sold in boxes of 12 bottles and there are available in three flavour: falvour A (RM60), B(RM80) and C(RM100). int calcPrice (int qttyA, int qttyB, int qttyC, double price){ int discount = 0; if(qttyA== 2) discount = 5; else if (qttyA== 1 && qttyB == 1) discount = 8; else if (qttyC == 3) else endif price = ((qttyA*60) + (qttyB 80) + (qttyC* 100))* (100-discount)/100; return price; discount = 10; discount = 2; Figure 1: Fragment of total purchase code.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter11: Introduction To Classes
Section11.4: A Case Study: Constructing A Date Class
Problem 9E
icon
Related questions
Question
Case Study 1:
The following fragment of code in Figure 1 show the function to calculating the total price of
soft drink orders. The soft drink is sold in boxes of 12 bottles and there are available in three
flavour: falvour A (RM60), B(RM80) and C(RM100).
int calcPrice (int qttyA, int qttyB, int qttyC, double price){
int discount = 0;
}
if (qttyA== 2)
discount = 5;
else if (qttyA== 1 && qttyB == 1)
discount = 8;
else if (qttyC == 3)
else
discount = 10;
discount = 2;
endif
price = ((qttyA * 60) + (qttyB * 80) + (qttyC* 100))* (100-discount)/100;
return price;
Figure 1: Fragment of total purchase code.
Transcribed Image Text:Case Study 1: The following fragment of code in Figure 1 show the function to calculating the total price of soft drink orders. The soft drink is sold in boxes of 12 bottles and there are available in three flavour: falvour A (RM60), B(RM80) and C(RM100). int calcPrice (int qttyA, int qttyB, int qttyC, double price){ int discount = 0; } if (qttyA== 2) discount = 5; else if (qttyA== 1 && qttyB == 1) discount = 8; else if (qttyC == 3) else discount = 10; discount = 2; endif price = ((qttyA * 60) + (qttyB * 80) + (qttyC* 100))* (100-discount)/100; return price; Figure 1: Fragment of total purchase code.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning