fork download
  1. import java.util.Scanner;
  2.  
  3. //Assignment1 class
  4. public class Assignment1 {
  5.  
  6. //main method where execution starts
  7. public static void main(String[] args)
  8. {
  9. //local variables
  10. final int N = 10;
  11. int lowestMark = 100, highestMark = 0, averageMark = 0, numberPassed = 0, numberFailed = 0, totalMark = 0, v = 0;
  12.  
  13. //Grader class object
  14. Grader graderObject = new Grader();
  15.  
  16. //Scanner class object to take input from user
  17. Scanner sc = new Scanner(System.in);
  18.  
  19. //print welcome message
  20. System.out.println("***** Welcome to Calculate the grade *****");
  21.  
  22. //loop to input marks, calculate and display grade, calculate summary values
  23. for(int i=0; i<N; i++)
  24. {
  25. //input mark
  26. System.out.print("\nMark for student " + (i+1) + ": ");
  27. int mark = sc.nextInt();
  28. do{
  29.  
  30. grade=s.nextLine();
  31. v=Integer.parseInt(grade);
  32. if(v<0 || v>100)
  33. {
  34. System.out.println("Enter Valid Mark");
  35. }
  36. }while(v<0 || v>100);
  37.  
  38.  
  39.  
  40. grade=g.grade(v)+"";
  41. result=g.pass(v);
  42.  
  43. //calculate grade using grade method from Grader class
  44. System.out.print("Grade for student " + (i+1) + ": " + graderObject.grade(mark));
  45.  
  46. //calculate total mark of all students
  47. totalMark = totalMark + mark;
  48.  
  49. //if statement for calculate lowest mark
  50. if(lowestMark > mark)
  51. lowestMark = mark;
  52.  
  53. //if statement for calculate highest mark
  54. if(highestMark < mark)
  55. highestMark = mark;
  56.  
  57. //if-else statement for count number of passed and failed students
  58. if(graderObject.pass(mark))
  59. numberPassed = numberPassed + 1;
  60. else
  61. numberFailed = numberFailed + 1;
  62. }
  63.  
  64. //calculate average mark
  65. averageMark = totalMark / N;
  66.  
  67. //generate and display summary
  68. System.out.println("\n\nSummary");
  69. System.out.println("********");
  70. System.out.println("Lowest mark: " + lowestMark);
  71. System.out.println("Highest mark: " + highestMark);
  72. System.out.println("Average mark: " + averageMark);
  73. System.out.println("Number passed: " + numberPassed);
  74. System.out.println("Number failed: " + numberFailed);
  75.  
  76. // display exit message
  77. System.out.println("\nThank you!!!!!! Exit from program.......");
  78. }
  79. }
  80.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:4: error: class Assignment1 is public, should be declared in a file named Assignment1.java
public class Assignment1  {
       ^
Main.java:14: error: cannot find symbol
		Grader graderObject = new Grader();
		^
  symbol:   class Grader
  location: class Assignment1
Main.java:14: error: cannot find symbol
		Grader graderObject = new Grader();
		                          ^
  symbol:   class Grader
  location: class Assignment1
Main.java:30: error: cannot find symbol
				grade=s.nextLine();
				^
  symbol:   variable grade
  location: class Assignment1
Main.java:30: error: cannot find symbol
				grade=s.nextLine();
				      ^
  symbol:   variable s
  location: class Assignment1
Main.java:31: error: cannot find symbol
				v=Integer.parseInt(grade);
				                   ^
  symbol:   variable grade
  location: class Assignment1
Main.java:40: error: cannot find symbol
			    grade=g.grade(v)+"";
			    ^
  symbol:   variable grade
  location: class Assignment1
Main.java:40: error: cannot find symbol
			    grade=g.grade(v)+"";
			          ^
  symbol:   variable g
  location: class Assignment1
Main.java:41: error: cannot find symbol
			    result=g.pass(v);
			    ^
  symbol:   variable result
  location: class Assignment1
Main.java:41: error: cannot find symbol
			    result=g.pass(v);
			           ^
  symbol:   variable g
  location: class Assignment1
10 errors
stdout

Standard output is empty