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 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...
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
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
Write the class declarations for the following objects' descriptions. NO CODE. That means only properties and...
Write the class declarations for the following objects' descriptions. NO CODE. That means only properties and method declarations. Like... class Lamp { int mBulbs; void Explode(); }; 1) A Laptop has a color, brand, and processor speed. You can open, close, turn on, and turn off a laptop. 2) A monitor has a screen size and a brightness. 3) Oh wait, a laptop has a monitor itself. To do this, would you add a line to answer #1 or answer...
A customer in a grocery store is purchasing three items. Write the pseudo code that will:...
A customer in a grocery store is purchasing three items. Write the pseudo code that will: • Ask the user to enter the name of the first item purchased. Then ask the user to enter the cost of the first item purchased. Make your program user friendly. If the user says the first item purchased is milk, then ask: “What is the cost of milk.” [This should work no matter what item is entered by the user. I might buy...
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line...
Write pseudo-code to solve the following problem using MapReduce and explain how it works. Each line in the file lists a user ID, the ID of the movie the user watched, the rating the user gave for the movie, and the timestamp. For example line 1 indicates that the user’s ID is 196, the movie ID is 242, the user gave this movie a rating of 3, and the timestamp is 881250949. Given the file, find out the top similar...
1. Write pseudocode for the following program. You do not have to write actual C++ code....
1. Write pseudocode for the following program. You do not have to write actual C++ code. Assume you have a text file, that has been encrypted by adding 10 to the ASCII value of each character in the message. Design a decryption program that would reverse this process, and display the original message to the console.to the new array. 2.Write the code for the specified program. Use proper style and naming. Test and upload your code as a CPP file....
Write a recursive algorithm in pseudo-code to compute the “power list” of a given list of...
Write a recursive algorithm in pseudo-code to compute the “power list” of a given list of integers. Assume that the List type has members: int List.length returns the length of the list. void List.push(T n) pushes an element n to the front of the list T List.pop() pops an element from the front of the list. List$$ List$$.concat(List$$ other) returns the concatenation of this list with other. Explain in plain English the reasoning behind your algorithm. Power Lists should be...
Write a Pseudo Code to send an Array of 20 elements from 8051 to the computer...
Write a Pseudo Code to send an Array of 20 elements from 8051 to the computer via serial port at maximum baud rate possible with XTAL=11.0592MHz.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT