int y = 3; boolean isGreen = true |
if (x < y)
{
System.out.println("x = " + x);
System.out.println("y = " + y);
}
System.out.println("Apple");
if (x == '2')
System.out.println("x = " + x);
System.out.println("y = " + y);
if (!isGreen)
System.out.println("banana");
System.out.println("grape");
if (x == y - 1)
{
int Temp = y;
y = x;
x = Temp;
System.out.println("x = " + x);
System.out.println("y = " + y);
}
if ((x < y) && ( y != 10))
{
int sum = x + y;
System.out.println("x = " + x);
System.out.println("y = " + y);
System.out.println("sum = " + sum);
}
else
{
System.out.println("x = " + x);
System.out.println("y = " + y);
}
if ((x > y) || ( x - y < 0))
{
x += 1;
y -= 1;
System.out.println("x = " + x);
System.out.println("y = " + y);
}
if (x > y)
x += 1;
else
y -= 1;
System.out.println("x = " + x);
System.out.println("y = " + y);
if (x < y)
x += 1;
System.out.println("x = " + x);
System.out.println("y = " + y);
else
y -= 1;
if (x = 3)
x += 1;
else
y -= 1;
System.out.println("x = " + x);
System.out.println("y = " + y);
if (x == 3)
x += 1;
else if (x == 4)
y -= 1;
else if (x == 5)
y -= 1;
System.out.println("x = " + x);
System.out.println("y = " + y);
if (!(x > y))
x += 1;
else
{
y -= 1;
System.out.println("x = " + x);
System.out.println("y = " + y);
}
if ((x > y)) || ( x * y < 0))
{
x +=1;
y -= 1;
System.out.println("x = " + x);
System.out.println("y = " + y);
}
System.out.println("x = " + x);
System.out.println("y = " + y);
if (x < y)
{
x +=1;
y -= 1;
System.out.println("x = " + x);
System.out.println("y = " + y);
}
System.out.println("x = " + x);
System.out.println("y = " + y);
|
if (x > Day.WED && x < Day.THUR)
cout << "Today is not Sunday." << endl;
else
cout << "Today is going to be a hard day." << endl;
if (x % y == 0)
System.out.println ("x is divisible by y.");
System.out.println ("x is NOT divisible by y.");
NOTE: Rewrite this segment of code using proper indentation.
Write a statement that displays "Out of Range" if int number is negative or is
greater than 100.
Write an efficient if statement to assign number the value:
8 if x is less than or equal to 1.5,
7 if 1.5 < x < 2.5,
6 if otherwise.
Write Java code to do the following:
Ask the user for the values of x, y, and code (all ints)
if code is a 1, calculate and display
the sum of x and y. Otherwise output the difference of x and y.
If double a is strictly between 0 and 5, set int b equal to 1/a;
otherwise set b equal to a.
Create an program that allows the user to input an age in years and then displays one of the following (or similar) responses:
Age Range | Response | |
0 < ageinput < 6 | You are considered a young minor. But, in approximately ___ year(s) you will be able to attend school! | |
6 <= ageinput < 16 | In approximately ___ year(s) you will be able to drive! | |
16 <= ageinput < 21 | In approximately ___ year(s) you will be of legal drinking age. | |
21 <= ageinput < 35 | You are of legal drinking age. In approximately ___ year(s) you will be able to run for president! | |
35 <= ageinput < 120 | You are old enough to run for U.S. President. | |
ageinput >= 120 | You are too enough to run for U.S. President. |