Q#2 Submit this question as one CPP files Write a complete C++ program. In this program you have to write 3 functions in addition to the main function. 1. Function #1: Write function throwDice that generates a random number between 1 and 6. The function should return the generated number. int throwDice(); 1. Function #2: Write function userGuess that asks the user to enter a valid number between 1 and 6. The function should ask the user to re-enter as long as the input is not valid. The function should return the valid input of the user. int userGuess(); 1. Function #3: Write function decide that receives as input parameters two integers, the first parameter dice represents the dice value and the second parameter userG represents a user guess. This function should return true if userG and dice are equal; otherwise, it should return false. bool decide(int dice, int userG); Write a complete program to do the following in the main: 1. Call the function dice. 2. Call the function userGuess. 3. Call the function decide passing to it the previous returned values of calling dice and userGuess. 4. Display "Win" if the returned value of calling the function decide is true, otherwise, display "lose". 5. Repeat all the above steps (step a to step d) until the user decides to stop and exit the program.

FINANCIAL ACCOUNTING
10th Edition
ISBN:9781259964947
Author:Libby
Publisher:Libby
Chapter1: Financial Statements And Business Decisions
Section: Chapter Questions
Problem 1Q
icon
Related questions
Question
Q#2 Submit this question as one CPP files
Write a complete C++ program. In this program you have to write 3 functions in addition to the main function.
1. Function #1:
Write function throwDice that generates a random number between 1 and 6. The function should return the generated
number.
int throwDice();
1. Function #2:
Write function userGuess that asks the user to enter a valid number between 1 and 6. The function should ask the user to
re-enter as long as the input is not valid. The function should return the valid input of the user.
int userGuess();
1. Function #3:
Write function decide that receives as input parameters two integers, the first parameter dice represents the dice value
and the second parameter userG represents a user guess. This function should return true if userG and dice are equal;
otherwise, it should return false.
bool decide(int dice, int userG);
Write a complete program to do the following in the main:
1. Call the function dice.
2. Call the function userGuess.
3. Call the function decide passing to it the previous returned values of calling dice and userGuess.
4. Display "Win" if the returned value of calling the function decide is true, otherwise, display "lose".
5. Repeat all the above steps (step a to step d) until the user decides to stop and exit the program.
Transcribed Image Text:Q#2 Submit this question as one CPP files Write a complete C++ program. In this program you have to write 3 functions in addition to the main function. 1. Function #1: Write function throwDice that generates a random number between 1 and 6. The function should return the generated number. int throwDice(); 1. Function #2: Write function userGuess that asks the user to enter a valid number between 1 and 6. The function should ask the user to re-enter as long as the input is not valid. The function should return the valid input of the user. int userGuess(); 1. Function #3: Write function decide that receives as input parameters two integers, the first parameter dice represents the dice value and the second parameter userG represents a user guess. This function should return true if userG and dice are equal; otherwise, it should return false. bool decide(int dice, int userG); Write a complete program to do the following in the main: 1. Call the function dice. 2. Call the function userGuess. 3. Call the function decide passing to it the previous returned values of calling dice and userGuess. 4. Display "Win" if the returned value of calling the function decide is true, otherwise, display "lose". 5. Repeat all the above steps (step a to step d) until the user decides to stop and exit the program.
AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Similar questions
Recommended textbooks for you
FINANCIAL ACCOUNTING
FINANCIAL ACCOUNTING
Accounting
ISBN:
9781259964947
Author:
Libby
Publisher:
MCG
Accounting
Accounting
Accounting
ISBN:
9781337272094
Author:
WARREN, Carl S., Reeve, James M., Duchac, Jonathan E.
Publisher:
Cengage Learning,
Accounting Information Systems
Accounting Information Systems
Accounting
ISBN:
9781337619202
Author:
Hall, James A.
Publisher:
Cengage Learning,
Horngren's Cost Accounting: A Managerial Emphasis…
Horngren's Cost Accounting: A Managerial Emphasis…
Accounting
ISBN:
9780134475585
Author:
Srikant M. Datar, Madhav V. Rajan
Publisher:
PEARSON
Intermediate Accounting
Intermediate Accounting
Accounting
ISBN:
9781259722660
Author:
J. David Spiceland, Mark W. Nelson, Wayne M Thomas
Publisher:
McGraw-Hill Education
Financial and Managerial Accounting
Financial and Managerial Accounting
Accounting
ISBN:
9781259726705
Author:
John J Wild, Ken W. Shaw, Barbara Chiappetta Fundamental Accounting Principles
Publisher:
McGraw-Hill Education