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!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.