import java.util.Scanner;
public class Checker
{
public static void main(String[] args)
{
int number;
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get a number from the user.
System.out.print("Enter a number in the range of 1 through 100: ");
number = keyboard.nextInt();
while (number<1 || number >100)
{
System.out.print("Invalid input. Enter a number in the range " +
"of 1 through 100: ");
number = keyboard.nextInt();
}
}
}
public class LoopConversion
{
public static void main(String[] args)
{
//convert to for loop
for (int count=0; count < 5; count++)
{
System.out.println("count is " + count);
}
}
}
for (int i=0; i<5; i++){
System.out.println(i);
int i<5}
int i = 0;
while (i < 5){
System.out.println(i);
i = i+1;
}
import java.util.Scanner;
import java.lang.Math;
Scanner number = new Scanner(System.in);
float number_float = Integer.parseInt(number.nextLine()); // read user input
System.out.println(number_float);
double random = Math.random() * 10;
//int random_int = float.parseInt(random.nextLine());
System.out.println(random);
public class Number{
public static void main(String[] args){
while (number_float != random){
if (number_float < random){
System.out.println("too low, try again");
Scanner number = new Scanner(System.in);
float number_float = Integer.parseInt(number.nextLine()); // read user input
System.out.println(number_float);
}
if (number_float > random){
System.out.println("too high, try again");
Scanner number = new Scanner(System.in);
float number_float = Integer.parseInt(number.nextLine()); // read user input
System.out.println(number_float);
}
}
System.out.println("congrats, you got it");
}
}
Number.main(null);