Prepare a well-structured report for presenting your program documentations
The first program is for accepting user input and assigning it to a variable semester1 and semestr2 respectively then calculating the final grade by adding
the 2 inputs to get total.
import java.util.Scanner;
User input is made possible by having to import the scanner class in the beginning of the code.
for(i=0; i<2; i++) {
System.out.print("Enter Marks of Semester"+(i+1)+":");
marks[i] = scanner.nextInt();
weightage = weightage + marks[i];
}
This program also grades the student by use of if statement when a certain condition is met.
if(TotalWeightage>=50)
{
System.out.print("PASS");
}
else
{
System.out.print("FAIL");
} }
We have to compile the program fisrt using the javac command in terminal or cmd which compile our file student.java and creates a new file student.class which
is executable using the java command as illustrated in the snipe above.
The program for task 3 is for accepting user input and assigning it to a variable mark of semester1 and semestr2 respectively then calculating the student
total weightage of both semesters.
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
for(i=0; i<2; i++) {
System.out.print("Enter Marks of Semester"+(i+1)+":");
marks[i] = scanner.nextInt();
weightage = weightage + marks[i];
}
scanner.close();
//Calculating Total weightage(100%) = Semester1(50%) +Semester2(50%)
TotalWeightage= weightage; }
Sample Solution