Java: Lang 错误 "ComSci" 无法解析为类型
Java: Lang error "ComSci" cant be resolved to a type
为我的学校做了一个简单的招生计划。但是收到错误-
线程“main”中的异常java.lang.Error:未解决的编译问题:
Comsci cannot be resolved to a type
at Add.main(Admission.java:104)
我已经多次尝试检查代码,但似乎没有发现任何问题。我对 java 有点陌生,但仍在学习。任何帮助将不胜感激。
这里是源码-
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");
}
}
}
对这个问题有什么建议吗??
您的大写字母打错了。 Line 104
应改为:
ComSci CS = new ComSci();
… 在 new Compsci
.
中更改为大写 S
为我的学校做了一个简单的招生计划。但是收到错误-
线程“main”中的异常java.lang.Error:未解决的编译问题:
Comsci cannot be resolved to a type
at Add.main(Admission.java:104)
我已经多次尝试检查代码,但似乎没有发现任何问题。我对 java 有点陌生,但仍在学习。任何帮助将不胜感激。
这里是源码-
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");
}
}
}
对这个问题有什么建议吗??
您的大写字母打错了。 Line 104
应改为:
ComSci CS = new ComSci();
… 在 new Compsci
.
S