69 679
Assignments Done
Successfully Done
In February 2019

Answer to Question #60270 in Java | JSP | JSF for Theressa Lalanne

Question #60270
1. In the main method place a method call to the method that will store the returned result in a variable of your choosing. Use number1 and number2 as the parameters.
Inside the main method, output the returned value from the method using the variable in a single println statement
Expert's answer
import java.util.Scanner;
public class Choice {

static int choice;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int number1 = (int) (Math.random() * 100);
int number2 = (int) (Math.random() * 100);

System.out.print("Make your choice. Choose one number: " + number1 + " " + number2 + "\nYour choice: ");
choice = in.nextByte();
choice = selectionMethod(number1, number2);
System.out.print("You choose the number of: " + choice);

private static int selectionMethod(int number1, int number2) {
if (number1 == choice) return number1;
else return number2;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions