Solved

class grades

Posted on 2009-05-16
2
198 Views
Last Modified: 2013-11-23
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

0
Comment
Question by:USN4x4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
climbgunks earned 500 total points
ID: 24403630

It's a class assignment.  I can give general help only.

Basically you need to create two new getGradeFunctions().  The first will have an addition Blevel argument, and the second will have both an additional Blevel and Clevel argument.   Replace the B cutoff (8) with the Blevel argument and simliarly for C (70 -> Clevel).

Otherwise, the code is the same as shown in the last function above.

0
 
LVL 3

Expert Comment

by:hazgoduk
ID: 24405917
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

0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate example using maven 12 109
Notify sent to other threads in Java 9 54
junit as external jar or library 7 58
DTD and JAVA versions 1 57
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question