0

As you can see ,that is simple java program where i ask user number of class they attend then by there percentage tell him they can sit in exam or not , but when i try to take input inside if statement that line skipped but code run without error

Scanner s = new Scanner(System.in);
    
    int   totalclass = 125 ;

    System.out.println("enter total Number of classes you Attend : ");

 float   attend = s.nextInt();

 float percentage = (attend/125 *100);

 if (percentage < 75){

 System.out.println("do have any medical cause Enter  yes(y) or no(n) : ");

why this line is not working, i want give input(string)

     String  str = s.nextLine();

but this skipped

     if(str.equalsIgnoreCase("y") ){

         System.out.println("Submited medical letter so we consider You to sit in Exam");

     }else{

         System.out.println("Your attendence is " + percentage + "% which is less then 75% ,you are not eligible for sit in Exam");

     }
 }else {
     System.out.println("You can sit in exam");
 }

0 Answers0