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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!