
Patrick B. answered 04/06/21
Math and computer tutor/teacher
1) sequential ...
statements are execute in order, one after another
selection: different blocks of code are executed (and other blocks
are skipped) based on the value of the variable
3)
Repetition (a.k.a Iteration, a.k.a LOOPING)
executes a block of code a specified number of
times OR while / until a condition holds true
/*******************************************************************
Prompt the user to input an integer value and then
outputs if the integer is positive, negative or zero;
Continues until the user chooses to quit
********************************************************************/
import java.util.Scanner;
class Akisha
{
public void Go()
{
Scanner scanner = new Scanner(System.in); //keyboard input
int yesNo=1;
while (yesNo==1)
{
System.out.print(" Please input the integer value:>");
int x = scanner.nextInt();
if (x>0) // output based on value
{
System.out.println(x + " is positive ");
}
else if (x<0)
{
System.out.println( x + " is negative ");
}
else
{
System.out.println("x = 0 ");
}
for (int iLoop=0; iLoop<25; iLoop++)
{
System.out.print("-");
} //for loop
do
{
System.out.print("\n\n Again ??? 1=YES 0=NO :>");
yesNo=scanner.nextInt();
}
while ((yesNo!=0) && (yesNo!=1)); //do-while loop
} //while
}
public static void main(String args[])
{
Akisha x = new Akisha();
x.Go();
}
}