Assignment 13
Due Thursday, May 24 at 9:20am

Assignment 13.1: Little Boy Blue Again (10 pts)

Denslow-little-boy-blue2.jpg Open blue.cpp from Assignment 12.

Alter the while loop in your program to be a for loop.

When your output is identical to the while loop version's, submit your program to Canvas.

Your Output Should Look Like the Following. Note that some values have been omitted for brevity.

Little Boy Blue
Come Blow Your Horn
Little Boy Blue
Little Boy Blue
Come Blow Your Horn
Little Boy Blue
The Sheep's in the Meadow. The Cow's in the Corn.
Little Boy Blue
Come Blow Your Horn
Little Boy Blue
The Sheep's in the Meadow. The Cow's in the Corn.

Assignment 13.2: i and j (10 pts)
  • Create a new C++ file called ij.cpp.
  • In this assignment, we are going to write another program that uses a for loop. 
  • Within the loop, make the variable i go from -5.0 to 5.0, counting by 0.5
  • Inside the body of the loop, set another variable j to be the current value of i raised to the fourth power
  • For output, you will need to display the current values of both i and j in a chart, as shown below.
  • Note that above the values, you should print out i above the i column and j above the j column.
  • Also, you should display the values to exactly one decimal point.
  • You will need to use tab, fixed and setprecision(n) and the pow(base,exp) function here. (What library(ies) do you need?)
  • When you are finished, upload your source code to Canvas.
Your Output Should Look Indentical to the Following:

i          j
-5.0       625.0
-4.5       410.1
-4.0       256.0
-3.5       150.1
-3.0       81.0
-2.5       39.1
-2.0       16.0
-1.5       5.1
-1.0       1.0
-0.5       0.1
0.0        0.0
0.5        0.1
1.0        1.0
1.5        5.1
2.0        16.0
2.5        39.1
3.0        81.0
3.5        150.1
4.0        256.0
4.5        410.1
5.0        625.0

Assignment 13.3: Really Cool Ice Cream (10 pts)

  • Encoding and decoding information can save memory space and speed transmission of data.
  • Waitstaff at ice cream shops often encode orders to reduce writing and speed up customer service.
  • Develop a program that asks a user for a single input -- where the first two characters is a flavor of ice cream in the following shorthand code and the last characters are the number of scoops for the type.
Code Ice Cream Flavor
CCChocolate Chocolate Chip
CMChocolate Mint
MCMocha Chip
RRRocky Road
VBVanilla Bean

  • For example, the code for twelve scoops of Chocolate Mint is: CM12. Notice there are no spaces between the code and quantity.
  • Name the source code file icecream.cpp and include all your code in this single file.
  • Ask the user for the following inputs (and no other input) in this order, as shown in the Example Run below:
    • A single order code like: CM12 (no spaces allowed!!)
    • A 'y' or 'n' (without the quotes) for the repeat loop
  • Also, assume the user enters all the codes with UPPERCASE letters as shown.
  • Store the order code in a single string variable.
    • Then use substr() to analyze and process the input string to print a full description of the ice cream order.
  • Add a while statement that allows the user to repeat the program by entering a 'y' (without the quotes).
  • If the user enters an invalid code, display the message, "We don't have that flavor." as shown in the example output.
Your Output Should Look Indentical to the Following (except user input will vary):

Welcome to the Really Cool Ice Creamery!

Enter the ice cream order code: CM12
12 Chocolate Mint
Another order? (y/n) y

Enter the ice cream order code: HC2
2 Horchata
Another order? (y/n) y

Enter the ice cream order code: XY123
We don't have that flavor.
Another order? (y/n) n

Your ice cream order will be right up!