You are on page 1of 2

1.

package Final;
import java.util.*;

public class Main {

public static void main(String[] args) {


Scanner x = new Scanner(System.in);
System.out.print("Input Two Numbers: ");
int n1 = x.nextInt();
int n2 = x.nextInt();

int max = Math.max(n1, n2);


System.out.println(“Largerst Number” + max);
}

2. package Final;
import java.util.*;

public class Main {

public static void main(String[] args) {


Scanner x = new Scanner(System.in);
System.out.print("Please enter a word: ");
String word = x.nextLine();
System.out.println("Your word has " + word.length() + " characters.");
}

}
3. package Final;
import java.util.*;

public class Main {

public static void main(String[] args) {


Scanner x = new Scanner(System.in);

while (true)
{
System.out.print("Please enter a number: ");
String input = x.next();
if (!Character.isDigit(input.charAt(0)))
{
if (input.length() >= 2)
{
System.out.println("Please enter 1 character only");
System.out.println();
}
else
{
System.out.println("Oops! That's not a Digit");
System.out.println();
}
}
else
{
System.out.println("Thanks!");
System.out.println();
}
}
}

You might also like