Write this code shown here as pseudocode in Java Make sure y

Write this code, shown here as pseudocode, in Java. Make sure you have no errors of syntax or logic. Save and run it to make sure. Do this twice: Once using if/else type statements Once using ?: type statements (this will be tricky, but it\'s doable) set a = 8, set c = 1 while (c

Solution

1) Using if else statement

class Condition{

public static void main(String args[])
{
int a= 8, c=1;
while(c<15)
{
if(a<=10)
{a=a+2;}
else
{a=a-10;}
System.out.println(\"Value of a\"+a);
c=c+1;
}

}

}

//Using ?: statement

class Condition{

public static void main(String args[])
{
int a= 8, c=1;
while(c<15)
{(a<=10) ? (a=a+2) : (a=a-10);

System.out.println(\"Value of a\"+a);
c=c+1;
}

}

2) class Sum{

int x,y,sum,z;

public Sum(int a , int b)

{x= a;

y=b;

}

public static sumCheck()

{

sum = x+y;

if(sum==3)

{z= sum;}

else

{z= 0;}

}

public static void main(String args[])

{

Sum first = new Sum(1,2);

Sum second = new Sum(2,2);

}

}

 Write this code, shown here as pseudocode, in Java. Make sure you have no errors of syntax or logic. Save and run it to make sure. Do this twice: Once using if
 Write this code, shown here as pseudocode, in Java. Make sure you have no errors of syntax or logic. Save and run it to make sure. Do this twice: Once using if

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site