Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help me answer this question! iRUBRIC There are 4 numbered instructions in the code, along with comments that should help you to make changes.
Please help me answer this question!
iRUBRIC There are 4 numbered instructions in the code, along with comments that should help you to make changes. Look back at any code from previous exercises. Run the code and look at the output to see what it does. POINTS- 10- The code compiles and runs Challenge \#1 10- The coin values are only 0 (tails) or 1 (heads) 5- This is done through changing variables Challenge \#2 10- The print statement only says "DOUBLE if 2 coins match 15- The correct relational and logical operators are used. Challenge \#3 10- The print statement only says "HEADS" if at least 1 coin is heads 15- The correct relational and logical operators are used. Challenge \#4 10- The print statement only says "TWO HEADS" if both coins are heads ( 15- The correct relational and logical operators are used. Paste your code into the answer text box. % public static void main(Stringll artse ! int max=9 : int m in =0; int loops - 3: int coin 10 int coin2=0 for (int i Dik loopsit+ it) System.out.printin("In\#1 Flip 2 Coins"): YCHALLENGE 12 You will notice from the the lines printed below 4 that the coins do not have the correct values. W/ They should be 0 for tails and 1 for heatis: coin1 - (int)(Math random() )(maxmin)+ min): coin2 - (int)(Math.random() )(maxmin)+ min); System.out.printin("coin1 ="+ coin1); System.out.printin("coin2 =" + coin2); ICCHALLENGE "2 Change the code below to say WOW it 2 coins have the same value /A You only need to change the conditions. if ((coin1>=coin2)) System.out printin("WoW: Two coins the samel"); Jelse ( System.out.printin("No matches'); J. IICHALLENGE \#3 Change the code below to say WOW if at least 1 coin is heads (1, not 0) /I You only need to change the conditions. if ((coin1:3)&&(coin2>=4)). System.out.printlin("WOW! At least one coin is heads"); Jelse I System.out.println("neither coin is heads')? f ICHALLENGE H4 Change the code below to s3y WOW it both coins are beids 4) You anly need to change the conditions: if ((coin1)=1)/1(coin23))[ System.out.printin("WOW! Both coins are Heads!?) Jelse ( System out printin("No matches") 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