Question

Phase 1 Requirements

Code submitted for Phase 1 will only have the following capability. Any additional coding will result in the loss of point.

  • code will have the main function, including looping until the user enters input of 12

  • code will call the printMenu() function

  • theprintMenu() function will have the capability to print the menu and receive input. AT THIS TIME do not worry about implementing the try/except code

  • code will return the integer value (remember - the input() function returns a string) entered by the user to the main function.

  • code will have a simple print statement outputting the statement "The user input the value ??" - where the ?? will be replaced by the value the user entered.

  • Select from the following options: 1) Category 2) Item 3) Serving Size 4) Calories 5) Calories from Fat 6) Total Fat 7) Chole

  • Phase 2 Requirements

  • code will meet all requirements from Phase 1

  • code in the printMenu() function will be added to include a try/except to catch errors if the user enters a non-numeric value in response to the menu prompt.

  • code will have the main function calling the processInput() function that accepts a single argument

  • the argument to the function will be the value returned from the printMenu() function

  • use a different variable name in your main code and in your function

  • create a list named headings[]

  • the headings list should contain all the Headings from the menu except 'Quit'...so you have all 11 elements in the list from your menu.

  • using the value that is passed into the processInput() function print not only the numerical value of that argument - but also print the proper item from the headings[] list.

  • Phase 3 Requirements

  • code will meet all requirements from Phase 2

  • code to read the input file will be added to the main function

  • the processInput() function will sort the data read from the file

  • the processInput() function will print out the top 5 items based on the input value

I need help with these 3 phases. If possible separate them. If I wanted to use only phase 1 in my python program, it will work. If I wanted to use both phase 1 and 2 it'll still work. I need to turn in phase 1 first then a few days, phase 2 with the new code and phase 1 code and then finally phase 3 with the all phases combined.

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

I have given the code for Phase 1 and Phase 2. For Phase 3, input file contents needed.
PLEASE MAKE SURE INDENTATION IS EXACTLY AS SHOWN IN IMAGE.
Please do rate the answer if it helped. Thank you.


Code for Phase 1
=================

def printMenu():
   print('Select from the following options:')
   print('\t 1) Category')
   print('\t 2) Item')
   print('\t 3) Serving Size')
   print('\t 4) Calories')
   print('\t 5) Calories from Fat')
   print('\t 6) Total Fat')
   print('\t 7) Cholestrol')
   print('\t 8) Sodium')
   print('\t 9) Carbohydrates')
   print('\t 10) Protein')
   print('\t 11) Sugars')
   print('\t 12) Quit')
   num = int(input('Enter Number Command: '))
   return num

def main():
   choice = 0
   while choice != 12:
       choice = printMenu()
       print('The user input the value', choice)
       print()
  

if __name__ == "__main__":
   main()

1 2 4 5 6 7 8 def printMenu(): print(select from the following options:) print(\t.l). Category) print(\t. 2). Item) pri
  
  
Code for Phase 2
=================

def printMenu():
   print('Select from the following options:')
   print('\t 1) Category')
   print('\t 2) Item')
   print('\t 3) Serving Size')
   print('\t 4) Calories')
   print('\t 5) Calories from Fat')
   print('\t 6) Total Fat')
   print('\t 7) Cholestrol')
   print('\t 8) Sodium')
   print('\t 9) Carbohydrates')
   print('\t 10) Protein')
   print('\t 11) Sugars')
   print('\t 12) Quit')
  
   num = None
   while num == None or num < 1 or num > 12:
       try:
           num = int(input('Enter Number Command (1-12): '))
       except:
           print('Please provide a valid integer in the range 1-12')
          
   return num


def processInput(menuChoice):
   headings = ['Category', 'Item', 'Serving Size', 'Calories', 'Calories from Fat', 'Total Fat', 'Cholestrol', 'Sodium', 'Carbohydrates', 'Protein', 'Sugars']
   print('Menu chosen is {}) {}'.format(menuChoice, headings[menuChoice-1]))

def main():
   choice = 0
   while choice != 12:
       choice = printMenu()
       if choice != 12:
           processInput(choice)
       print()
  

if __name__ == "__main__":
   main()

1 2 3 4 5 6 7 def printMenu(): print(select from the following options:) print(\t.l). Category) print(\t.2). Item) prin

