In: Computer Science
For the following program descriptions, write step by step
pseudo code that shows you understand the problem and what it takes
to solve it. The first one is done for you as an
example. Please answer the questions in the same format as the
example problem below so it is the same.
Example #1 Problem
A customer is purchasing five items. Design a program where you
collect the amount of each item,
calculate the subTotal of the items, the tax at 7%, and a grand
total. The output will display the subTotal,
tax and grand total formatted with 2 decimal places and a $.
Answer
Declare variables: item1, item2, item2, item4, item5, subtotal,
tax, grandTotal
Declare constant TAX_RATE=0.07
Get the price for each item
Calculate the subtotal=item1 + item2 + item3 + item4 + item5
Calculate the tax = subtotal * TAX_RATE
Calculate the grandTotal=subtotal + tax
Display the subtotal
Display the sales tax
Display the grandTotal
Question
3. Design a program that calculates the total amount of a meal
purchased at a restaurant. The program
should ask the user to enter the charge for the food, then
calculate the amount of an 18% tip and 7%
sales tax and the total cost of the meal including the tax and
tip.
4. Design a program that asks the user for the number of males and
females registered in a class. The
program should display the percentage of males and females in the
class. You will need to calculate the
total number of students first to get the percentage of males and
females.
3.
Solution:
The pseudocode for the given problem is given below:
Declare variables: meal_amount, grandTotal
Declare constant = TIP_AMOUNT = 0.18, SALES_TAX = 0.07
Get the amount of meal purchased
Calculate the Sales_tax_amount = meal_amount * SALES_TAX
Calculate the Tip_amount = meal_amount * TIP_AMOUNT
Calculate the grandTotal = meal_amount + Tip_amount + Sales_tax_amount
Display the grandTotal
Explanation:
4.
Solution:
The pseudocode for the given problem is given below:
Declare variables: num_males, num_females
Get the number of male and female number of students.
Calculate total_students = num_males + num_females
Calculate the Male_percentage = (num_males/total_students) * 100
Calculate the female_percentage = (num_females/total_students) * 100
Display the Male_percentage
Display the female_percentage
Explanation: