Answered step by step
Verified Expert Solution
Link Copied!

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 (e.g., 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
IF-ELSE
IF-ELSE-IF
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.
Rock-Paper-Scissors: 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 0 and 10. The boost value is determined from generating a random number between 0 and 10. Assuming the starting distance of the spaceship is 0, 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 2 is used, the output of the program will look like:
Boost: 6
Distance travelled: 6
This program uses a pseudo-random number generator. The line SeedRandomNumbers(2) results in a series of pseudo-random numbers that is reproducible each time the program runs, thus allowing us to test your output. The seed value for this lab is 2. Uncomment the line SeedRandomNumbers(2) when implementing your program.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Real Time Database Systems Architecture And Techniques

Authors: Kam-Yiu Lam ,Tei-Wei Kuo

1st Edition

1475784023, 978-1475784022

More Books

Students also viewed these Databases questions