Add a comment
Know the answer?
Add Answer to:
Phase 1 Requirements Code submitted for Phase 1 will only have the following capability. Any additional...
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
  • STAGE 1 In Stage #2 here are the requirements: • Keep the following requirements from Stage...

    STAGE 1 In Stage #2 here are the requirements: • Keep the following requirements from Stage #1 o Write code that calls a function named printMenu() • The printMenu() function will: • print the menu below . ask the user to input a value between 1 an 12 · return an integer value to your main program. • Within the printMenu() function: o I STRONGLY SUGGEST THAT YOU DO THESE ONE AT A TIME - get the loop working before...

  • can anyone show me how this code would look in python, I'm studying python while taking...

    can anyone show me how this code would look in python, I'm studying python while taking some classes. I can't seem to understand what this is asking for. • Phase 1 Requirements Code submitted for Phase 1 will only have the following capability. Any additional coding will result in the loss of point. • code will have the main function, including looping until the user enters input of 12 • code will call the printMenu() function • The printMenu() function...

  • in Python: Write a program that allows the user to enter a number between 1-5 and...

    in Python: Write a program that allows the user to enter a number between 1-5 and returns an animal fact based on what the user entered. The program should 1. Continue to run until the user enters “quit” to terminate the program, and 2. Validate the user’s input (the only acceptable input is 1, 2, 3, 4, 5 or “quit”). You can use the following animal facts: An octopus is a highly intelligent invertebrate and a master of disguise. Elephants...

  • Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================")...

    Need help writing this code in python. This what I have so far. def display_menu(): print("======================================================================") print(" Baseball Team Manager") print("MENU OPTIONS") print("1 - Calculate batting average") print("2 - Exit program") print("=====================================================================")    def convert_bat(): option = int(input("Menu option: ")) while option!=2: if option ==1: print("Calculate batting average...") num_at_bats = int(input("Enter official number of at bats: ")) num_hits = int(input("Enter number of hits: ")) average = num_hits/num_at_bats print("batting average: ", average) elif option !=1 and option !=2: print("Not a valid...

  • C++ (1) Prompt the user to enter a string of their choosing (Hint: you will need...

    C++ (1) Prompt the user to enter a string of their choosing (Hint: you will need to call the getline() function to read a string consisting of white spaces.) Store the text in a string. Output the string. (1 pt) Ex: Enter a sample text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!...

  • 40pts) Given the following code segment. mSwer= input("Enter age: ") ile answer != 'q' : try:...

    40pts) Given the following code segment. mSwer= input("Enter age: ") ile answer != 'q' : try: print(int(answer) ) answer input ( " Enter age: ") except Value E rror : print ("Invalid answer 'q' age") Show what is printed if the user enters the following values at the prompt, one at a time. Print output User input 20 17 2a => 29 q 9. The following main function works with a class called Student that you will write. def main()...

  • C++ please! (1) Prompt the user to enter the name of the input file. The file...

    C++ please! (1) Prompt the user to enter the name of the input file. The file will contain a text on a single line. Store the text in a string. Output the string. Ex: Enter file name: input1.txt File content: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue! (2) Implement a PrintMenu() function,...

  • Create a program to help some local coffee shops manage their menus Requirements The class contai...

    program is C# Create a program to help some local coffee shops manage their menus Requirements The class contains: 1) A method called defaultMenu that returns a String list and has no parameters. When called, the method returns a string list containing the following elements: {"Coffee", "Americano", Cappuccino" A method called custom Menu that returns a String list and has an int parameter. When called, the method will create a new string list, then ask the user for items to...

  • This is done in c programming and i have the code for the programs that it wants at the bottom i ...

    This is done in c programming and i have the code for the programs that it wants at the bottom i jut dont know how to call the functions Program 2:Tip,Tax,Total int main(void) {    // Constant and Variable Declarations    double costTotal= 0;    double taxTotal = 0;    double totalBill = 0;    double tipPercent = 0;    // *** Your program goes here ***    printf("Enter amount of the bill: $");    scanf("%lf", &costTotal);    printf("\n");    // *** processing ***    taxTotal = 0.07 * costTotal;    totalBill...

  • CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c...

    CSC 130 Lab Assignment 8 – Program Menu Create a C source code file named lab8.c that implements the following features. Implement this program in stages using stepwise refinement to ensure that it will compile and run as you go. This makes it much easier to debug and understand. This program presents the user a menu of operations that it can perform. The choices are listed and a prompt waits for the user to select a choice by entering a...

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