Home > Back-end >  The code runs fail to find or unable to load the main class
The code runs fail to find or unable to load the main class

Time:09-18

Package Hongbao.
Import the Java. Util. *;/class - parent
The class User {
private String username;
Private double leftMoney;
Public User () {

}
Public User (String username, double leftMoney) {
Enclosing the username=username;
Enclosing leftMoney=leftMoney;
}
Public String getusername () {
Return the username.
}
Public void setusername (String username) {
Enclosing the username=username;
}
Public double getleftMoney () {
Return leftMoney;
}
Public void setleftMoney (double leftMoney) {
Enclosing leftMoney=leftMoney;
}
Public void show () {
System. The out. Println (" user name "+ username +", the balance is: "+ leftMoney +" RMB ");
}
}


Class QunZhu extends the User {//group manager - subclass
Public QunZhu () {

}
Public QunZhu (String username, double leftMoney) {
Super (username, leftMoney);
}
Public ArrayList Send (int Money, int count) {
Double leftMoney=getleftMoney ();
If (Money> LeftMoney) {
return null;
}
SetleftMoney (leftMoney=Money);
ArrayList List=new ArrayList<> (a);
Money=Money * 100;
Int m=Money/count;
Int l=Money % count;
for(int i=0; IList. The add (m/100.0);
If (l==0) {
List. The add (m/100.0);
} else {
List. The add (m + 1)/(100.0);
}
return list;
}
return list;
}
A class Member extends the User {//define members
Public Member () {

}
Public Member (String username, double leftMoney) {
Super (username, leftMoney);
}
Public void openHongbao (ArrayList The list) {
The Random r=new Random ();
Int index=r.n extInt (list. The size ());
Double money=list. Remove (index);
SetleftMoney (money);
}
}
}
Public class Test {
Private static Scanner sc;

Public static void main (String args) {
QunZhu qz=new QunZhu (" group manager ", 200);
Sc=new Scanner (System. In);
System. The out. Println (" please enter the amount: ");
Int money=sc. NextInt ();
System. The out. Println (" please enter the number of red envelopes ");
Int count=sc. NextInt ();
ArrayList Sendlist=qz. Send (money, count);
If (sendlist==null) {
System. Out.println (" insufficient... ");
return;
}
Member m1=new Member ();
Member m2=new Member ();
Member m3=new Member ();
Member m4=new Member ();
Member m5=new Member ();
Member m6=new Member ();
Member m6=new Member ();
Member m7=new Member ();
Member m8=new Member ();
Member m9=new Member ();
Member m10=new Member ();

M1. OpenHongbao (sendlist);
M2. OpenHongbao (sendlist);
M3. OpenHongbao (sendlist);
The m4. OpenHongbao (sendlist);
The m5. OpenHongbao (sendlist);
M6. OpenHongbao (sendlist);
M7. OpenHongbao (sendlist);
M8. OpenHongbao (sendlist);
M9. OpenHongbao (sendlist);
M10. OpenHongbao (sendlist);

Qz. The show ();
M1. The show ();
M2. The show ();
M3. The show ();
The m4. The show ();
The m5. The show ();
M6. The show ();
M7. The show ();
M8. The show ();
M9. The show ();
M10. The show ();
}
}
Help me to look at the error

CodePudding user response:

Don't take the suffix Java hongbao directly

CodePudding user response:

An IDEA

CodePudding user response:

With the main function of the name of the class should be consistent with the file name

CodePudding user response:

Should be unable to load
  • Related