What is the printed by the following program public class Pr

What is the printed by the following program? public class PrintWithNumbers {public static void main(String[] args) {double x=4, Y=3, z=5, t=4; x = y + 5; System.out.println(\"l: x = \"+x); x = t+x*y; System.out.println(\"2: x = \"+x); x = Math.pow(y-l, t-2); System.out.println(\"3: x = \"+x); x = Math. squareroot (z+t); System.out.println(\"4: x = *\"+x); x = mystery(y, z); System.out.println(\"5: x = \"+x); x = mystery(z, y); System.out.println(\"6: x = \"+x); x = mystery(6, mystery(5, 4)); System.out.println(\"7: x = \"+x); x = 12 % 5; System.out.println (\"8: x = \"+x);} public static double mystery(double x, double y) {if (x

Solution

import java.util.*;
import java.lang.*;
import java.io.*;


class Ideone
{
   public static void main (String[] args) throws java.lang.Exception
   {
   double x=4,y=3,z=5,t=4;
   x=y+z; //3+5 =8
   System.out.println(\"1:x= \"+x);
   x= t+x*y; // 4+8*3 =28
   System.out.println(\"2:x= \"+x);
   x=Math.pow(y-1,t-2); //pow(2,2) = 4
   System.out.println(\"3:x= \"+x);
   x=Math.sqrt(z+t); //sqrt(5+4) = sqrt(9) =3
   System.out.println(\"4:x= \"+x);
   x=mystery(y,z); //mystery(3,5) =5
   System.out.println(\"5:x= \"+x);
   x=mystery(z,y); //mystery(5,3) =5
   System.out.println(\"6:x= \"+x);   
   x= mystery(6,mystery(5,4)); //mystery(6,mystery(5,4)) = mystery(6,5) =6
   System.out.println(\"7:x= \"+x);
   x = 12 % 5; // x=2 ,remainder
   System.out.println(\"8:x= \"+x);
  
   }
   public static double mystery(double x,double y)
   {
   if(x<y)
   return y;
   else
   return x;
   }
}

output:

Success time: 0.03 memory: 712192 signal:0

 What is the printed by the following program? public class PrintWithNumbers {public static void main(String[] args) {double x=4, Y=3, z=5, t=4; x = y + 5; Syst

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site