0

I'm having some trouble with my loop here, I want the user to be able to add more info(the grade and credits) if they have more classes to add. I'm stuck and hoping someone can help. Thanks.

import java.util.*;

public class DoWhileDemo 
{
    public static void main(String[] args){
        String name;
        String add;
        double gradePoints = 0;
        double credits = 0;

        Scanner input = new Scanner(System.in);

        System.out.println("Enter Students Name: ");
        name = input.nextLine();
        do {
            System.out.println("Enter class credits: ");
            credits = input.nextDouble();
            System.out.println("Enter letter grade: ");
            gradePoints = input.nextDouble();
            System.out.println("Add another class? (Y/N) ");
            add = input.nextLine();
        } while (add == ("Y"));
    }
}
  • 8
    Don't compare strings with == : http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java – Suresh Atta Sep 29 '15 at 17:14
  • 1
    This question is combination of duplicates. Other one is [Skipping nextLine() after using next(), nextInt() or other nextFoo() methods](https://stackoverflow.com/questions/13102045/skipping-nextline-after-using-next-nextint-or-other-nextfoo-methods) – Pshemo Sep 29 '15 at 17:18

0 Answers0