Great Deal! Get Instant \$25 FREE in Account on First Order + 10% Cashback on Every Order Order Now

# NCTC- COSC 1437 F19 1 Program Set #4 Total Points: 30 Choose 3 of the 6 problems below for full credit. The starred problem must be implemented. See 1437 Grading Guide Sheet for additional...

NCTC- COSC 1437 F19
1

Program Set #4
Total Points: 30

Choose 3 of the 6 problems below for full credit. The sta
ed problem must be implemented. See 1437
points each)

1. Implement Programming Project #11-Chapter 14 (Savitch), pp. 666/667. Implement the classes and
member functions as stated in the problem. Place all classes into one file. Output should be user friendly.

Name the program: PlayCardInheritXX.cpp, where XX are your initials.

2. In the childhood game of Musical Chairs, chairs are placed in a circle with one less chair than players.
Children march to the music around the circle of chairs until the music stops. Then each child sits in the
chair nearest them. The one child that cannot find a chair is eliminated from the game. A chair is removed
and the game continues until there is just one person left. That person is the winner. Write a C++ program
to simulate a game of Musical Chairs and determine the winner of each game played. The simulation will
work as follows:
• The chairs are numbered from 1 to m.
• The children are numbered from 1 to m + 1.
• Two integers a and b are given. The first integer a is the chair number where child #1 will sit when
the music stops. When the music stops, the children begin sitting down with child #1 sitting in
chair a, child #2 sitting in chair a + 1, etc, until chair b is reached. The person who would have
een assigned to chair b is eliminated and the next person in line is seated in chair b.
• Since the chairs are in a circle, once chair m is reached, the children begin sitting in chair #1 and
continue until the rest of the children have been seated.
• The children are then renumbered with the child sitting in chair #1 becoming child #1, the child in
chair #2 becoming child #2, etc.
• Chair number m is then removed and the game is continued with one less chair and one less child.

Input: The first line from a text file, will contain a single integer n that indicates the number of games to be
played. For each game there will be m + 2 lines where m is the number of chairs in the game. The first of
these lines will be the integer m that indicates the number of chairs in the game. The second of these
lines will have the first names of m + 1 players separated by a comma and a space. Each of the next m
lines will have two integers separated by a space. The first integer a will represent the chair number
where the children will begin sitting and the second number b will be the number, relative to the first
chair, of the person who will not find a seat. Output: For each game, label the game played, on the
following line output original players of the game, output a blank line, then output the order of the
students, beginning with chair #1, each time the music stops. The winner will be the last child. Output a
lank line between each game played. Let the user input the file name from the keyboard. Refer to the
sample output below.

NCTC- COSC 1437 F19
2

Sample File:
1
6
ANNE, BECKA, CHAD, DREW, ERNIE, FRANK, GEORGE
3 5
2 1
4 3
3 1
2 2
1 2

Sample Run:

Enter the file name: chairs.txt

Game 1:

Original Students:
ANNE, BECKA, CHAD, DREW, ERNIE, FRANK, GEORGE

FRANK GEORGE ANNE BECKA DREW ERNIE
ERNIE FRANK GEORGE ANNE BECKA
FRANK GEORGE BECKA ERNIE
BECKA ERNIE FRANK
FRANK ERNIE

Winner: FRANK

Name the program: MusicalChairsXX.cpp, where XX are your initials.

3. Given a dollar amount between \$0.01 and \$9.99 write a C++ program to compute the fewest
number of standard American coins needed to produce that sum. The standard coins are:

• dollar (\$1.00)
• half-dollar (\$0.50)
• quarter (\$0.25)
• dime (\$0.10)
• nickel (\$0.05)
• penny (\$0.01)

Input the amount from the keyboard (double). Output the number of coins in descending order of value,
using plurals when a specific coin is represented more than once. Include a recursive function to
compute the change. Must use a recursive function for full credit. E
or check input. Refer to the
sample output below.

NCTC- COSC 1437 F19
3

Sample Run:

Enter the amount (double): 1.47

Change returned:
1 dollar
1 quarter
2 dimes
2 pennies

Name the program: RecChangeXX.cpp, where XX are your initials.

4. In 1844, Samuel Morse designed a coding
system in which letters and other symbols
are represented as coded sequences of short
and long tones, traditionally called dots and
dashes. In Morse code, the 26 letters of the
alphabet and special characters are
epresented by the following codes at right.
Write a C++ program that reads in a line
from the user and translates each line to
Morse code, using periods (.) to represent
dots and hyphens (-) to represent dashes.
Separate the letters in each word with a
space and two space between words in the
sentence. Allow only the characters and
numbers found in the table to the right.
Ignore case. Use C++ string class and
appropriate STL classes. Refer to the sample output below.

Sample Run:

Morse Code translator

The string entered was: Hello World

The transformed string is:

.... . .-.. .-.. --- .-- --- .-. .-.. -..

Name the program: STLMorseCodeXX.cpp, where XX are your initials.

NCTC- COSC 1437 F19
4

5. Telephone numbers in the US and Canada are organized into various three-digit area codes. A single
area code will not cross a state or provincial boundary. This rule makes it possible to list the
geographical locations of each area code in a data file. Write a C++ program that reads the file into a STL
Map where the key is the area code and the value is the location. The user can either enter an area code
or state/providence from the keyboard and have the program list all the area codes (or state) that serve
that area. Text file will be provided by the instructor. Let the user enter the file name from the
keyboard. The program will repeatedly run until the user enters "QUIT". Check for case. Use the STL
classes. Refer to the sample output below.

Sample Run:
Enter the file name: areacodes.txt

Enter the area code or state/providence name: Oregon

458
503
541
971

Enter the area code or state/providence name: 778

British Columbia

Enter the area code or state/providence name: QUIT

Name the program: AreaCodeMapXX.cpp, where XX are your initials.

6(**). Implement Programming Project #14-Chapter 13 (Savitch), p. 618. Modify the program to print the
shortest word latter. Let the user input the file name from the keyboard.

Name the program: RecWordLatterXX.cpp, where XX are your initials.

NCTC- COSC 1437 F19
5

Extra Credit: Implement the problems below for extra credit. See 1437 Grading Guide Sheet for

1. Implement Programming Project #3-Chapter 16 (Savitch), p XXXXXXXXXXMake sure to implement the
templated and non-templated versions of the insertion sort. Output should be user friendly.

Name the program: TemplatedSortXX.cpp, where XX are your initials.

2. Implement Programming Project #2-Chapter 18 (Savitch), p. 864. Make sure to implement all
equirement as stated in the problem. Output should be user friendly.

Name the program: ExceptionDepthXX.cpp, where XX are your initials.
Dec 05, 2021
SOLUTION.PDF

## Get Answer To This Question

### Submit New Assignment

Copy and Paste Your Assignment Here