Link to home
Start Free TrialLog in
Avatar of USN4x4
USN4x4

asked on

class grades

assignment is to write two more overloaded methods to change the cut
off level for B to be 75; and change cut off level for C to be 65.

Thus, your program will have four overloaded methods.

First method: takes 3 arguments. This is already done.

Second overloaded method: takes four arguments: three scores and new cut off
score for A (85). This is already done.

Third overloaded method: takes five arguments: three scores, new cut off score
for A (85), and new cut off score for B (75). You need to write this.

Fourth overloaded method: takes six arguments: three scors, new cut off
score for A (85), new cut off score for B (75), and new cut off score for C
(65). You have to write this.

import java.util.*;
class Grades
{
public static void main(String args[]){
int score1, score2, score3;
System.out.println("Input three exam score");
Scanner input = new Scanner(System.in);
score1 = input.nextInt();
score2 = input.nextInt();
score3 = input.nextInt();
getGrade(score1,score2,score3);
getGrade(score1,score2,score3,85);
}
//Invokes this method if the number of arguments is 3
static void getGrade(int s1, int s2, int s3){
int sum = s1+s2+s3;
int average =(int)(sum/3);
System.out.println("Grade using the original scheme");
if(average >= 90) System.out.println("Grade is A");
else if(average >= 80) System.out.println("Grade is B");
else if(average >= 70) System.out.println("Grade is C");
else if(average >= 60) System.out.println("Grade is D");
else System.out.println("Grade is F");
}
//Invokes this method if the number of arguments is 4
static void getGrade(int s1, int s2, int s3, int Alevel){
int sum = s1+s2+s3;
int average =(int)(sum/3);
System.out.println("Grade using the new scheme - Cut off for A is 85");
if(average >= Alevel) System.out.println("Grade is A");
else if(average >= 80) System.out.println("Grade is B");
else if(average >= 70) System.out.println("Grade is C");
else if(average >= 60) System.out.println("Grade is D");
else System.out.println("Grade is F");
}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Todd Mummert
Todd Mummert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Overloading just means the same function or contructor with different arguements, for example
public overloadedConstructor()
{
}
 
public overloadedConstructor(int i)
{
}
 
public overloadedConstructor(int i, String s)
{
}

Open in new window