0

Hello everyone, I am developing an application which makes use of abstract classes.

I am trying to create a switch statement, which I have placed in the abstract class as all the subclasses can use this.

I would like to refer back to this statement in a scanner which is located in another class, so I can use the input (e.g., 1, 2, 3) to produce a value which can later be added to another value in the scanner.

I have this so far, the first is in an abstract class.

public double chooseScore (int score) {

        switch (score) {

            case 1: return 0.35;

            case 2: return 0.48;

            case 3: return 0.62;

            default: return 0.00;

Then in another class the scanner, which does not seem to be finding the int score.

public class gradeTester
{
        public static void main (String [] args){
        Scanner in = new Scanner(System.in);
{

 int chooseGrade;

 System.out.print("Choose Grade "); 
        
 chooseGrade = in.nextInt();

system.out.println("Your grade is: + Grade);

Can anyone help me back on the right track, thanks!

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by ~s.o.s~
0

Your question isn't very clear, which `score` are you talking about? BTW, you can't access instance variables like `chooseGrade` from within `main` since it's a `static` method. Also, post complete class definitions to get better responses/suggestions.

Edited by ~s.o.s~: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.