Question

Question 28 (1 point) ✓ Saved What does the code fragment print? double x = Math.sqrt (3); double y = 4; if (x + x == y) { Sy
0 0
Add a comment Improve this question Transcribed image text
Answer #1

input code:

public class Main { public static void main(String[] args) { /*declare the variables*/ double x=Math.sqrt(3); double y=4; /*c

output:

4.0 ... Program finished with exit code 0 Press ENTER to exit console.

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);
   }
   }
}

Add a comment
Know the answer?
Add Answer to:
Question 28 (1 point) ✓ Saved What does the code fragment print? double x = Math.sqrt...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 52 (1 point) Write the missing code in the following code fragment to check the...

    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? Explain the result? int [] a = new int[10];...

    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:...

    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...

    (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...

    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...

  • PLEASE SOLVE THESE QUESTIONS Q.3.6 What does the following code output? int x = 8; int...

    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....

    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;...

  • What is the output of the following code fragment? int i = 1; while( i <=...

    What is the output of the following code fragment? int i = 1; while( i <= 5 ) if(i == 2 || i == 4) System.out.println(i + ":" + " is an even index) System.out.println("i: " + i); i++;

  • EX 1) Determine the outcome of the following code fragment without writing and running the program....

    EX 1) Determine the outcome of the following code fragment without writing and running the program. int num = 0, max = 20; while (num <= max) {     System.out.println(num);     num += 4; } EX 2) Write a code fragment that reads and prints integer values entered by user until a particular sentinel value (stored in constant SENTINEL) is entered. Do not print the sentinel value.                 Ex 3)  Write a method called averageLargestTwo  that accepts three int parameters  and returns the average...

  • Question 31 -Given the following code fragment, what value is contained in myArr[O]? const int ARRAYSIZE...

    Question 31 -Given the following code fragment, what value is contained in myArr[O]? const int ARRAYSIZE 3 double() myArr new double [ARRAYSIZE] myArr [0]1.1 myArr [1]2.2; myArr [2] myArr [0] myArr[1 O3.3 2.2 O 1.1 0 Question 32 - Given the following code fragment, what is displayed in IblResult? const int ARRAYSIZE 3 double(] myArr - new double [ARRAYSIZE] myArr [0] - 1.1 myArr [1] 2.2 lblResult.Text - Convert.Tostring (myArr (01) 3.3 O 2.2 1.1 0 Question 33 - Given...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT