Search code examples
javaclassmethodsprogram-entry-point

Java: Lang error "ComSci" cant be resolved to a type


Made a simple admission program for my school. But receiving error-

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

Comsci cannot be resolved to a type

    at Add.main(Admission.java:104)

I have tried reviewing the code numerous times but cant seem to notice anything off. Im kinda new to java and still leaning. any help would be much appreciated.

Here is the source code-

import java.util.*;
import java.io.*;

class Admission{
    String name = new String();
    float phy, che, mat, cs, eng, hin;
    float tot, perc;

    void enter(){
        Scanner ent = new Scanner(System.in);

        System.out.println("\nEnter your name:");
        name = ent.nextLine();

        System.out.println("\nEnter your 12th Std marks (x/100)");
        System.out.print("Physics- ");
        phy= ent.nextInt();
        System.out.print("\nChemistry- ");
        che= ent.nextInt();
        System.out.print("\nMaths- ");
        mat= ent.nextInt();
        System.out.print("\nComputers- ");
        cs= ent.nextInt();
        System.out.print("\nEnglish- ");
        eng= ent.nextInt();
        System.out.print("\nHindi- ");
        hin= ent.nextInt();
    }
}

class ComSci extends Admission{
    void calculate(){
        tot=phy+mat+che+cs+eng+hin;
        perc=(tot/600)*100;

        System.out.println("Your total marks= "+tot +"/600");
        System.out.println("Your percentage= "+perc +"%");

        if(perc>60){
            System.out.println("You are eligible for admission. Please contact Department ffice :)");
        }else{
            System.out.println("You are not eligible. Percentage needed: 60%");
        }
    }
}

class VisCom extends Admission{
    void calculate(){
        tot=phy+mat+che+cs+eng+hin;
        perc=(tot/600)*100;

        System.out.println("Your total marks= "+tot +"/600");
        System.out.println("Your percentage= "+perc +"%");

        if(perc>50){
            System.out.println("You are eligible for admission. Please contact Department ffice :)");
        }else{
            System.out.println("You are not eligible. Percentage needed: 50%");
        }
    }
}

class FoodSci extends Admission{
    void calculate(){
        tot=phy+mat+che+cs+eng+hin;
        perc=(tot/600)*100;

        System.out.println("Your total marks= "+tot +"/600");
        System.out.println("Your percentage= "+perc +"%");

        if(perc>40){
            System.out.println("You are eligible for admission. Please contact Department ffice :)");
        }else{
            System.out.println("You are not eligible. Percentage needed: 40%");
        }
    }
}

class Add{
    public static void main (String[] args){
       
        int choice;

        Scanner ch = new Scanner(System.in);
                                    

        System.out.println("Which course do want to enrol in?");
        System.out.println("1)CS 2)Viscom 3)FSPM");
        choice=ch.nextInt();

        switch(choice){

            case 1:
                ComSci CS = new Comsci();
                CS.enter();
                CS.calculate();
                break;

            case 2:
                VisCom VC = new VisCom();
                VC.enter();
                VC.calculate();
                break;

            case 3:
                FoodSci FSPM = new FoodSci();
                FSPM.enter();
                FSPM.calculate();
                break;

            default:
                System.out.println("Wrong choice entyer again");
            

        }

    }
}

Any suggestions for this problem??


Solution

  • You've made a simple typo with the capitalisation. Line 104 should read:

    ComSci CS = new ComSci();
    

    … changing to uppercase S in new Compsci.