mardi 21 juin 2016

How Do I Test For More Than One Letter In A Loop

Im Trying To Test If The User's Input Is More Than One Letter, If It Is Then Send Out A System.out.println statement.

My Assignments Instructions Are Below

use the System.out.println() method to tell the student to try again if they enter anything other than one letter for a grade;

Here Is The Code Im Using

import java.io.IOException;

import java.util.Scanner;

public class MyGradeLoops {

public static void main(String[] args) throws IOException {
    Scanner in = new Scanner(System.in);

    for (int x = 1; x <= 5; x++) {

        System.out.println("Please enter Your Class Grades");
        String A;
        char B;
        A = in.next();
        System.out.println("Thank You");
        if (**TRYING TO TEST FOR MORE THAN ONE LETTER**) {
            System.out.println("Only One Letter At A Time");
        }
    }

    System.out.println("Keep Up The Good Work");

}

}

Any Help Is Appreciated

Aucun commentaire:

Enregistrer un commentaire