0

I'm making a simple program in java for school where you input the name and score for 3 students and then it returns the grade however when it loops the first time it no longer asks for the grade. my output ends up looking like this
https://imgur.com/a/wsIryKh

this is the code

                while (i <3)
    {
        
        System.out.println("please enter the students name:    ");
            name=sc.nextLine();
        System.out.println("please enter the students grade:    ");     
            score=sc.nextInt();
        
        if(score>=80)       
        {   
            grade='A';
        }
        else if(score>=70 && score<80)
        {
            grade='B';
        }
        else if(score>=50 && score<70)
        {
            grade='C';                  
        }
        else {
            grade='F';
        }

        System.out.println(name + " got a score of " + score + " and a grade of " + grade); 
        System.out.println("================================================================");//separate each output so its easier to read
        i++;
    }   
blu
  • 19
  • 1

0 Answers0