2011-10-08 13:47:14 UTC
int iResult, num1 = 25, num2 = 40, num3 = 17, num4 = 5
double fResult, val1 = 17.0, val2 = 12.78
a) iResult = num1 / num4
b) fResult = num1 / num4
c) iResult = num3 / num4
d) fResult = num3 / num4
e) fResult = val1 / num4
f ) fResult = val1 / val2
g) iResult = num1 / num2
h) fResult = (double) num1 / num2
i ) fResult = num1 / (double) num2
j ) fResult = (double) (num1 / num2)
k) iResult = (int) (val1 / num4)
l ) fResult = (int) (val1 / num4)
m) fResult = (int) ((double) num1 / num2)
n) iResult = num3 % num2
2) What output is produced by the following code fragement?
String m1, m2, m3;
m1 = "Quest for the Holy Grail";
m2 = m1.toLowerCase();
m3 = m1 + " " + m2;
System.out.println (m3.replace( 'h', 'z' ));
3) Write a single statement that computes and prints the absolute value of total.
4) Assuming that a Random object called generator has been created, what is the range of the result of each of the following expressions?
a) generator.nextInt(20)
b) generator.nextInt(8) + 1
c) generator.nextInt(45) + 10
d) generator.nextInt(100) - 50
Any help would be greatly appreciated. Thanks in advanced