Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this exercise, you will create a Java program to randomly choose, and then p

ID: 3750214 • Letter: F

Question

For this exercise, you will create a Java program to randomly choose, and then print to the console, one of five possible greetings. The text of the 5 possible greetings is up to you. Using IntelliJ IDE create a new Java project called "RandomHello". You may use the following as a skeleton for your class RandomHello.java: public class RandomHe1lo 1 public static void main(String1 args) f RandomHello randomHe7lonew RandomHe1loO; System.out.println(randomHe11o. sayHe110)); public String sayHelloO 1 YOUR CODE GOES HERE Please note that this skeleton is meant only to serve as a starting point for students who are not familiar with Java. If you have some Java programming experience, you are free to organize RandomHello as you see fit.

Explanation / Answer

//Java program

import java.util.Random;

public class RandomHello {

public static void main(String args[]) {

RandomHello randomhello=new RandomHello();

System.out.println(randomhello.sayHello());

}

  

public String sayHello() {

Random random = new Random();

String Greeting [] =new String [5];

Greeting [0] ="Hello World";

Greeting [1] ="Hola Mundo";

Greeting [2] ="Bonjour Monde";

Greeting [3] ="Hallo Welt";

Greeting [4] ="Ciao Mondo";

  

return Greeting[random.nextInt(Greeting.length)];

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote