Question

Write the pseudocode below as a working Python program. Take a screenshot of your code and...

  1. Write the pseudocode below as a working Python program. Take a screenshot of your code and output and paste into your answer document. User input of ‘y’ or ‘Y’ should cause the loop to continue.

   // Constant for the commission rate

   // Declare as a global variable

   Constant Real COMMISSION_RATE = 0.10

    Module main()

       // Local variable

        Declare String keepGoing = "y"

        // Calculate as many commissions

        // as needed.

        While keepGoing == "y"

           // Display a salesperson's commission.

           Call showCommission()

           // Do it again?

           Display "Do you want to calculate another"

           Display "commission? (Enter y for yes.)"

           Input keepGoing

        End While

    End Module

    // The showCommission module gets the

    // amount of sales and displays the

    // commission.

    Module showCommission()

        // Local variables

        Declare Real sales, commission

        // Get the amount of sales.

        Display "Enter the amount of sales."

        Input sales

        // Calculate the commission.

        Set commission = sales * COMMISSION_RATE

        // Display the commission

        Display "The commission is $", commission

    End Module

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here I am sending code, screens of code and output. Refer the screens for better visualize. If any queries comment below. Thank you.

Code:

COMMISSION_RATE = 0.10#gobal variable

def showCommission():#showCommission module
sales = int(input("Enter the amount of sales.: ")) #reading the amount of sales.
comission = sales * COMMISSION_RATE #calculating commission.
print("The commission is $",comission) #printing the commission.

keepGoing = "y" #local variable.
while keepGoing == "y" or keepGoing == "Y": #checking the condition is input is y or not.
showCommission() #calling the showCommission.
print("\nDo you want to calculate another.")
keepGoing = str(input("commission?(Enter y for yes): "))#asking the user for calculate another.

Add a comment
Know the answer?
Add Answer to:
Write the pseudocode below as a working Python program. Take a screenshot of your code and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON Programming Exercise 2: Create a Simple Cost Calculator Write a program that displays input fields...

    PYTHON Programming Exercise 2: Create a Simple Cost Calculator Write a program that displays input fields (item name and cost) and calculates and displays the calculated costs. The program should do the following: Provide data entry areas for item name and cost. Calculate and display the subtotal of all items. Adds a sales tax of 6% and calculate and displays the total cost. Enter the following values into your program. Mother Board $200. RAM $75. Hard Drive $72. Video Graphics...

  • Write the Flowchart for the following programming problem based on the pseudocode below. Last year, a...

    Write the Flowchart for the following programming problem based on the pseudocode below. Last year, a local college implemented rooftop gardens as a way to promote energy efficiency and save money. Write a program that will allow the user to enter the energy bills from January to December for the year prior to going green. Next, allow the user to enter the energy bills from January to December of the past year after going green. The program should calculate the...

  • Look at this partial class definition, and then answer questions a - b below: Class Book...

    Look at this partial class definition, and then answer questions a - b below: Class Book    Private String title    Private String author    Private String publisher    Private Integer copiesSold End Class Write a constructor for this class. The constructor should accept an argument for each of the fields. Write accessor and mutator methods for each field. Look at the following pseudocode class definitions: Class Plant    Public Module message()       Display "I'm a plant."    End Module...

  • Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that...

    Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...

  • When breaking a problem down, you often encounter elements that you want to use repeatedly in...

    When breaking a problem down, you often encounter elements that you want to use repeatedly in your code. Sometimes it's appropriate to write a new function; at other times it's appropriate to write a loop. What do you think? What kinds of circumstances would lead you to writing a function versus using a loop? What is the error in the pseudocode below? Re-write the pseudocode in your answer document. Declare Boolean finished = False Declare Integer value, cube While NOT...

  • I am supposed to a pseudocode function named max that accepts two integer values as arguments...

    I am supposed to a pseudocode function named max that accepts two integer values as arguments and returns the value that is greater of the two. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is greater of the two. Is everything correct and complete? //Pseudocode //This function takes two integers as parameters: x and y Begin : Max(x,y) If(x>y) then MAX=x Else MAX=y End if Return...

  • I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply t...

    I have this code and need this to be written and applied with an array? How do I process this? Also What would I apply this with flowchart? Module main()   Call getDailyProfit()   Call calculateWeeklyProfit() Call main() Module getDailyProfit()   // Declare all variables and establish the array          Constant Real SIZE = 7          Declare String days[SIZE] = Sunday, Monday, Tuesday, Thursday. Friday, Saturday          Declare Real days          Declare Real number          Declare Real Index             //Prompt the user for profit information for Sunday          Display “How...

  • Using python, write code for problem. Please also put screenshot of your code. The following program...

    Using python, write code for problem. Please also put screenshot of your code. The following program will perform properly if the user enters 0 in response to the request for input. However, the program will crash if the user responds with "eight". Rewrite the program using a try/except statement so that it will handle both types of responses. See Fig. 6.1. while True: n = int (input ("Enter a nonzero integer: ")) if n! = 0: reciprocal = 1/n print...

  • Write a Python program that does the following: Obtains the following input from a user: Mileage...

    Write a Python program that does the following: Obtains the following input from a user: Mileage at beginning of measurement period Mileage at end of measurement period Gallons of fuel consumed Calculates and displays: Miles driven Miles per gallon Kilometers driven Liters of fuel consumed Kilometers per liter Also incorporate some selection structure logic into it. If a vehicle gets less than 15 miles per gallon, display the message:       "Your vehicle has criminally low fuel efficiency." If it gets...

  • hello help me asap please kindly "Programming Challenge 1 -- Going Green," of Starting Out with...

    hello help me asap please kindly "Programming Challenge 1 -- Going Green," of Starting Out with Programming Logic and Design. Note: You are only required to create the flowchart for this activity; however, notice how the pseudocode compares to the given Python code for this assignment. Lab 9: Arrays This lab accompanies Chapter 8 of Gaddis, T. (2016). Starting out with programming logic and design (4th ed.). Boston, MA: Addison-Wesley. Lab 9.5 – Programming Challenge 1 -- Going Green Write...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT