input code:
![public class Main { public static void main(String[] args) { /*declare the variables*/ double x=Math.sqrt(3); double y=4; /*c](http://img.homeworklib.com/questions/ad3ed840-df81-11ea-9235-8daa30d5742c.png?x-oss-process=image/resize,w_560)
output:

code:
public class Main
{
public static void main(String[] args)
{
/*declare the variables*/
double x=Math.sqrt(3);
double y=4;
/*check conditions*/
if(x*x==y)
{
/*print x if true*/
System.out.println(x);
}
else
{
/*else print y*/
System.out.println(y);
}
}
}
Question 28 (1 point) ✓ Saved What does the code fragment print? double x = Math.sqrt...
Question 52 (1 point) Write the missing code in the following code fragment to check the input using method of the Scanner class. This fragment is intended to read from a text file. Scanner in = new Scanner(...); while double hours = in.nextDouble(); System.out.println (hours); D] Previous Page Next Page Page 52 of 52
What does the following code fragment print? char c[20] = "ABC"; cout << sizeof(c[2]) << endl; 2. What does the following code fragment print? char c[20] = "ABC"; c[3] = 'x'; cout << c << endl; 3. What does the following code fragment print? char c[20] = "ABC"; c[3] = 'x'; strcat(c, "ZZ"); cout << c << endl;
What does the following code fragment print? Explain the result? int [] a = new int[10]; for (int i = 0; i < 10; i++) a[i] = 9 - i; for (int i = 0; i < 10; i++) a[i] = a[a[i]]; for (int i = 0; i < 10; i++) System.out.println(a[i]);
Question 4 (1 point) Translate this Python statement to Java: print(n, end=' ') Question 4 options: a. System.out.print(n) b. System.out.print(n + " "); c. System.out.println(n); d. System.println(n + " "); Question 5 (1 point) What is the output of this code fragment? int count = 0; for(int n = 3; n <= 10; n += 2) { count++; } System.out.println(count); Question 5 options: a. 2 b. 3 c. 4 d. 10
(a)How many times does the code snippet given below display "Hello"? int x = 1; while (x != 15) { System.out.println ("Hello"); x++; } (b)What is the output of the following code fragment? int i = 1; int sum = 0; while (i <= 5) { sum = sum + i; i++; } System.out.println("The value of sum is " + sum); Quie 2 What is the output of the following snipped code? public class Test {...
3) What are the final values of a, b, c in the following code fragment (1.5 point): int a = 6 , b = 127 , c; c = ( ++a ) + ( b -- ); Answer: 4) What are the final values of a, b, c in the following code fragment (1.5 point): int a = 6 , b = 127 , c; c = (a++) + ( -- b); Answer: 5) What is displayed by this poorly...
Question 41 Which of the following is NOT a valid assignment statement? A. x = 55; B. 55 = x; C. x += 3; D. x = 56 + y; Question 42 What is the result of 45 / 4? A. 11.25 B. 10 C. 12 D. 11 Question 43 What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0");...
PLEASE SOLVE THESE QUESTIONS
Q.3.6 What does the following code output? int x = 8; int y = 2; while(x > 8) { X- y+=2; } System.out.println(y); Q.3.7 What does the following code output? System.out.println((2 + 3 - 5) * (3/3) + (5+5)); Q.3.8 What does the following code output? if((2 == 2) && (3 != 3) && ((5 + 1)==6){ System.out.println(true); else { System.out.println(false);
Question 15 (1 point) What does this program print? Please make sure your spacing is exact. public class Test { System.out.print("39 + 3"); System.out.println(39 + 3); } 1 A/ Question 5 (1 point) Consider a file called input.txt that has the following 4 lines: Trace the program when it is 89 lines 78.5 is average. Isn't it? What would be the value of count after the following code snippet executes? Scanner in = new Scanner (new File("input.txt")); int count 0;...
Given the following Java code fragment, what is output? int a, b; String c, d, e; String x = new String(“I LOVE”); String y = “java!”; a = x.length( ); System.out.println(“1) “ + a); b = y.length( ); System.out.println(“2) “ + b); c = y.toUpperCase( ); System.out.println(“3) “ + c); d = x.toLowerCase( ); System.out.println(“4) “ + d); e = x.concat(y); System.out.println(“5) “ + e);