Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

* * * PLEASE HELP WITH CORAL CODE FORMAT ONLY * * * I have my code already and would simply like for an expert

***PLEASE HELP WITH CORAL CODE FORMAT ONLY***
I have my code already and would simply like for an expert to review it and see if it is missing anything or needs to be adjusted. I am fairly new to coral code and simply want some guidance for anything I may be missing or doing improperly.
Below is the scenario for the code:
Cracked Egg Game: There are a dozen eggs in a basket; some are hard boiled and some are raw. The object of this game is for the user to guess the number of hard-boiled eggs prior to playing the game. The computer then simulates cracking all 12 eggs, using a random number 0 or 1 to simulate raw or hard boiled. The number 0 should represent raw eggs and the number 1 should represent hard boiled. The computer must keep track of the number of hard-boiled eggs. At the conclusion of cracking all 12 eggs, the actual number of hard boiled is compared to the users guess, and whether the user won or lost is given as output.
Below is the CORAL code I have written so far:
//Variables for code are listed here
integer raw
integer boil
integer min
integer max
integer boiled
integer i
integer ranNum
min=0
max=1
//Program inquiry and User input
Put "How many hard-boiled eggs do you think there are?" to output
boiled = Get next input
//Utilizing a "for" loop, this generates the random number of \theta or 1
//If the random number is \theta , then the egg is raw
//else the egg is a hard-boiled
//count the number of hard-boiled eggs
for i =0; i <=11; i = i +1
ranNum = RandomNumber (0,1)
if ranNum ==0
raw =0
boil = boil
else
boil = boil +1
//Outputs the quantity of hard-boiled eggs determined by the code
Put "
This is the number of hard-boiled eggs there are: " to output
Put boil to output
//Outputs a "win" or "lose" message if the user's input and program's random number are the same or different
if boiled == boil
Put "
You have won the Cracked Egg Game! Congratulations!
Would you like to play again?" to output
else
Put "
Sorry, you lost the Cracked Egg Game. Better luck next time!
Would you like to play again?" to output

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

Beginning Microsoft SQL Server 2012 Programming

Authors: Paul Atkinson, Robert Vieira

1st Edition

1118102282, 9781118102282

More Books

Students also viewed these Databases questions

Question

5. How we can improve our listening skills?

Answered: 1 week ago