Find three run-time errors in the program - what are the


1. What is the value of mystery after this sequence of statements?
int mystery = 1;
mystery = 1 - 2 * mystery;
mystery - mystery + 1;

2. What is wrong with the following sequence of statements?
int mystery 1;
mystery - mystery + 1;
int mystery 1 - 2 * mystery;

3. Write the following mathematical expressions in Java.

s = so + vot + 1/2 gt2

G = 4 Π2.a3/p2(m1 + m2)

FV = PV.(1 + INT/100)YRS

c = √(a2 + b2 - 2abcosγ)

4. Write the following Java expressions in mathematical notation.
a. dm . m * (Math.sqrt(1 + v / c) / Math.sqrt(1 - v / c) - 1);
b. volume = Math.PI * r * r * h;
c. volume = 4* Math.PI * Math.pow(r, 3) / 3;
d. z = Math.sqrt(x * x + y * Y);

5. What are the values of the following expressions? In each line, assume that

double x = 2.5;
double y = -1.5;

int m = 18;
int n = 4;

a. x + n * y- (x + n) * y
b. m /n + m%n
c. 5 * x - n / 5
d. 1 - (1 - (1 - (1 - (1 - n))))
e. Math.sqrt(Math.sqrt(n))

6. What are the values of the following expressions, assuming that n is 17 and m is 18?
a. n / 10 + n % 10
b. n % 2 + m % 2
C. (m + n) / 2
d. (m + n) / 2.0
e. (int) (0.5 * (m + n))
f. (int) Math.round(0.5 * (m + n))

7. What are the values of the following expressions? In each line, assume that
String s - "Hello";
String t "World";
a. s.length() + t.length()
b. s.substring(1, 2)
C. s.substring(s.length() / 2, s.length())
d.s + t
e. t + s

8. Find at least five compile-time errors in the following program.
public class HasErrors
public static void main();
{
System.out.print(Please enter two numbers:)
x in.readDouble;
y in.readDouble;
System.out.printline("The sum is " + x + y);
}
}

9. Find three run-time errors in the following program.
public class HasErrors
public static void main(String[] args)
{
int x - 0;
int y 0;
Scanner in - new Scanner("System.in");
System.out.print("Please enter an integer:");
x in.readInt();
System.out.print("Please enter another integer: ");
x in.readInt();
System.out.println("The sum is " + x + y);

}

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Find three run-time errors in the program - what are the
Reference No:- TGS02191762

Expected delivery within 24 Hours