Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This must be written in Coral Language. Determine the variables and relevant data types of each variable. Consider the necessary variables required to implement the
This must be written in Coral Language.
Determine the variables and relevant data types of each variable. Consider the necessary variables required to implement the logic of your game, as well as the relevant data type eg integer or float of each variable. Consider your inputs and outputs for the program as you work.
Initialize the variables using appropriate data values. Where necessary, assign an initial value to each variable. Note that variables that obtain an initial value from user input do not require initializing. For example, before you start simulating any of the games, there should be zero wins and losses.
Set a branch that uses conditionals to define the logic of the game. This must meet the requirements of the program. This includes using the following:
IF
IFELSE
IFELSEIF
Statements must also use the appropriate relational operators, which are as follows:
equals
not equal
less than
greater than
less than or equal
greater than or equal
Create one loop to define the logic, flow, and sequence of the game. This must meet the requirements of the program. Reference the Brief Tutorial on Coral, linked in this weeks Resources section, for a reminder of how to create loops in Coral. Use a WHILE or FOR loop and the appropriate relational operators and Avoid infinite loops by ensuring the loop has an exit condition using the appropriate relational operator.
Cracked Egg Game: Write code that will determine if one egg is hard boiled or raw.
Spaceship Race: Write code that will apply a boost value to one spaceship in the race toward the distant star.
RockPaperScissors: Write code that will play the game once.
Apply necessary arithmetic operations. Note that mathematical operators include and modulo This must meet the requirements of the program. For example, in each of the games, you will want to keep track of wins and losses.
Spaceship Race: Keep track of the distance traveled in the first round.
Write code using best practices including appropriate syntax and commenting. This includes the following:
Using descriptive names for your variables
Using the correct formatting structure with appropriate indentations
Using appropriate comments relating to your code
Write a program that simulates applying a "boost" to a spaceship in a spaceship race game. A spaceship makes progress by getting a "boost" value between and The boost value is determined from generating a random number between and Assuming the starting distance of the spaceship is the program will output the boost value and the total distance travelled by the spaceship after applying the boost. Note: Two newlines are output after the final output of the program
When a random seed value of is used, the output of the program will look like:
Boost:
Distance travelled:
This program uses a pseudorandom number generator. The line SeedRandomNumbers results in a series of pseudorandom numbers that is reproducible each time the program runs, thus allowing us to test your output. The seed value for this lab is Uncomment the line SeedRandomNumbers when implementing your program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started