6. Suggest two subsequent levels of menus for each of the first two options in this main menu:

(1) Print records from file

(2) Delete records from file

(3) Quit

Student answers will vary.

After the user chooses Print records from file, offer the user a choice of available printers. For each printer, offer available fonts.

After the user chooses Delete records from file, offer the user a choice of whether to delete a file or folder. After the user chooses a folder, ask which file should be deleted. After the user chooses a file, ask the user to choose whether to delete the file to the recycle bin, or permanently.

7. Develop the logic for a program that displays the rules for a sport or a game. The user can select from the following menu:

(1) Sports

(2) Games

(3) Quit

If the user chooses 1 for Sports, then display options for four different sports of your choice (for example, soccer or basketball).

If the user chooses 2 for Games, display options for:

(1) Card games

(2) Board games

(3) Quit

Display options for at least two card games (for example, Hearts) and two board games (for example, checkers) of your choice. Then display a one- or two-sentence summary of the game rules.

a. Hierarchy Chart:

b. Flowchart:




c. Pseudocode:

start

perform housekeeping()

while response not = 3

perform mainLoop()

perform finishUp()

stop

housekeeping()

declare variables

open files

perform displayMainMenu()

read response

return

displayMainMenu()

print "(1) Sports"

print "(2) Games"

print "(3) Quit"

print "Please press a number to make your selection."

read response

return

mainLoop()

based on response

case 1

perform sports()

case 2

perform games()

default

print "Sorry. Invalid entry."

perform displayMainMenu()

return

sports()

perform displaySportsMenu()

while sportsResponse not = 5

based on sportsResponse

case 1

perform baseballRules()

case 2

perform soccerRules()

case 3

perform basketballRules()

case 4

perform footballRules()

default

print "Sorry. Invalid selection."

perform displaySportsMenu()

return

displaySportsMenu()

print "(1) Baseball"

print "(2) Soccer"

print "(3) Basketball"

print "(4) Football"

print "(5) Quit this menu"

print "Please press a number to make your selection."

read sportsResponse

return

games()

perform displayGamesMenu()

while gamesResponse not = 3

based on gamesResponse

case 1

perform cardGameRules()

case 2

perform boardGameRules()

default

print "Sorry. Invalid selection."

perform displayGamesMenu()

return

displayGamesMenu()

print "(1) Card games"

print "(2) Board games"

print "(3) Quit this menu"

print "Please press a number to make your selection."

read gamesResponse

return

cardGameRules()

perform displayCardGamesMenu()

while cardGamesResponse not = 3

based on cardGamesResponse

case 1

perform heartsRules()

case 2

perform pokerRules()

default

print "Sorry. Invalid selection."

perform displayCardGamesMenu()

return

boardGameRules()

perform displayBoardGamesMenu()

while gamesResponse not = 3

based on boardGamesResponse

case 1

perform monopolyRules()

case 2

perform sorryRules()

default

print "Sorry. Invalid selection."

perform displayBoardGamesMenu()

return

displayCardGamesMenu()

print "(1) Hearts"

print "(2) Poker"

print "(3) Quit this menu"

print "Please press a number to make your selection."

read cardGamesResponse

return

displayBoardGamesMenu()

print "(1) Monopoly"

print "(2) Sorry"

print "(3) Quit this menu"

print "Please press a number to make your selection."

read boardGamesResponse

return

baseballRules()

print "Nine players hit ball with bat and run bases"

return

soccerRules()

print "Kick the ball into the other team's net"

return

basketballRules()

print "Throw the ball into the net"

return

footballRules()

print "Carry the ball across the other team's goal line"

return

heartsRules()

print "Don't take hearts or the queen of spades unless you can take them all"

return

pokerRules()

print "You gotta know when to hold them and know when to fold them"

return

monopolyRules()

print "Try to accumulate properties and build on them"

return

sorryRules()

print "Try to get all your pieces home first"

return

finishUp()

close files

return

8. Draw the menus, then develop the logic for a program that displays United States travel and tourism facts. The main menu should allow the user to choose a region of the country. The next level should allow the user to select a state in that region. The final level should allow the user to select a city, at which point the user can view facts such as the city’s population and average temperature. Write the complete module for only one region, one state, and one city.

Menus:

(1)Northeast
(2)South
(3)Midwest
(4)West
(5)Southwest
(6)Quit
Please press a number
to make your selection
(1)Indiana
(2)Illinois
(3)Iowa
(4)Kansas
(5)Michigan
(6)Ohio
(7)Wisconsin
(8)Quit this menu
Please press a number to
make your selection
(1)Chicago
(2)Springfield
(3)Peoria
(4)Quit this menu
Please press a number to
make your selection

a. Hierarchy Chart:

b. Flowchart:



c. Pseudocode:

start

perform housekeeping()

while response not = 6

perform mainLoop()

perform finishUp()

stop

housekeeping()

declare variables

open files

perform displayRegionMenu()

return

displayRegionMenu()

print "(1) Northeast"

print "(2) South"

print "(3) Midwest"

print "(4) West"

print "(5) Southwest"

print "(6) Quit"

print "Please press a number to make your selection."

read response

return

mainLoop()

based on response

case 1

perform northeast()

case 2

perform south()

case 3

perform midwest()

case 4

perform west()

case 5

perform southwest()

default

print "Sorry. Invalid entry."

perform displayRegionMenu()

return

midwest()

perform displayMidwestStateMenu()

while midwestStateResponse is not equal to 8

based on midwestStateResponse

case 1

perform indiana()

case 2

perform illinois()

case 3

perform iowa()

case 4

perform kansas()

case 5

perform michigan()

case 6

