Fix the program: what if the input is three?
import java.util.Scanner
public class Test { public static void main(String[] args)
{ Scanner in = new Scanner(System.in); System.out.print("Enter an integer: ");
int m = in.nextInt(); System.out.print("Enter another integer: ");
int n = in.nextInt(); System.out.println(m + " " + n); } }
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner in = new Scanner(System.in); try { System.out.print("Enter an integer: "); int m = in.nextInt(); System.out.print("Enter another integer: "); int n = in.nextInt(); System.out.println(m + " " + n); } catch (Exception e) { System.out.println("Invalid input."); } } }
Get Answers For Free
Most questions answered within 1 hours.