Program 2:
Write a program that graphically depicts an integer’s magnitude by using asterisk, creating a
histogram.
Hint:
The
inner loop handles the printing of t
he asterisk and the outer loop handles
exciting until zero is entered. Make sure you don’t accept negative numbers.
Sample run:
Enter a positive integer (0 to quit): 5
*****
Enter a positive integer (0 to quit): 8
********
Enter a positive integer (0 to
quit):
–
5
Enter a positive integer (0 to quit):
–
10
Enter a positive integer (0 to quit): 15
***************
Enter a positive integer (0 to quit): 0
Good Bye!
Submit a copy of the program
(15 points)
and sample output for at least 4
–
5
numbers, including
invalid data (
5 points
).
Program 3:
Write a program to display an upside down right triangle. Yu should ask the user to provide you
with the height.
Sample Run:
Enter a number between 5 and 50: 10
**********
*********
********
*******
******
*****
****
***
**
*
Would you like to continue (Y/N)? N
Good bye!
Submit a copy of the program
(15 points)
and sample output for at least
2
–
3
numbers, including
invalid data (
5 points
)


0 comments