Java Hyd Team
https://docs.google.com/spreadsheets/d/1qFO52EmuylPxnbAaJtqIqGgygXiHXA_0Qi6yhJQmec4/edit?miehl=jee-oqzj-wiw
sheet got deleted by mistake kindly share your mail id @stockkida
https://docs.google.com/spreadsheets/d/1j5O9_P7DbsqNLjv5s-DmYGvRey_GRwPLAOVpWXJ7s8Y/edit?usp=sharing click on this link to join the new sheet i will update by today night
public class Student { private int studentId; private String studentName; private int marks; private char grade; public Student() { // TODO Auto-generated constructor stub } public Student(int studentId, String studentName, int marks) { super(); this.studentId = studentId; this.studentName = studentName; this.marks = marks; calculateGrade(); } public String displayDetails() { return "Student [name=" + studentName + ", studentId=" + studentId + ", marks=" + marks + ", grade=" + grade + "]"; } private void calculateGrade() { if (marks <= 100 && marks >= 90) { grade = 'A'; } else if (marks <= 89 && marks >= 81) { grade = 'B'; } else if (marks <= 80 && marks >= 71) { grade = 'C'; } else if (marks <= 70 && marks >= 61) { grade = 'D'; } else if (marks <= 60 && marks >= 0) { grade = 'E'; } } }
public class Tester { public static void main(String[] args) { Student s1 = new Student(123, "John Smith", 95); System.out.println(s1.displayDetails()); } }
Output:
Student [name=John Smith, studentId=123, marks=95, grade=A]
public class Tester { public static void main(String[] args) { Student s1 = new Student(123, "John Smith", 95); System.out.println(s1.displayDetails()); } }
Output:
Student [name=John Smith, studentId=123, marks=95, grade=A]