Write java program by taking input as student name, roll number, marks of four subjects and section of student. Assuming that the exam is conducted for 100 marks. Find out the percentage and grade. Percentage Grade > = 80 to 100 Excellent > = 70 to = 60 to = 50 to, how did I got banned in just 2 warnings
Answers
import java.util.Scanner; // Importing java.util package public class StudentReport // Creating class
{
// The main function public static void main(String args[]) {
// Creating object of scanner class Scanner scr = new Scanner(System.in);
// Taking user input to accept the name of the student and storing it in string data type
");
System.out.print("Enter name of student:
String n = scr.nextLine();
// Taking user input to accept the class of student and storing it in int data type System.out.print("Enter class of student:
");
int c = scr.nextInt();
// Taking user input to accept the roll no. of student and storing it in int data type System.out.print("Enter roll number of
student: ");
int r = scr.nextInt();
// Taking user input to accept the marks in 1st subject and storing it in int data type System.out.print("Enter marks in 1st subject: ");
int m1 = scr.nextInt();
// Taking user input to accept the marks in 2nd subject and storing it in int data type
System.out.print("Enter marks in 2nd
subject: ");
int m2 = scr.nextInt();
// Taking user input to accept the marks in 3rd subject and storing it in int data type System.out.print("Enter marks in 3rd
subject: ");
int m3 = scr.nextInt();
// Taking user input to accept the marks in 4th subject and storing it in int data type
System.out.print("Enter marks in 4th
subject: ");
int m4 = scr.nextInt();
if (m1 + m2 + m3 + m4 <= 400) {
// Calculating percentage obtained by the student
double Percentage (m1 + m2 + m3 + = m4)/400.0 100.0;
// Stroring grade as string data type String grade;
if (Percentage >= 90) {
grade = "Excellent.";
}
else if (Percentage >= 70) { grade = "First Division.";
}
else if (Percentage >= 60) {
grade = "Second Division.";
}
else if (Percentage >= 50) {
grade = "Third Division.";
}
else {
grade "Fail."; =
}
System.out.println("");
// Displaying the name of student System.out.println("Student name: " +
n);
// Displaying the name of student System.out.println("Class: " + c);
// Displaying the name of student System.out.println("Roll number: " + r);
// Displaying the percentage obtained by the student
System.out.println("Percentage: " +
Percentage);
// Displaying the grade of student System.out.println("Grade: " + grade);
}
}
}
Output:
Enter name of student: Eldarion
Enter class of student: 12
Enter roll no of student: 5
Enter marks in 1st subject: 98
Enter marks in 2nd subject: 87
Enter marks in 3rd subject: 91
Enter marks in 4th subject: 89
Student name: Eldarion(write anyname, it is an example)
Class 12
Roll number: 5
Percentage: 91.25
Grade: Excellent.
hope it helps.
lucky if someone gets Warning before getting ban, my friends id was ban without any warning
Answer:
import java.util.Scanner;
public class KboatStudentGrades
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter name of student: ");
String n = in.nextLine();
System.out.print("Enter class of student: ");
int c = in.nextInt();
System.out.print("Enter roll no of student: ");
int r = in.nextInt();
System.out.print("Enter marks in 1st subject: ");
int m1 = in.nextInt();
System.out.print("Enter marks in 2nd subject: ");
int m2 = in.nextInt();
System.out.print("Enter marks in 3rd subject: ");
int m3 = in.nextInt();
System.out.print("Enter marks in 4th subject: ");
int m4 = in.nextInt();
System.out.print("Enter marks in 5th subject: ");
int m5 = in.nextInt();
int t = m1 + m2 + m3 + m4 + m5;
double p = t / 500.0 * 100.0;
String g = "";
if (p >= 90)
g = "A+";
else if (p >= 80)
g = "A";
else if (p >=70)
g = "B+";
else if (p >= 60)
g = "B";
else if (p >= 50)
g = "C";
else if (p >= 40)
g = "D";
else
g = "E";
System.out.println("Total Marks = " + t);
System.out.println("Percentage = " + p);
System.out.println("Grade = " + g);
}
}
Explanation:
hello XD
how are you ^_~
it's been a long time〜