Test II Sample 2
Test II Sample 2
CSC 103
TEST II
STUDENT NAME
STUDENT ID # 2 0 SECTION #
1 10
2 10
3 10
4 10
TOTAL 40
Page 1 of 6
Question 1 ( 10 marks )
Show the output of each code in the corresponding box to the right.
(4) int p, m;
for (p=1 ; p <= 3 ; p++)
{
for (m=9 ; m > 8 ; m--)
cout << "[" << m-p <<"]"<< endl;
}
Page 2 of 6
Question 2 ( 10 marks )
Write a C++ program to calculate and display the net price of pasta
based on two user inputs: Type (C for chicken, M for Meat, or V for
Vegetable) and the number of appetizers. The net price of pasta is
the sum of the following:
1. Base price of the pasta is 2.5 BD for chicken, 2.5 BD for Meat,
and 2.1 for Vegetable.
2. Each appetizer is an additional 1.2 BD.
SAMPLE INPUT/OUTPUT
Enter pasta type: C for Chicken, M for Meat, V for Vegetable
C
Enter number of appetizers:
2
Net price = 4.9
Page 3 of 6
Question 3 ( 10 marks )
A supply chain is performing end of the year store inventory. Write a C++ program that asks
the user to enter the Type (D for Deskjet, L for Laser) and price for 120 printers. The
program then displays how many Deskjet printers, how many Laser printers and how many
other printers.
Page 4 of 6
Question 4 ( 10 marks )
Assume that we have a file called savings.txt with unknown number of lines. Each line
contains the client name and his/her saving money in the bank. Below is a sample file.
Write a C++ program that reads all the lines from the file and prints on screen on separate
lines the client name and the saved money. The program should also display the total saving
money in the bank and the name of the customer who has the highest saving money.
Page 5 of 6
Page 6 of 6