Links
• Home
• Contact Me
• Aeries Portal
• Royal High School
• Simi Valley USD
AP Statistics
• Course Calendar
• Chapter Notes
• Practice Tests
• Statistics Links
AP CompSci
• Course Content
• Programs
• Practice Tests
• CompSci Links
CP Statistics
• Course Calendar
• Chapter Notes
• Practice Tests
• Statistics Links
Algebra
• Table of Contents
Geometry
• Table of Contents
Math Power
• Table of Contents

17. Write a program that uses nested loops to print out all of the following designs. Just write one program that does all 3, one after the other. Make version A first and get it to work. Then B, etc... Note that the three results are not to be displayed sidebyside as shown below, but vertically.
A 
B 
C 
1 
987654321 
1 
12 
98765432 
21 
123 
9876543 
321 
1234 
987654 
4321 
12345 
98765 
54321 
123456 
9876 
654321 
1234567 
987 
7654321 
12345678 
98 
87654321 
123456789 
9 
987654321 




18. Write a program that uses nested loops to print out all of the following designs. Just write one program that does all 3, one after the other. Make version A first and get it to work. Then B, etc... Note that the three results are not to be displayed sidebyside as shown below, but vertically. Allow the user to specify the character they would like to use in the design.
A 
B 
C 
******** 
***** 
********* 
******** 
**** 
******* 
******** 
*** 
***** 
******** 
** 
*** 
******** 
* 
* 




19. Write a program that uses nested loops to print the following multiplication table. All output MUST be generated using loops and must look EXACTLY as shown.
X

1

2

3

4

5

6

7

8

9

1

1

2

3

4

5

6

7

8

9

2

2

4

6

8

10

12

14

16

18

3

3

6

9

12

15

18

21

24

27

4

4

8

12

16

20

24

28

32

36

5

5

10

15

20

25

30

35

40

45

6

6

12

18

24

30

36

42

48

54

7

7

14

21

28

35

42

49

56

63

8

8

16

24

32

40

48

56

64

72

9

9

18

27

36

45

54

63

72

81


20. When a player lands in jail in the game of Monopoly, he/she has the opportunity to “get out” by rolling doubles with the dice. The player must pay $50 if they are unsuccessful after 3 tries. Assume that they could roll as long as they wanted. How long, on average, would one expect to take to roll doubles? To answer this question, simulate this situation 10,000 times and find the average number of rolls needed per attempt to achieve doubles.
For example, if we ran three trials and they took 9, 5 and 6 rolls, the average would be 6.7 (20/3) rolls. To see this another way, look at it in table form:
Trial 
Rolls needed to "double" 
1 
9 
2 
5 
3 
8 
Total 
22 
For 3 trials and a total of 22, the average number of rolls is then 22/3 = 7.33 rolls.
Also display the highest number of rolls needed to achieve doubles (in the example above that would be 9).
This program is random, so results will vary. 
21. Write a program to determine all possible ways to make change for a dollar using only quarters, dimes, nickels and pennies. The output must show the results, one line at a time, without showing zeros. Count the number of ways that the program finds to make change and print this result at the end of the program.
For example: 2 quarters 5 dimes not 2 quarters 5 dimes 0 nickels 0 pennies.
The total number of combinations is 242
Hint: This program requires 4 FOR LOOPS (one for each type of coin). 
22. A perfect number is any integer that is equal to the sum of its factors, not including itself. For example, 6 is a perfect number because 1+2+3=6. Write a program to find the first four perfect numbers (6 is the first). This is a tough one! 
