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 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
