2010 Homework #4

Conditional statements, and looping.

Due: before lab class begins 9/26/2019

Write the 4 programs below.

Write your programs in your 2010/4/ folder on Odin.

The exact name of each program is given.

Include comment lines at the top of each program with your name and information about which program you are writing.

The output of your program should be formatted like the samples below.
Each of your programs should be a gem with perfect indenting style, no warnings or errors, and beautiful output.

    Remember:  do not use any goto statements.
               do not use the string class.

1.
Name your program: order3.cpp

Prompt the user for 3 numbers.
After entry, display all 3 numbers in order from low to high.

sample output...
Please enter 3 numbers: 6 14 3 Your numbers in-order are: 3 6 14
Notes: Any three numbers are allowed for input. There is no input validation. See if you can... • get input with just one cin statement. • find a solution with just three if-statements. • show the result with just one cout statement. Tips: Store the input numbers in 3 different variables. Use if-statements to arrange the numbers for output.
2.
Name your program: sumnum.cpp

Sum of Numbers

Write a program that asks the user for a positive integer value. The program
must use a loop to get the sum of all the integers from 1 up to the number
entered. For example,

You must use a while, do-while, or a for-loop.

   if the user enters 4, the answer is 10.

   Input Validation: Do not accept negative numbers or zero.

sample output:
Summation of a number series 1 to n. Enter n: 10 Sum of 1 through 10 is: 55
3.
Name your program: bingo.cpp

3-5-bingo!

   Display the numbers 1 through 100 using a for-loop.

   if a number is divisible by 3,
       print "three" next to the number.

   if a number is divisible by 5,
       print "five" next to the number.

   if a number is divisible by 3 and 5,
      do not print "three"
      do not print "five"
      print only "bingo!" next to the number.

Your program should look like the output below.

Partial output is shown. The complete output goes up to 100.

3-5-bingo program. 1 2 3 three 4 5 five 6 three 7 8 9 three 10 five 11 12 three 13 14 15 bingo! 16 17 18 three 19 . . .
4.
Name your program: pyramid.cpp

Prompt the user for the height of a pyramid.
Display a pyramid of that height.

Example run:
Enter pyramid height: 7 * *** ***** ******* ********* *********** *************
This program requires nested loops. Nested loops must be used in this program. bonus point: If the pyramid is 8 or higher, give it smooth sides and a top.
Enter pyramid height: 8 ^ /*\ /***\ /*****\ /*******\ /*********\ /***********\ /*************\