1import java.util.Scanner;
2public class StudentMarks {
3 Scanner scan1 = new Scanner(System.in);
4 private double math;
5 private double science;
6 private double english;
7 public StudentMarks(double math, double science, double english) {
8 this.math = math;
9 this.science = science;
10 this.english = english;
11 }
12 public static boolean wasPromroted(StudentMarks marks) {
13 if(marks.math>=85 && marks.science>=75 && marks.english>=65)
14 return true;
15 return false;
16 }
17 public static void main(String args[]) {
18 Scanner sc = new Scanner(System.in);
19 System.out.println("Enter your math score: ");
20 double math = sc.nextDouble();
21 System.out.println("Enter your science score: ");
22 double science = sc.nextDouble();
23 System.out.println("Enter your english score: ");
24 double english = sc.nextDouble();
25 StudentMarks marks = new StudentMarks(math, science, english);
26 boolean bool = wasPromroted(marks);
27 if(bool) {
28 System.out.println("Congratulations you've got promoted");
29 } else {
30 System.out.println("Sorry try again");
31 }
32 }
33}
1StudentMarks.java:16: error: non-static variable math cannot be referenced from a static context
2 if(math>=85 && science>=75 && english>=65)
3^
4StudentMarks.java:16: error: non-static variable science cannot be referenced from a static context
5 if(math>=85 && science>=75 && english>=65)
6^
7StudentMarks.java:16: error: non-static variable english cannot be referenced from a static context
8 if(math>=85 && science>=75 && english>=65)
9^
103 errors
1import java.util.Scanner;
2public class StudentMarks {
3 Scanner scan1 = new Scanner(System.in);
4 private double math;
5 private double science;
6 private double english;
7 public StudentMarks(double math, double science, double english) {
8 this.math = math;
9 this.science = science;
10 this.english = english;
11 }
12 public static boolean wasPromroted(StudentMarks marks) {
13 if(math>=85 && science>=75 && english>=65) {
14 return true;
15 }
16 return false;
17 }
18 public static void main(String args[]) {
19 Scanner sc = new Scanner(System.in);
20 System.out.println("Enter your math score: ");
21 double math = sc.nextDouble();
22 System.out.println("Enter your science score: ");
23 double science = sc.nextDouble();
24 System.out.println("Enter your english score: ");
25 double english = sc.nextDouble();
26 StudentMarks marks = new StudentMarks(math, science, english);
27 boolean bool = wasPromroted(marks);
28 if(bool) {
29 System.out.println("Congratulations you've got promoted");
30 } else {
31 System.out.println("Sorry try again");
32 }
33 }
34}