question archive Provide flowchart and pseudo code for both problems to do the following:- You are going to modify week 4 assignment (2 problems) to use input() function (no hard coded values) to prompt the user to enter the values

Provide flowchart and pseudo code for both problems to do the following:- You are going to modify week 4 assignment (2 problems) to use input() function (no hard coded values) to prompt the user to enter the values

Subject:Computer SciencePrice:3.87 Bought7

Provide flowchart and pseudo code for both problems to do the following:-

You are going to modify week 4 assignment (2 problems) to use input() function (no hard coded values) to prompt the user to enter the values.

Make sure the prompt message is meaningful, do not say "Enter value", say something like this "Enter hours worked" after you get all the inputs, display the results and prompt the user if wants more calculation (y/n). If no then print a message like "Thank you for ......." 

The flowchart must include a loop and if-then

week 4 assignment:

Problem 1: Provide Python program to solve a simple payroll calculation. Calculate the amount of pay, given hours worked, and hourly rate. (The formula to calculate payroll is pay = hourly rate * hours worked.) Display hourly rate, hours worked, and pay.

Problem 2: Provide Python program to calculate the average miles per gallon obtained on a trip. Input the amount of gas used and the number of miles driven. (The formula to calculate miles per gallon is miles per gallon = number of miles driven / amount of gas used. ) Display gas used, miles driven and MPG.  Use  your own values to test the. You can hard code the values or you can use the input() function.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Answer:

#problem 1

#Pseudocode

#step 1:- call main function 

#step 2:- main function call payroll

#step 3:- payroll input hours and hourly rate and print payroll

#step 4:- program ask for more calculation 

# if input == 'y' then repeat step 2 to 4 

# else exit program

def payroll():

  hour = int(input('Enter number of hours worked: '))

  rate = int(input('Enter the rate of per hour: '))

  print('Payroll: ${:d}'.format(hour*rate))

def main():

  cal = 'Y'

  payroll()

  cal = input('Do you want more calculations?y/n: ')

  if(cal == 'y' or cal =='Y'):

    main()

  else:

    return

if __name__ == "__main__":

  print('PAYROLL CALCULATION')

  main()

 

------------------------------------------------------------------------------------------------------

#problem 2

#Pseudocode

#step 1:- call main function 

#step 2:- main function call milePerGallon

#step 3:- milePerGallon input hours and hourly rate and print MPG

#step 4:- program ask for more calculation 

# if input == 'y' then repeat step 2 to 4 

# else exit program

 

def milePerGallon():

  gas = int(input('Enter amount of gas used: '))

  miles = int(input('Enter the number of miles driven: '))

  MPG = miles/gas

  print('Gas used mile per gallon: {:.2f}'.format(MPG))

 

def main():

  cal = 'Y'

  milePerGallon()

  cal = input('Do you want more calculations?y/n: ')

  if(cal == 'y' or cal =='Y'):

    main()

  else:

    return

   

   

if __name__ == "__main__":

  print('Mile per Gallon')

  main()

PFA