I have a program to enter the student's name, gender, grade, and rank Here is my code:
public class Exercise_W28 { String name; String Sex; int Score; String ratting;
public Exercise_W28(String name, String Sex, int Score, String ratting) { this.name = name; this.Sex = Sex; this.Score = Score; this.ratting = ratting; } public String getName() { return name; } public String getSex() { return Sex; } public int getScore() { return Score; } public String getratting() { return ratting; } public String toString() { return("Name: "+ this.getName()+ ".\nSex: "+ this.getSex()+ ".\nScore: "+ this.getScore()+ ".\nRank: "+ this.getratting()+"." ); } public static void main(String[] args) { Exercise_W28 std = new Exercise_W28("Jullien","male", 9, "RankA"); System.out.println(std.toString()); } }
Now I want to not put the rank in, but based on the score to determine the rank 1~5 : rankC, 5~7: rankD, 8~10: rankA. I just learned about classes in java and I don't know how to handle it