(5/5)

need code wrote for each question

Quiz #3 Name___________________

Note: Each problem has the indicated value. Demonstrate each program per the included test values (bottom of p.2). It is YOUR responsibility to create, enter, test, troubleshoot, save, recover any lost/deleted/backup files, plus provide a commented listing printout of each program; the Instructor will not do these tasks for you. Comments must be part of the program file, not written onto the listing. Use your notes, book(s), previous labs and quizzes to assist you. Do not consult fellow students. Use only one computer. Partial credit is awarded for programming efforts that don’t work. Quiz is based on 100 points; thus 20 extra credit points.

1. YOU have just won $1,000,000 in a lottery. In an effort to teach responsibility to your child (niece/nephew, grandchild, etc.), you offer to pay the child $1000 per day for a month for keeping his/her room clean. The child counters with $0.01 the first day, doubled each subsequent day from the previous day. You readily accept the deal and sign an agreement with the child to assure no cheating on the deal. Write a C language program that will compute and display the dollar amount paid each day and the total paid out after each day for a 31 day month. (20 point problem)

2. The cosine of an angle is the adjacent side divided by the hypotenuse, in which a 90o angle connects the opposite and adjacent side. Example: cos 45o = 1/1.414 = 0.7071. The secant of an angle is defined as 1/cos of the angle. Write a C language program that will compute the cosine of each degree from 0o – 180o and store the result in a 2-D array. Compute the secant for each angle; store the result in the same 2-D array. Print out a table showing the cosine and secant for each degree from 0o – 180o. (25 point problem)

3. In the game “Rock, Paper, Scissors”, each opponent simultaneously selects rock, paper, or scissors by hand signal with the winner determined by this formula: Rock beats Scissors, Scissors beats Paper, Paper beats Rock; a tie if both the same. Implement the game vs. the computer by these steps:

A. Use an integer variable cval = rand() % 3 where the random number generator rand() is found in stdlib.h. For the computer, assign 0 = rock, 1 = scissors, 2 = paper.

B. Prompt the user to enter ‘R’, ‘P’, or ‘S’, and also ‘Q’ to quit. Allow both uppercase and lowercase. Re-prompt (indefinitely) for any other entry. If ‘Q’ is entered, output “Game Over” and exit the program. Otherwise, compare your choice to the computer’s using the above winner formula.

C. Display the computer’s choice and the winner. Display the running total wins, losses, and ties for the computer and the user. (35 point problem)

4. Color bands on the side of an electrical resistor provide the value (in ohms) of the resistor by providing the digits, the power of 10 multiplier, and the tolerance on the resistor’s value. Of the four bands, the first two provide leading digits of the numeric value of the ohms, the third band provides the power of 10 multiplier, and the fourth band provides the tolerance percentage. Specific values are assigned to the different colors. The letters in parentheses are the color abbreviations to be used in this problem.

Bands 1, 2, 3 Band 4 – Tolerance %

Black (BK) - 0

Brown (BR) - 1 No Band (N) - 20

Red (RD) - 2 Silver (S) - 10

Orange (OR) - 3 Gold (G) - 5

Yellow (YW) - 4

Green (GN) - 5 Examples:

Blue (BU) - 6 Brown-Black-Yellow-Silver = 10 x 104 +/- 10% =

Violet (VL) - 7 10,000 ohms with a range 9000 <= R <= 11000 ohms.

Gray (GR) - 8 Yellow-Violet-Red-no band = 47 x 102 +/- 20% =

White (WT) - 9 4700 ohms with a range 3760 <= R <= 5640 ohms.

Write a C language program that will:

A. Display the colors and their values and the abbreviations to be used.

B. Prompt for the color of the first band, the second band, the third band, and the fourth band. Test that the user response is in the form of the character / string abbreviations required.

C. Compute and print the nominal value in ohms.

D. Compute and print the value range in ohms.

E. Include ‘ohms’ or its abbreviation after each value. (40 point problem)

Demonstration; test all the values indicated:

Problem 1 – entire program output.

Problem 2 – entire program output.

Problem 3 – R, S, P, and Q.

Problem 4 – Brown-Black-Brown-no band

Red-Blue-Red-Silver

Yellow-Violet-Orange-Gold

Gray-White-Green-Gold

(5/5)

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Get Free Quote!

437 Experts Online