perform ohio()

case 7

perform wisconsin()

default

print "Sorry. Invalid selection."

perform displayMidwestStateMenu()

return

displayMidwestStateMenu()

print "(1) Indiana"

print "(2) Illinois"

print "(3) Iowa"

print "(4) Kansas"

print "(5) Michigan"

print "(6) Ohio"

print "(7) Wisconsin"

print "(8) Quit this menu"

print "Please press a number to make your selection."

read midwestStateResponse

return

illinois()

perform illinoisMenu()

while illinoisResponse is not equal to 4

based on illinoisResponse

case 1

perform chicago()

case 2

perform springfield()

case 3

perform peoria()

default

print "Sorry. Invalid selection."

perform illinoisMenu()

return

illinoisMenu()

print "(1) Chicago"

print "(2) Springfield"

print "(3) Peoria"

print "(4) Quit this menu"

print "Please press a number to make your selection."

read illinoisResponse

return

chicago()

print "The population is 8 million. The average temperature is 65 F."

return

finishUp()

close files

return

9. Design the menus, then develop the logic for an interactive program for a florist. The first screen asks the user to choose indoor plants, outdoor plants, nonplant items, or quit. When the user chooses indoor or outdoor plants, list at least three appropriate plants of your choice. When the user chooses a plant, display its correct price. If the user chooses the nonplant option, offer a choice of gardening tools, gift items, or quit. Depending on the user selection, display at least three gardening tools or gift items. When the user chooses one, display its price.

Menus:

(1) Indoor plants
(2) Outdoor plants
(3) Nonplant items
(4) Quit
Please enter your choice
(1)Ficus
(2)Coleus
(3)Cactus
(4)Quit
Please enter your choice
(1) Rose bush
(2)Apple tree
(3)Impatiens
(4)Quit
Please enter your choice
(1)Gardening tools
(2)Gift items
(3)Quit
Please enter your choice
(1)Hoe
(2)Rake
(3)Shovel
(4)Quit
Please enter your choice
(1) Candle
(2) Ceramic goose
(3) Pink flamingo
(4) Quit
Please enter your choice

a. Hierarchy Chart:

b. Flowchart:

c. Pseudocode:

start

perform housekeeping()

while response not = 4

perform mainLoop()

perform finishUp()

stop

housekeeping()

declare variables

open files

perform displayMenu()

return

displayMenu()

print "(1) Indoor plants"

print "(2) Outdoor plants"

print "(3) Nonplant Items"

print "(4) Quit"

print "Please enter your choice"

read response

return

mainLoop()

based on response

case 1

perform indoor()

case 2

perform outdoor()

case 3

perform nonplant()

default

print "Sorry. Invalid entry."

perform displayMenu()

return

indoor()

perform displayIndoorMenu()

while indoorResponse is not equal to 4

based on indoorResponse

case 1

perform ficus()

case 2

perform coleus()

case 3

perform cactus()

default

print "Sorry. Invalid selection."

perform displayIndoorMenu()

return

displayIndoorMenu()

print "(1) Ficus"

print "(2) Coleus"

print "(3) Cactus"

print "(4) Quit"

print "Please enter your choice "

read indoorResponse

return

outdoor()

perform displayOutdoorMenu()

while outdoorResponse is not equal to 4

based on outdoorResponse

case 1

perform roseBush()

case 2

perform appleTree()

case 3

perform impatiens()

default

print "Sorry. Invalid selection."

perform displayOutdoorMenu()

return

displayOutdoorMenu()

print "(1) Rose bush"

print "(2) Apple tree"

print "(3) Impatiens"

print "(4) Quit"

print "Please enter your choice"

read outdoorResponse

return

nonplant()

perform displayNonplantMenu()

while nonplantResponse is not equal to 3

based on nonplantResponse

case 1

perform gardening()

case 2

perform gift()

default

print "Sorry. Invalid selection."

perform displayNonplantMenu()

return

displayNonplantMenu()

print "(1) Gardening tools"

print "(2) Gift items"

print "(3) Quit"

print "Please enter your choice"

read nonplantResponse

return

gardening()

perform displayGardeningMenu()

while gardeningResponse is not equal to 4

based on gardeningResponse

case 1

perform hoe()

case 2

perform rake()

case 3

perform shovel()

default

print "Sorry. Invalid selection."

perform displayGardeningMenu()

return

displayGardeningMenu

print “(1) Hoe”

print “(2) Rake”

print “(3) Shovel”

print “(4) Quit”

print “Please enter your choice”

read gardeningResponse

return

gift()

perform displayGiftMenu()

while giftResponse is not equal to 4

based on giftResponse

case 1

perform candle()

case 2

perform ceramicGoose()

case 3

perform pinkFlamingo()

default

print "Sorry. Invalid selection."

perform displayGiftMenu()

return

displayGiftMenu

print “(1) Candle”

print “(2) Ceramic goose”

print “(3) Pink flamingo”

print “(4) Quit”

print “Please enter your choice”

read giftResponse

return

ficus()

print "Price is", ficusPrice

return

coleus()

print "Price is", coleusPrice

return

cactus()

print "Price is", cactusPrice

return

roseBush()

print "Price is", roseBushPrice

return

appleTree()

print "Price is", appleTreePrice

return

impatiens()

print "Price is", impatiensPrice

return

hoe()

print "Price is", hoePrice

return

rake()

print "Price is", rakePrice

return

shovel()

print "Price is", shovelPrice

return

candle()

print "Price is", candlePrice

return

ceramicGoose()

print "Price is", goosePrice

return

pinkFlamingo()

print "Price is", flamingoPrice

return

finishUp()

close files

return