Question

In: Computer Science

For the following program descriptions, write step by step pseudo code that shows you understand the...

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.

Solutions

Expert Solution

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:

  • First declare the variables to store the meal amount and the total amount after all the computations.
  • Define the constant variables to be used.
  • Prompt the user to enter the amount of meal.
  • Compute the amount after applying the sales tax.
  • Compute the amount after applying the tip percentage on meal amount.
  • Compute the grand total which is the summation of the entered meal amount and the percentage amount of sales and tip applied to it.
  • Display the grand total amount.

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:

  • Declare the variable that takes the number of male and female count.
  • Compute the total number of students which is the summation of number of males and females count.
  • Compute the percentage of male.
  • Compute the percentage of female.
  • Display the percentage of male student in the class.
  • Display the percentage of female student in the class.

Related Solutions

Write a pseudo code program for a goal-based agent. The goal of the agent is to...
Write a pseudo code program for a goal-based agent. The goal of the agent is to find the exit of a labyrinth. The agent is not omniscient The agent can sense if it is next to a wall (in front, left or right) The agent can turn 90 degrees to the right or left The agent can drive 1unit forward The maze is constructed of paths that are 1 unit across (wide) Show a maze of your choosing and illustrate...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x +...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x + y – z + A[j] x and y should be in reserved memory words using the .word directive and labeled as x and y. Initialize x=10 and y=200. Read in z from the console. Input the value -8. This is the value for z, not for –z. Store this value in memory with the label z. To begin, you could just initialize z to...
(Full Program)Write code that shows how deadlocks work. Then write code that shows a fix using...
(Full Program)Write code that shows how deadlocks work. Then write code that shows a fix using semaphores. (Full program)Write code showing the elevator algorithm. c++ Language
you are to write a program in Java, that reads in a set of descriptions of...
you are to write a program in Java, that reads in a set of descriptions of various geometric shapes, calculates the areas and circumferences of the shapes, and then prints out the list of shapes and their areas in sorted order from smallest to largest area. There are four possible shapes: Circle, Square, Rectangle, and Triangle. The last is always an equilateral triangle. The program should read from standard input and write to standard output. The program should read until...
Write the pseudo code for this problem based on what you learned from the video. The...
Write the pseudo code for this problem based on what you learned from the video. The purpose is to design a modular program that asks the user to enter the length and width, and then calculates the area. The formula is as follows: Area = Width x Length
Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
Write a pseudo code for an O (n7log3n) algorithm. Please write in C++.
What will be the expected output of the following pseudo code? Write exactly what would display...
What will be the expected output of the following pseudo code? Write exactly what would display when you execute the statements. Module main() Declare Integer a = 5 Declare Integer b = 2 Declare Integer c = 3 Declare Integer result = 0 Display "The value of result is" Display result Set result = a + b * c - a Display "Changed value is: ", result End Module
(Artificial Intelligence) Write a pseudo code for the following: Regular Hill Climbing with steepest ascent
(Artificial Intelligence) Write a pseudo code for the following: Regular Hill Climbing with steepest ascent
Let's say we have the following lines of pseudo-code in a program. What type of malware...
Let's say we have the following lines of pseudo-code in a program. What type of malware is in this code? username = get_username(); password = get_password(); if username is "l33t h4ck0r": return PERMIT_ENTRY if username and password are valid: return PERMIT_ENTRY else return DENY_ENTRY rootkit spyware trojan horse backdoor
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write...
1. Write an algorithm to calculate the Matrix multiplication (or write with pseudo code) 2. Write an algorithm to calculate the recursive Matrix multiplication (or write with pseudo code) 3. Find the time complexity of your pseudo code and analyze the differences
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT