Question

In: Computer Science

For Homework 4, we are going to present the user with a series of menus, accept...

For Homework 4, we are going to present the user with a series of menus, accept as input the action they wish to take, and act appropriately. You must practice basic input validation to ensure that the menu option they chose is valid.

  1. Create “CPS132 Homework 4” project in Eclipse
  2. Create “Homework4.py” file
  3. Download "Homework4_incomplete.py"
  4. Paste the text into "Homeworkpy"
  5. Make sure to fill in the appropriate information in the header including your name, username, due date, Homework #4, and the Bug Report
  6. Use the comments and hints to complete the assignment
  7. Sample input and output on Windows 10
    1. This is homework 4 incomplete
      1. #*****************************************************************************
        # Name:
        # User name:
        # Homework No: 4
        # Date Due:    3/26/2019
        #
        # Description:
        #   A brief but complete description of what the program does
        #
        # Bug Report:
        #   A description of the known bugs in the program you could not fix.
        #   If you did not implement specific functionality, that should be reported
        #   in this section as well
        #*****************************************************************************
        import platform
        import webbrowser
        
        def mainMenu():
            # output main menu to user
            print("\n")
            
            
            # get input from user
            
        
            # take appropriate action based on the user input
            # Hint: call openWebsite() or getComputerInfo() when appropriate
            
        
        def openWebsite():
            # output web sites menu to user
            print("\n")
            
        
            # get input from user
            
        
            # take appropriate action based on the user input
            # Look at https://docs.python.org/2/library/webbrowser.html
            # We want to open the appropriate web page in a new browser tab
            # Hint: use webbrowser.open_new_tab(url)
            
            # The URLs are the following:
            # UD: http://www.udayton.edu
            # BCM: http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/chemistry/#BCM
            # CHM: http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/chemistry/
            # CME: http://catalog.udayton.edu/undergraduate/schoolofengineering/programsofstudy/chemicalandmaterialsengineering/#MAJOR
            # EAS: http://catalog.udayton.edu/allcourses/edt/
            # ECT: http://catalog.udayton.edu/allcourses/ect/
            # ERL: https://udayton.edu/education/departments_and_programs/edt/programs/undergraduate/erl/index.php
            # EYA: https://udayton.edu/education/departments_and_programs/edt/programs/undergraduate/eya/index.php
            # GEO: http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/geology/#GEO
            # MCT: http://catalog.udayton.edu/allcourses/mct/
            # MEE: http://catalog.udayton.edu/allcourses/mee/
            # MTH: http://catalog.udayton.edu/allcourses/mth/
            # PHY: http://catalog.udayton.edu/allcourses/phy/
        
            
        def getComputerInfo():
            # output computer info menu to user
            print("\n")
            
        
            # get input from user
            
        
            # take appropriate action based on the user input
            # Look at https://docs.python.org/2/library/platform.html for the list of functions which perform the necessary actions
            # Use the appropriate functions in the section "15.15.1. Cross Platform"
        
        # call the mainMenu() function
        mainMenu()

Solutions

Expert Solution

############### PGM START ############################################

# -*- coding: utf-8 -*-
#*****************************************************************************
# Name:
# User name:
# Homework No: 4
# Date Due:    3/26/2019
#
# Description:
#   A brief but complete description of what the program does
#
# Bug Report:
#   A description of the known bugs in the program you could not fix.
#   If you did not implement specific functionality, that should be reported
#   in this section as well
#*****************************************************************************
import platform
import webbrowser

def mainMenu():
    flag=True
    while(flag):
        choice=int(input("__MAIN MENU___\n1. Open Website\n2. Computer Info\n3. Exit\nEnter your choice: "))
        if choice==1:
            openWebsite()
        elif choice==2:
            getComputerInfo()
        elif choice==3:
            flag=False
            print("\nExiting....\n")
        else:
            print("\nInvalid choice!!!!!!!!!\n")

  

def openWebsite():
    # output web sites menu to user
    print("\n")
  

    # get input from user
  

    # take appropriate action based on the user input
    # Look at https://docs.python.org/2/library/webbrowser.html
    # We want to open the appropriate web page in a new browser tab
    # Hint: use webbrowser.open_new_tab(url)
    print("\n___Website Menu____\n1. UD\n2. BCM\n3. CHM\n4. CME\n5. EAS\n6. ECT\n7. ERL\n")
    print("8. EYA\n9. GEO\n10. MCT\n11. MEE\n12. MTH\n13. PHY\n")
    choice=int(input("Enter the choice: "))
    if choice==1:
        webbrowser.open_new_tab("http://www.udayton.edu")
    elif choice==2:
        webbrowser.open_new_tab("http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/chemistry/#BCM")
    elif choice==3:
        webbrowser.open_new_tab("http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/chemistry/")
    elif choice==4:
        webbrowser.open_new_tab("http://catalog.udayton.edu/undergraduate/schoolofengineering/programsofstudy/chemicalandmaterialsengineering/#MAJOR")
    elif choice==5:
        webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/edt/")
    elif choice==6:
        webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/ect/")
    elif choice==7:
        webbrowser.open_new_tab("https://udayton.edu/education/departments_and_programs/edt/programs/undergraduate/erl/index.php")
    elif choice==8:
        webbrowser.open_new_tab("https://udayton.edu/education/departments_and_programs/edt/programs/undergraduate/eya/index.php")
    elif choice==9:
        webbrowser.open_new_tab("http://catalog.udayton.edu/undergraduate/collegeofartsandsciences/programsofstudy/geology/#GEO")
    elif choice==10:
        webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/mct/")
    elif choice==11:
        webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/mee/")
    elif choice==12:
        webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/mth/")
    elif choice==13:
        webbrowser.open_new_tab("http://catalog.udayton.edu/allcourses/phy/")
    else:
        print("\nInvalid choice!!!!!\n")

  
def getComputerInfo():
    print("\n___Computer Info Menu___\n")
    print("1. Machine\n2. Processor\n3. Node\n4. System\n")
    choice=int(input("Enter your choice: "))
    if choice==1:
        print("Machine Type: "+str(platform.machine())+"\n")
    elif choice==2:
        print("Processor: "+str(platform.processor())+"\n")
    elif choice==3:
        print("Network Name: "+str(platform.processor())+"\n")
    elif choice==4:
        print("System Type: "+str(platform.system())+"\n")
    else:
        print("\nInvalid Choice!!!!!!\n")

# call the mainMenu() function
mainMenu()

##################### PGM END #############################################

OUTPUT
#########


Related Solutions

Excel Homework: We are going to start working on sample statistics—that is, on measures we can...
Excel Homework: We are going to start working on sample statistics—that is, on measures we can sue to describe a sample. The two that we will learn about today are histograms, and 5 number summaries (which can be represented using box-plots). 1. You are designing a game, and considering having players roll a six-sided die and a 20-sided die, and add the values of each die. To get a picture of what happens when someone rolls dice like that, you...
For this homework we are going to walk you through creating a class. Lets look at...
For this homework we are going to walk you through creating a class. Lets look at a pizza restaurant and create a class for this. We will call our class pizza. The goal for every class is to include everything that has to happen for that class in 1 place. So whenever we create a class we need to think of what the nouns or variables will be for that class and then what the actions or methods will be...
Creating a list/tuple 4. Write a program to accept a string from the user, then replace...
Creating a list/tuple 4. Write a program to accept a string from the user, then replace the first letter with the last letter, the last letter with the middle letter and the middle letter with the first letter. E.g. “Billy” -> “yiBll”.
This is to be done using MIPS assembly language. Display the following menus, ask user to...
This is to be done using MIPS assembly language. Display the following menus, ask user to select one item. If 1-3 is selected, display message “item x is selected”, (x is the number of a menu item), display menus again; if 0 is selected, quit from the program. 1. Menu item 1 2. Menu item 2 3. Menu item 3 0. Quit Please select from above menu (1-3) to execute one function. Select 0 to quit
We are going to develop a guessing game where the user has to guess a secret...
We are going to develop a guessing game where the user has to guess a secret number. We will start from a simple task and refine our code step by step. Task is to develop a program that Generates a random integer number in the range of [1-10] as the secret number Asks for user to input an integer in the range of [1-10] Print out the secret number and a user's input. Steps Please download this sample code, using...
3. Refer to Ch 4, pg 132- 4 in BM. We are going to calculate the...
3. Refer to Ch 4, pg 132- 4 in BM. We are going to calculate the velocity of the Earth today (let’s say 7 Feb 2020) using the vis viva equation. Take a deep breath... (a) Calculate the "mean anomaly" of the Earth M. This is the angle from perihelion to the position of Earth as if the Earth were in a circular orbit. You have to look up the perihelion of the Earth. See pg 34 in BM. This...
For this homework assignment, we present two ideal scenarios. Scenario #1: After graduation from high school,...
For this homework assignment, we present two ideal scenarios. Scenario #1: After graduation from high school, students begin jobs as construction workers and elementary school teachers. They expect their wages to remain relatively level throughout their careers. They marry five years after graduation from high school and raise large families with home schooling by the parents. Before marriage, both men and women work; once couples begin home schooling their children, one parent stays home, either the father or the mother....
ok here is my homework This assignment focuses on file streams. Your program will accept the...
ok here is my homework This assignment focuses on file streams. Your program will accept the name of an input file from the user, and the name of an output file from the user. You may assume the input file contains no more than 100 lines. Your program will write the lines of the input file to the output file in reverse line order, i.e. the first line of the input file becomes the last line of the output file,...
Write a class to accept a sentence from the user and prints a new word in...
Write a class to accept a sentence from the user and prints a new word in a terminal formed out of the third letter of each word. For example, the input line “Mangoes are delivered after midnight” would produce “neltd”. Program Style : Basic Java Programming
Homework 6: Present Value We sought out a soothsayer, who did sayeth some sooth. She stirred...
Homework 6: Present Value We sought out a soothsayer, who did sayeth some sooth. She stirred her cauldron and foresaw that terrible things would happen to Evanston. 100 years from this very day, the crimes of John Evans will come back to punish the residents of this town, causing $300 million dollars of damages. However, we can avert this terrible fate at the low, low cost of just $6 million dollars today (paid to descendants of those Evans wronged). That’s...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT