You may not give a copy of your code to your designated pair-programming partner if you did not develop the code together.

You may not show your completed code to another person or look at another person's code until you complete and submit this assignment and the due date has passed, except for code you develop together with your pair-programming partner.

You may get help from people other than your pair-programming partner if you get stuck, but only if they do not show or tell you the code to type.

Remember that the instructor performs similarity tests on programming project submissions, and plagiarized code is usually very easy to detect.

Project Specifications

Keep the same filename and add to the existing code to complete the project. Leave the existing code unchanged, except for changing Your Name and Date Completed in the comments to your name and the date respectively.

Add your name and the date to the file comment block at the top of the file where shown in the comments.

User input is already coded into the worksheet.

Do not add any other input commands or change the input order.

Read the comments in the worksheet file and write the code specified in the comments. The code output should look like the following two Example Runs. The places to enter your code are marked:

// *** Enter code here ***

Example Runs: The input prompts and outputs of the program must look like the following for full credit, including the same order of input and wording of the output. For the input shown you must get the same output. However, the output must change properly if the inputs are different.

***** Squirrel Logic *****
This worksheet prints information about squirrels that depends
on the answers to the following questions.
Enter the number of nuts: 63
Enter the temperature: 75
Enter true for weekend and false for weekday: false
The squirrel says Chitter!
63 is basic food, more nuts please.
When the temperature is 75, squirrels are playing.
When a squirrel has 63 nuts it says "Bark!"
With 63 nuts on a weekday, it is a bad party :(

***** Squirrel Logic *****
This worksheet prints information about squirrels that depends
on the answers to the following questions.
Enter the number of nuts: 80
Enter the temperature: 59
Enter true for weekend and false for weekday: true
The squirrel says Chatter!
80 is better food, more nuts please.
When the temperature is 59, squirrels are resting.
When a squirrel has 80 nuts it says "Cry!"
With 80 nuts on a weekend, it is a good party!

In the above example run, the user entered the values shown in italics (for emphasis) to produce the output. Your program does NOT print the characters in italics, nor does the user input appear in italics.

After displaying the output, exit the program.

Submit the source code file squirrel.cpp with the rest of the assignment as described in Deliverables.

Project 2: Numbers in the Electromagnetic Spectrum

Electromagnetic waves can be measured by either wavelength or frequency. The wavelength is the distance between one wave crest (or trough) to the next. The frequency is the rate at which the waves repeat over a period of time such as seconds.

The term electromagnetic spectrum refers to the entire range of the frequencies of electromagnetic radiation and light wavelengths. Electromagnetic radiation extends from radio waves (low frequency) to Gamma rays (high frequency). There are no precisely defined boundaries between the bands of the electromagnetic spectrum as the bands fade into each other like the bands in a rainbow [1]. However, we will use the boundaries shown in the following table for our project.

Electromagnetic Spectrum

Type

Wavelength (m)

Frequency (Hz)

Radio wave

[ 10-1, +∞ )

[ 3 x 109, 0 )

Microwaves

[ 10-3, 10-1 )

[ 3 x 109, 3 x 1011 )

Infrared

[ 7 x 10-7, 10-3 )

[ 3 x 1011, 4 x 1014 )

Visible light

[ 4 x 10-7, 7 x 10-7 )

[ 4 x 1014, 7.5 x 1014 )

Ultraviolet

[ 10-8, 4 x 10-7 )

[ 7.5 x 1014, 3 x 1016 )

X-rays

[ 10-11, 10-8 )

[ 3 x 1016, 3 x 1019 )

Gamma rays

( -∞, 10-11 )

[ 3 x 1019, +∞ )

Project Specifications

Write a program that asks the user for a wavelength value and prints a description of where the value belongs in the electromagnetic spectrum defined by the table above.

Name the source code file spectrum.cpp and include all your code in this single file.

Be careful of the spelling, including capitalization, as you will lose points for a misspelled name. Naming is important in programming.

Ask the user for the following inputs (and no other input) in this order and each on their own line, as shown in the Example Run below:

Numbers on the boundary between two wavelengths belong in the longer wavelength (lower frequency) spectrum (higher entry in the table).

Add a while statement that allows the user to repeat the program by entering a "y" (without the quotes).

Example Run: The input prompts and outputs of the program must look like the following for full credit, including the same order of input and wording of the output. For the input shown you must get the same output. However, the output must change properly if the inputs are different.

Enter a wavelength and I will report the band of
the electromagnetic spectrum.
Enter a wavelength in meters: .001
Microwaves
Run again? (y/n) y
Enter a wavelength in meters: 4e-7
Visible light
Run again? (y/n) n

In the above example run, the user entered the values shown in italics (for emphasis) to produce the output. Your program does NOT print the characters in italics, nor does the user input appear in italics.

Submit the source code file spectrum with the rest of the assignment as described in Deliverables.

Hints:

Start by translating the Electromagnetic Spectrum table from scientific to exponential notation. Here are the first few numbers in both exponential and fixed notation.

Scientific

Exponential

Fixed

10-1

1e-1

0.1

10-3

1e-3

0.001

7 x 10-7

7e-7

0.0000007

As an example, Microwaves have a wavelength of 10-3 to 10-1, which is 0.001 to 0.1 meters. Thus, microwave wavelengths are less than 10-1 but greater than or equal to 10-3.

References and More Information

Project 3: Ice Cream Orders

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 orders. In this project we will look at decoding orders at an ice cream shop.

Project Specifications

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

CH

Chocolate

CC

Chocolate Chocolate Chip

CM

Chocolate Mint

HC

Horchata

MC

Mocha Chip

RR

Rocky Road

SB

Strawberry

VB

Vanilla Bean

For example, the code for twelve scoops of Chocolate Mint is: CM12. Notice there are no spaces between the code and quantity. The quantity can be any amount greater than zero.

Name the source code file icecream.cpp and include all your code in this single file.

Be careful of the spelling, including capitalization, as you will lose points for a misspelled name. Naming is important in programming.

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

Assume the user enters all the codes with UPPERCASE letters as shown.

Store the order code in a singlestring 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).

