Rewrite each of the fragments using nested if statement


Solve the following problems(a,b,c).

3. Rewrite each of the following fragments using nested if statements without compound conditions.

a. If (( rate = = 1) && (sum > 1000))
{
x = x + 1;
}
else if ((rate == 1 ) && (sum <= 1000))
{
x = x + 2;
}
else if ((rate == 2) && (sum > 1000))
{
x = x + 3;
}
else if ((rate ==2) && (sum <= 1000))
{
x = x + 5;
}

b. If (((a > 0) && (b > 0)) || (c > 0))
{
System.out.println(" Option one");
}
else
{
System.out.println("Option two");
}

c. If ((a > 0) && (b > 0))
{
System.out.println("Both Positive");
}
else
{
System.out.println ("Some Negative");

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Rewrite each of the fragments using nested if statement
Reference No:- TGS0136072

Expected delivery within 24 Hours