0

** I'm facing a problem in inserting value for the variable that is used in IF condition
inp = s.nextLine(); **

import java.util.Scanner;
public class main {
    public static void main(String[] args) {              
        System.out.println("Enter the marks for 3 subjects");
        Scanner s = new Scanner(System.in);
        int a =s.nextInt();
        int b =s.nextInt();
        int c =s.nextInt();
        if(a>100 || b> 100 || c>100) {
            System.out.println("Enter value in range of 100");
        }
        else {
            System.out.println("marks for 1st Subjects: " + a);
            System.out.println("marks for 2nd Subjects: " + b);
            System.out.println("marks for 3rd Subjects: " + c);
        }
        System.out.println("Press * r * to get  obtained marks");
        String inp;
        inp = s.nextLine(); //issue here // need help :( 
        String res = "r" ;
        if (inp.equals(res)) { 
            int obtMarks = a+b+c;
            System.out.println(obtMarks);
        }
    }
}
Cashif
  • 1
  • 3

0 Answers0