Question: File Home Insert Draw Design Layout References Mailings Review View Help Comments Editing Share ~ & Cut Calibri Light (Hea * 12 ~ |A A

 File Home Insert Draw Design Layout References Mailings Review View HelpComments Editing Share ~ & Cut Calibri Light (Hea * 12 ~|A" A Aa A AaBbCcDe AaBbCcDe AaBbC( AaBbCct AaB Find AaBbCcDc [)Copy AaBbCCC AaBbCcDdl AaBbCcDdl AaBbCcDdl AaBbCcDdi AaBbCcDe Cc Replace Paste Format Painter

File Home Insert Draw Design Layout References Mailings Review View Help Comments Editing Share ~ & Cut Calibri Light (Hea * 12 ~ |A" A Aa A AaBbCcDe AaBbCcDe AaBbC( AaBbCct AaB Find AaBbCcDc [) Copy AaBbCCC AaBbCcDdl AaBbCcDdl AaBbCcDdl AaBbCcDdi AaBbCcDe Cc Replace Paste Format Painter BIU ab x x A LA 1 Normal 1 No Spac... Heading 1 Heading 2 Title Subtitle Subtle Em... Emphasis Intense E... Strong Quote Intense Q... Dictate Sensitivity Editor Select Clipboard Font Paragraph Styles Editing Voice Sensitivity Editor NOTE: All programs that you write must have comments at the top with the program name, your name, and a sentence describing what the program will do. 1. Write a program called Lab10A. In this program you will ask the user for a positive integer and add up all the digits in it. Then you will print the sum. (See the video of my walk through for writing the program) Write a void function named add Digits that has 3 int parameters: the number itself, count of digits & the total of digits. The last 2 parameters should be reference parameters. This function should: . Count the number of digits in the number ii. Total the number of digits in the total ili. It will not have a return statement because the values will go back to main in the reference parameters b. In the main function i. Ask the user for a number with at least 3 digits and input it 11. Call add Digits sending the number, a count variable and a total variable as parameters. iii. Print the count and total with labels. Three hints: c. num % 10 will give you the last digit of a number (so 512 % 10 = 2) d. If num is an int, num / 10 will get rid of the last digit, so that you can get to the other digits (so 512 / 10 = 51) e. You'll want to use a while loop because you won't know how many digits are in the number. Sample Test Cases: (but I will test it with a different number) The input 512 would return 8. The input 7145 would return 17. The input 8613 would return 18. 2. Create a new program called Lab10B that will play a game of "Rock-Paper-Scissors" with the user. For the purposes of our game 0=rock, 1=paper & 2=scissors) The detailed instructions are below, but here's the overview. You will ask the user to enter a 0, 1 or 2 in the main function. The program will generate a random number that is 0, 1 or 2 in the programChoice function. Then the determineWinner function will compare the user's and program's choice to see who won. IMPORTANT - Follow the instructions for each function exactly as they are written. Do NOT add extra statements into a function to do something that is not required; this just causes you a lot of confusion. (i.e. - if it doesn't say to print in a function, don't put a cout statement in there, etc.). a. Write an integer function (no parameters) called programChoice that will return a random number between 0 and 2. (This will be the computer's play.) Before you return the number, print the word version of the choice (rock, paper or scissors - You'll need if-else if statements for this.) Don't forget you'll need to #include and , and use the following 2 statements: srand(time(0)); randomNum = rand() % 3; b. Write a void function named determine Winner that will have 2 integer parameters, the program's choice and the user's choice (You name them). In this function use the rules of rock-paper-scissors to determine who won. It should then print who won. (You'll need if-else if - else statements here too.) (Game rules: rock beats scissors, scissors beat paper, paper beats rock) c. In the main function: i. Ask the user to enter 0, 1 or 2 for their choice. When you ask, tell them what each digit stands for. ii. After they enter their choice, print whether it was rock, paper or scissors. iii. Call the program Choice function to get the integer for the program's choice. iv. Call the determineWinner function (sending the two game choices as parameters).3. Write a program named Lab10C that calculates the average of a group of test scores where the lowest score is dropped. It should use the following functions. a. void getScores should have 4 double reference parameters (one for each test score) getscores should do the following: - read 4 test scores from the text file Lab10C.txt (Important: declare your ifstream infile and open the file inside this function, not in the main function) - store them in the reference parameters b. void calcAverage (4 double parameters) should do the following: - call findLowest passing the test scores as parameters total the 4 scores and subtract the result returned by findLowest this will leave you with the total of 3 test scores, so divide the total by 3 print the average with a label c. double findLowest (so it has 4 double parameters) should find and return the lowest of the 4 scores passed to it. d. In the main function call getScores sending 4 double variables as parameters call calcAverage sending those 4 double variables Note about reference parameters: remember that with reference parameters, you will use the & in the top line of the function itself, but you will not use the & in the call to the function in main. 4. Write a program called Lab10D that will read pairs of numbers from a text file (Lab10D.txt) and then find the largest common divisor for both of those numbers. This will be the largest number that will evenly divide into both numbers. (Ex - the LCD of 5 and 25 is 5, the LCD of 8 and 20 is 4) a. Write an integer function named getL.CD that receives 2 integer parameters and returns their greatest common divisor. To do this you will have a for loop with I starting at 1 and going up to either one of the numbers. (It doesn't matter which.) Inside the for loop check to see if both integers are divisible by i. Find the last (largest) i that both numbers are divisible by. b. In your main function: i. Have a loop that will read pairs of numbers from the text file until it encounters the end of file (eof). ii. Call getLCD with each pair of numbers. iii. Print the result returned by getLCD with an appropriate label for each pair of numbers.85 90 100 25\f

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!