Question: Please change this C# code to Java code!!! public class Test{ // Print the data to Console public static void WriteOutput(string s){ Console.WriteLine(s); } //
Please change this C# code to Java code!!!
public class Test{ // Print the data to Console public static void WriteOutput(string s){ Console.WriteLine(s); } // Taking Input from Console; public static int ReadInput(){ return Convert.ToInt32(Console.ReadLine()); } public static void Main(){ // Array to check if a number is enter twice or not bool[] l = new bool[70]; for (int i = 0; i < 70; i++) l[i] = false; int j = 1; while (true){ WriteOutput("Please enter number "+j+" which should be > 0 and less than 70: "); int n = ReadInput(); // if number is invalid if (n <= 0 || n >= 70){ if (n <= 0) WriteOutput("Number " + j + " must be greater than zero"); else WriteOutput("Number " + j + " must be less than 70"); } // the number is already repeated else if (l[n-1] == true) WriteOutput("Number " + j +" must be different from previous numbers"); else{ l[n-1] = true; j += 1; } // if we have entered 5 numbers if (j == 6) break; } // Code for powerball int powerball; // Until we did not get valid powerball while (true){ WriteOutput("Please enter a number that is > 0 and less than 27 for your lucky Powerball number"); // read a value between 0 and 27 int p_ball = ReadInput(); if (p_ball <= 0 || p_ball >= 27){ if (p_ball <= 0) WriteOutput("The Powerball must be greater than zero"); else WriteOutput("The Powerball must be less than 27"); } else{ powerball = p_ball; break; } } // print the result WriteOutput("Your power ball numbers are "); for (int i = 0; i < 70; i++){ if (l[i] == true) Console.Write((i+1)+" "); } WriteOutput(" and the Powerball number is "+powerball); } } Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
