Question
What is output by the following program? Suppose the input is: 20 15 import java.util.*; public class Mystery { public static Scanner console = new
What is output by the following program? Suppose the input is: 20 15
import java.util.*;
public class Mystery {
public static Scanner console = new Scanner(System.in);
public static final int NUM = 10;
public static final double X = 20.5;
public static void main(String[] args) {
int a, b;
double z;
char grade;
a = 25;
System.out.println("a = " + a);
System.out.print("Enter the first integer: ");
a = console.nextInt();
System.out.println();
System.out.print("Enter the second integer: ");
b = console.nextInt();
System.out.println();
System.out.println("The numbers you entered are " + a + " and " + b);
z = X + 2 * a - b;
System.out.println("z = " + z);
grade = 'A';
System.out.println("Your grade is " + grade);
a = 2 * NUM + (int) z;
System.out.println("The value of a = " + a);
}
}
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