A Write JAVA code to declare a variable using the correct data type for the math
ID: 3666508 • Letter: A
Question
A Write JAVA code to declare a variable using the correct data type for the mathematic value of pi using 3.14145 What is the value of x after the calculation is executed? Int x = 4/5; What is the value of x after the calculation is executed? Int x = 7 % 3; What is the value of answer after the following code is executed? Boolean answer = (6 > 5); What is printed by the JAVA code? Char a CharValue = 9; int a NumValue = 9; System. out println (" a CharValue is" + a CharValue +" aNumValue is"+ aNumValue); What EXACTLY is printed by the JAVA code? Int billing Data = 5; System. out.print("Bills are sent on day"); System. out print (billing Date): System. out. Print ("of the month"); System. out. Printin (" Next. bill; October " + billing Date): What is the value of result ? int result = ((9+6)% 3)-); What is the value of result? Double result = (19 + 8 % 3) -4; What EXACTLY is printed by the JAVA code? System. out. Println ("X" + 2 + 4+ (2 + 4));Explanation / Answer
/**
* @author Srinivas Palli
*
*/
public class ExampleTest {
public static void main(String[] args) {
// A)
final double PI = 3.14145;
// B)
int x = 4 / 5;
System.out.println("B) x = " + x);
// C)
x = 7 % 3;
System.out.println("C) x = " + x);
// D)
boolean answer = (6 > 5);
System.out.println("D) answer = " + answer);
// E)
char aCharValue = '9';
int aNumValue = 9;
System.out.println("E) aCharValue is " + aCharValue + " aNumValue is "
+ aNumValue);
// F)
int billingDate = 5;
System.out.print("F) Bills are sent on day ");
System.out.print(billingDate);
System.out.print(" of the month ");
System.out.println(" Nex bill: October " + billingDate);
// G)
int result = ((9 + 6) % 3 - 4);
System.out.println("G) result = " + result);
// H)
double result1 = (19 + 8 % 3) - 4;
System.out.println("H) result = " + result1);
// J)
System.out.println("J) X" + 2 + 4 + (2 + 4));
}
}
OUTPUT:
B) x = 0
C) x = 1
D) answer = true
E) aCharValue is 9 aNumValue is 9
F) Bills are sent on day 5 of the month
Nex bill: October 5
G) result = -4
H) result = 17.0
J) X246
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.