rec05 cs1114 in lab programs

Write the following programs on paper - in practice for how you will be taking the test: no books, no notes, no laptop.

Show your lab worker your completed code for each program before going to the next.

Your lab worker will tell you which one to submit via the handin system.

Program #1. Sentinel Method, 15 minutes
Program #2. How many method 7, minutes

Get words from the user and after the user has stopped, tell the user how many times each of these words were entered:

This

C++

program

Show the percentage of all the words instead of just how many.

Write two programs.
In one, use the sentinel method. In the other, use the 'ask how many' method?

Program #3. 15 minutes

Write the program that will show the status for each student who took Test 2.

The user will be entering the data for each student who took Test 2.
This information is based on the stats from Test 1 which will have to be entered by the user. (Yes, it’s not a great system but the user will have to enter all the Test 1 data and then the Test 2 data to learn each student’s status in the course after Test 2.)

Each data set will contain the students’ name (a single name) and their score. The scores will be floating point values.

Your output should be for each student who takes Test Two state:

·  the student’s name

·  their letter grade on Test 2 based on a scoring system that is NOT used in cs1114 - the 60-70-80-90 system

·  whether their score is above or below the average score on Test One

Use an input validation loop to allow only valid data to be entered for scores. Scores can range from 0 to 100.
Where is the test data? On the test, you’d be shown an example.

Program #4. 15 minutes with a “stub” for menu item 4.
Program #5. Include code for menu item 4., additional 15 minutes

Write the program that presents the user this menu and does what it says.
The user’s name in our example is Sue.
How many times should this menu be presented?

What is your name? Sue

Choose from the following:

1. Print your name twice on one line, separated by a space

2. Print your name the number of times you'd like to see it,

each time on a separate line

3. Print your name an infinite number of times

(you'll have to hit ^C to stop the program!)

4. Draw a pattern using your name

0. Quit

For menu item 4., this is the processing to make the pattern:

Take a small number (between 2 and 5 inclusive) (you must enforce this) .
If the user's name is Sue and she enters the number 4 this is the output:

\\\\Sue////

\\\\Sue////

\\\\Sue////

\\\\Sue////

Notice that there are four lines.
Notice that there are four forward slashes and four backward slashes.
Notice that the second line is indented by 4 spaces, the third by 8 and the fourth by 12.

All these 4's are because Sue chose 4 as her number.
Use loops to accomplish this. (Make sure you choose the correct loop)
Notice also that you must not use blocks in the cases of switches. Any variables you need for in a case (except loop variables) should be defined before the switch.

You’ll likely not be asked to write something like this on the test, but notice the issues:
The first number uses different code that all the rest of the numbers on each output line.
The user’s input are used in the for loop as starting and stopping values.
Only work on this program if you have time after finishing the others.

Program #last - optional. (not a timed exercise)

Write the program that takes two numbers from the user and produces the following output. Don’t assume that the first input will be smaller than the second – fix the order.

It is OK is the user enters the same number twice.

If the user enters 7 and 15:

7-8-9-10-11-12-13-14-15

8-9-10-11-12-13-14

9-10-11-12-13

10-11-12

11

If the user enters 14 and 7:

7-8-9-10-11-12-13-14

8-9-10-11-12-13

9-10-11-12

10-11