The program prints the message “This program simulates a swimming competition or meet.” to the screen. The program then asks the user the following question: “Would you like to continue (yes or no)?” o If the answer is “yes” (in either upper or lower case), a simple message “Main program code to be inserted here.” is displayed. Program execution is then repeated and the user is again asked if they would like to continue. o If the answer is anything other than “yes”, the program displays “Maybe next time. Goodbye.” and exits.The simple message from step 1 “Main program code to be inserted here.” is replaced by a series of questions: o The user is asked to enter the length of the swimming race. The length can be one of the following 50m, 100m, 200m, 400m, 800m or 1500m. “Enter the length of the swimming race in metres (50, 100, 200, 400, 800 or 1500):” o The user is asked to enter the names of the competitors in this swimming event. The user must enter 11 competitors’ names. “Enter a competitor’s name (type “end” to finish):” The program then prints a simple message “Code to determine number of heats and simulate event to be inserted here.”The simple message from step 2 “Code to determine number of heats and simulate event to be inserted here.” is replaced by the code that: o determines the number of heats from the number of competitors entered; o simulates the running of the event and displays heat results to the screen; o determines the top 3 competitors; o awards gold, silver and bronze medals to the competitors with the first, second and third best finishing times, respectively. When the user chooses not to continue, before exiting, the program will print the following messages to the screen: o Thank you for using this program. XX swimming event(s) were simulated. Where XX is the number of times the user has responded with “yes” to the “Would you like to continue (yes or no)?” question.Event Length / Stroke / Sex World Record Time 50m Freestyle Men 21.28 100m Freestyle Men 47.50 200m Freestyle Men 1:43.86 400m Freestyle Men 3:40.08 800m Freestyle Men 7:38.65 1500m Freestyle Men 14:34.56 The maximum of a range is determined by the following equation: maximum = worldRecordTimeSeconds + ((eventLength / 50) * 3) where worldRecordTimeSeconds is the integer portion of the world record time in seconds (ie. the hundredths of a second are dropped). Example 1: 400m Freestyle Men: maximum = 220 + ((400 / 50) * 3) = 244 seconds (4:04.00) Example 2: 1500m Freestyle Men: maximum = 874 + ((1500 / 50) * 3) = 964 seconds (16:04.00) The minimum of a range is determined by the following equation: minimum = wordRecordTimeSeconds - (eventLength / 50) Example 1: 400m Freestyle Men: minimum = 220 – (400 / 50) = 216 seconds (3:36.00) Example 2: 1500m Freestyle Men: minimum = 874 – (1500 / 50) = 844 seconds (14:04.00) The number of heats in an event can be determined using the following algorithm: If ((numCompetitors % numLanes) > 0) then numHeats = (numCompetitors / numLanes) + 1 Else numHeats = (numCompetitors / numLanes) Where numLanes is 8 for an Olympic (Long Course) Pool.
输出结果: This program simulates a swimming competition or meet. Would you like to continue? (yes or no):no may be next time. Goodbye
This program simulates a swimming competition or meet. Would you like to continue? (yes or no):yes Enter the length of the swimming race in metres (50, 100, 200, 400, 800 or 1500):50 Enter a competitor's name (type 'end' to finish):end You must enter 10 or more competitors Enter a competitor's name (type 'end' to finish):Name 1 Enter a competitor's name (type 'end' to finish):Name 2 Enter a competitor's name (type 'end' to finish):Name 3 Enter a competitor's name (type 'end' to finish):Name 4 Enter a competitor's name (type 'end' to finish):Name 5 Enter a competitor's name (type 'end' to finish):Name 6 Enter a competitor's name (type 'end' to finish):Name 7 Enter a competitor's name (type 'end' to finish):end You must enter 10 or more competitors Enter a competitor's name (type 'end' to finish):Name 8
Enter a competitor's name (type 'end' to finish):Name 9 Enter a competitor's name (type 'end' to finish):Name 10 Enter a competitor's name (type 'end' to finish):end Event:50 Freestyle Men Number of competitors:10 Number of heats:2 Competitor 1:Name 1 Heat time:20.37 Competitor 1:Name 2 Heat time:21.12 Competitor 1:Name 3 Heat time:24.59 Competitor 1:Name 4 Heat time:21.18 Competitor 1:Name 5 Heat time:20.10 Competitor 1:Name 6 Heat time:20.50 Competitor 1:Name 7 Heat time:24.05 Competitor 1:Name 8 Heat time:23.25 Competitor 1:Name 9 Heat time:23.46 Competitor 1:Name 10 Heat time:22.18 Gold Silver Bronze Would you like to continue? (yes or no):no thank you for using
编个能输出这样的程序: This program simulates a swimming competition or meet. Would you like to continue? (yes or no):no may be next time. Goodbye This program simulates a swimming competition or meet. Would you like to continue? (yes or no):yes Enter the length of the swimming race in metres (50, 100, 200, 400, 800 or 1500):50 Enter a competitor's name (type 'end' to finish):end You must enter 10 or more competitors Enter a competitor's name (type 'end' to finish):Name 1 Enter a competitor's name (type 'end' to finish):Name 2 Enter a competitor's name (type 'end' to finish):Name 3 Enter a competitor's name (type 'end' to finish):Name 4 Enter a competitor's name (type 'end' to finish):Name 5 Enter a competitor's name (type 'end' to finish):Name 6 Enter a competitor's name (type 'end' to finish):Name 7 Enter a competitor's name (type 'end' to finish):end You must enter 10 or more competitors Enter a competitor's name (type 'end' to finish):Name 8
Enter a competitor's name (type 'end' to finish):Name 9 Enter a competitor's name (type 'end' to finish):Name 10 Enter a competitor's name (type 'end' to finish):end Event:50 Freestyle Men Number of competitors:10 Number of heats:2 Competitor 1:Name 1 Heat time:20.37 Competitor 1:Name 2 Heat time:21.12 Competitor 1:Name 3 Heat time:24.59 Competitor 1:Name 4 Heat time:21.18 Competitor 1:Name 5 Heat time:20.10 Competitor 1:Name 6 Heat time:20.50 Competitor 1:Name 7 Heat time:24.05 Competitor 1:Name 8 Heat time:23.25 Competitor 1:Name 9 Heat time:23.46 Competitor 1:Name 10 Heat time:22.18 Gold medal:name XX[...] Silver medalname XX[...] Bronze medal:name XX[...] Would you like to continue? (yes or no):no thank you for using
competition or meet.” to the screen. The program then asks the user the
following question: “Would you like to continue (yes or no)?”
o If the answer is “yes” (in either upper or lower case), a simple message
“Main program code to be inserted here.” is displayed.
Program execution is then repeated and the user is again asked
if they would like to continue.
o If the answer is anything other than “yes”, the program displays
“Maybe next time. Goodbye.” and exits.The simple message from step 1 “Main program code to be inserted here.” is
replaced by a series of questions:
o The user is asked to enter the length of the swimming race. The length
can be one of the following 50m, 100m, 200m, 400m, 800m or 1500m.
“Enter the length of the swimming race in metres (50, 100, 200,
400, 800 or 1500):”
o The user is asked to enter the names of the competitors in this
swimming event. The user must enter 11 competitors’ names.
“Enter a competitor’s name (type “end” to finish):”
The program then prints a simple message “Code to determine number of
heats and simulate event to be inserted here.”The simple message from step 2 “Code to determine number of heats and
simulate event to be inserted here.” is replaced by the code that:
o determines the number of heats from the number of competitors
entered;
o simulates the running of the event and displays heat results to the
screen;
o determines the top 3 competitors;
o awards gold, silver and bronze medals to the competitors with the first,
second and third best finishing times, respectively.
When the user chooses not to continue, before exiting, the program will print
the following messages to the screen:
o Thank you for using this program.
XX swimming event(s) were simulated.
Where XX is the number of times the user has responded with “yes” to the
“Would you like to continue (yes or no)?” question.Event Length / Stroke / Sex World Record Time
50m Freestyle Men 21.28
100m Freestyle Men 47.50
200m Freestyle Men 1:43.86
400m Freestyle Men 3:40.08
800m Freestyle Men 7:38.65
1500m Freestyle Men 14:34.56
The maximum of a range is determined by the following equation:
maximum = worldRecordTimeSeconds + ((eventLength / 50) * 3)
where worldRecordTimeSeconds is the integer portion of the world record time in
seconds (ie. the hundredths of a second are dropped).
Example 1: 400m Freestyle Men:
maximum = 220 + ((400 / 50) * 3) = 244 seconds (4:04.00)
Example 2: 1500m Freestyle Men:
maximum = 874 + ((1500 / 50) * 3) = 964 seconds (16:04.00)
The minimum of a range is determined by the following equation:
minimum = wordRecordTimeSeconds - (eventLength / 50)
Example 1: 400m Freestyle Men:
minimum = 220 – (400 / 50) = 216 seconds (3:36.00)
Example 2: 1500m Freestyle Men:
minimum = 874 – (1500 / 50) = 844 seconds (14:04.00)
The number of heats in an event can be determined using the following algorithm:
If ((numCompetitors % numLanes) > 0) then
numHeats = (numCompetitors / numLanes) + 1
Else
numHeats = (numCompetitors / numLanes)
Where numLanes is 8 for an Olympic (Long Course) Pool.
This program simulates a swimming competition or meet.
Would you like to continue? (yes or no):no
may be next time. Goodbye
This program simulates a swimming competition or meet.
Would you like to continue? (yes or no):yes
Enter the length of the swimming race in metres (50, 100, 200, 400, 800 or 1500):50
Enter a competitor's name (type 'end' to finish):end
You must enter 10 or more competitors
Enter a competitor's name (type 'end' to finish):Name 1
Enter a competitor's name (type 'end' to finish):Name 2
Enter a competitor's name (type 'end' to finish):Name 3
Enter a competitor's name (type 'end' to finish):Name 4
Enter a competitor's name (type 'end' to finish):Name 5
Enter a competitor's name (type 'end' to finish):Name 6
Enter a competitor's name (type 'end' to finish):Name 7
Enter a competitor's name (type 'end' to finish):end
You must enter 10 or more competitors
Enter a competitor's name (type 'end' to finish):Name 8
Enter a competitor's name (type 'end' to finish):Name 10
Enter a competitor's name (type 'end' to finish):end
Event:50 Freestyle Men
Number of competitors:10
Number of heats:2
Competitor 1:Name 1
Heat time:20.37
Competitor 1:Name 2
Heat time:21.12
Competitor 1:Name 3
Heat time:24.59
Competitor 1:Name 4
Heat time:21.18
Competitor 1:Name 5
Heat time:20.10
Competitor 1:Name 6
Heat time:20.50
Competitor 1:Name 7
Heat time:24.05
Competitor 1:Name 8
Heat time:23.25
Competitor 1:Name 9
Heat time:23.46
Competitor 1:Name 10
Heat time:22.18
Gold
Silver
Bronze
Would you like to continue? (yes or no):no
thank you for using
This program simulates a swimming competition or meet.
Would you like to continue? (yes or no):no
may be next time. Goodbye This program simulates a swimming competition or meet.
Would you like to continue? (yes or no):yes
Enter the length of the swimming race in metres (50, 100, 200, 400, 800 or 1500):50
Enter a competitor's name (type 'end' to finish):end
You must enter 10 or more competitors
Enter a competitor's name (type 'end' to finish):Name 1
Enter a competitor's name (type 'end' to finish):Name 2
Enter a competitor's name (type 'end' to finish):Name 3
Enter a competitor's name (type 'end' to finish):Name 4
Enter a competitor's name (type 'end' to finish):Name 5
Enter a competitor's name (type 'end' to finish):Name 6
Enter a competitor's name (type 'end' to finish):Name 7
Enter a competitor's name (type 'end' to finish):end
You must enter 10 or more competitors
Enter a competitor's name (type 'end' to finish):Name 8
Enter a competitor's name (type 'end' to finish):Name 10
Enter a competitor's name (type 'end' to finish):end
Event:50 Freestyle Men
Number of competitors:10
Number of heats:2
Competitor 1:Name 1
Heat time:20.37
Competitor 1:Name 2
Heat time:21.12
Competitor 1:Name 3
Heat time:24.59
Competitor 1:Name 4
Heat time:21.18
Competitor 1:Name 5
Heat time:20.10
Competitor 1:Name 6
Heat time:20.50
Competitor 1:Name 7
Heat time:24.05
Competitor 1:Name 8
Heat time:23.25
Competitor 1:Name 9
Heat time:23.46
Competitor 1:Name 10
Heat time:22.18
Gold medal:name XX[...]
Silver medalname XX[...]
Bronze medal:name XX[...]
Would you like to continue? (yes or no):no
thank you for using