Example Run: The input prompts and outputs of the program must look like the following for full credit, including the same order of input and wording of the output. For the input shown you must get the same output. However, the output must change properly if the inputs are different.

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!

In the above example run, the user entered the values shown in italics (for emphasis) to produce the output. Your program does NOT print the characters in italics, nor does the user input appear in italics.

If the user enters an invalid code, display the message, "We don't have that flavor." as shown in the example run.

Submit the source code file icecream.cpp with the rest of the assignment as described in Deliverables.

Hints:

Use the substr() function to separate the code and quantity into separate variables.

Remember that we can always extract the last few characters of a string without knowing its length. See lesson 3.2.6: String Functions.

Tutorial Lab

In preparation for next weeks lessons, complete the following:

Type the program invtable.cpp from the textbook on page 145 into a text editor, and then compile and run the program. Submit your working source code file to Canvas for grading using the file name invtable.cpp.

Complete the Tutorial Exercises in CodeLab 4 before the specified due date. Refer to the assigned reading for the next lesson to help you understand the problems. Also, you can use the online lecture notes for more information as the notes become available. You can look at solutions if you miss your first attempt by clicking the "Solution" tab.

Grading Criteria

The instructor will evaluate your assignment using the following criteria. Thus you should check your assignment against these criteria to maximize your score.

Each criteria represents a specific achievement of your assignment and has a scoring guide. The scoring guide explains the possible scores you can receive. Some scoring guides have a list of indicators. These indicators are a sign of meeting, or a symptom of not meeting, the specific criterion. Note that a single indicator may not always be reliable or appropriate in a given context. However, as a group, they show the condition of meeting the criterion.

README.txt File

Deliverables

Students submit some homework as they work on it like CodeLab. However, students must submit other homework in Canvas following the link to A4-Making Selections. Include the following items when submitting to Canvas:

Note: Make certain your programs compile before you turn them in. When a program does not compile then it does not function either. For all programming problems, you should expect little or no credit if your program does not compile and run. For more information see the Grading Criteria.

You must submit all the files needed to complete your assignment. Your assignment must work as submitted. Remember to test and double check your files before submitting them. If you make a mistake, you can resubmit up to the deadline. If you resubmit, you must include all your assignment files in the last submission as Canvas hides prior submissions.