C++ Final Exam
C++ Final Exam
# 1 Based on the engineering problem-solving methodology, write down the detailed 5 steps
that are applied for developing a C++ program to calculate salesperson’s earnings: A large
company pays its salesperson on a commission basis. The list of the items sold by
salespersons is
Item Value
1 10
2 20
3 30
The salesperson receive $200 per week plus 9% of their gross sales for that week. For
example, if a salesperson sells 100 item 1 and 200 item 3 in a week, he receives
$200 + 9% × (100 × $10 + 200 × $30) = $830
There is no limit to the number of items that can be sold. The salespersons weekly sales data
may look like: 100 item 1 and 200 item 3 on Monday, 50 item 2 on Tuesday, 100 item 1 and
200 item 2 on Wednesday, and so on. Use structured input loop to enter the salespersons
weekly sale. Use switch statement to determine the value for the corresponding item. Use
either pseudo-code or flow chart to describe your algorithm. 25
# 2 Write a complete C++ program for question 1 (Include comments in your program) 25
#3 Develop a module chart and use the engineering problem-solving methodology to write
down the detailed 5 steps for the following C++ program: first, develop a function that
displays at the left margin of the screen a solid square. The square is formed of whatever
character entered by the user. The size of the square is also entered by the user. For example,
if the user entered ‘%’ as the character and ‘3’ as the size. The function should print the
following
%%%
%%%
%%%
This function is then called by the main function which reads the character and size from the
user. Use either pseudo-code or flow chart to describe your algorithm. 30
# 4 Write a complete C++ program for question 3 (Include comments in your program) 20
# 5 (Not required, bonus credit) Fill in the blanks in each of the following 10
a) Every C++ program begins execution at the function .
b) All programs can be written in terms of three types of control structures: , , and .
c) A(n) allows the compiler to check the number, types and order of the
arguments passed to a function