Exercises - chapter 5

Mr. Gottsacker
Computer Programming


Relevant links for Chapter 5


5.101

Write a program that prints out the following converstion table of light years to astronomical units (the distance from the Earth to the Sun). Note that one light year is 63241.077 astronomical units.


Light years 	 Astronomical Units
1 	 	 63241.08
2 	 	 126482.15
3 	 	 189723.23
...
9 	 	 569169.69
10 	 	 632410.77
            

5.102

Write a program that prints out the following conversion table of nautical miles to miles. Note that one nautical mile is 1.151078 miles.


Nautical miles 	 Miles 
1 	 	 1.151078
5 	 	 5.755390
10 	 	 11.510780
15 	 	 17.266170
... 
495 	 	 569.783610
500 	 	 575.390000
            

5.103

Write a program that prints out the winningest soccer team given a series of team names and their number of wins in the season. Prompt the user to enter the number of teams that are in the league. Then, collect each team's name and their number of wins in the season. Then, display the name of the team with the most wins.


5.104

Use a while loop to find the largest integer n such that n^3 is less than 14,000.


5.14 (from textbook)


5.16 (from textbook)


5.23 (from textbook)


5.25 (from textbook)


5.27 (from textbook)


5.30 (from textbook) - very similar to Exercise_2_13


5.33 (from textbook)


5.40 (from textbook)


5.41 (from textbook)


5.43 (from textbook)


5.46 (from textbook)


5.105

Rewrite Exercise 4.102, taking advantage of loops. When the program is first run, prompt the user to enter the number of quizzes that they would like to take. Each quiz should generate two integers between 10 and 20, and prompt the user to answer the sum of them. After the last quiz, output the user's score to two decimal places.

5.106

Rewrite Exercise 4.103, taking advantage of looping. The user should enter a password with any number of characters. The password must contain at least one of the following:

Notify the user about whether the password meets the requirements, and improvements they can make.


5.107

Rewrite Exercise 4.104, taking advantage of looping. Prompt the user to enter a password of any length. Transform the password to make it stronger. Specifically:

character leet
a or A @
e or E 3
s or S $
o or O 0