Home > Back-end >  Don't know where there is a problem.. A freshman quickly collapsed
Don't know where there is a problem.. A freshman quickly collapsed

Time:10-02

Homework is to make the written in the Java subjects and 100 students randomly generated a total score of form but the outcome of the goose is the worst mistake is also don't know what wrong
Really good hard top online class??

Package Javafromthescatching;
Import the Java. Util. ArrayList;
Import the Java. Util. Random;

Public class Javafromthescatching {static ArrayList Records=new ArrayList (); Public static void main (String arg []) {int number=0, k=0, m=0, e=0, s=0; Int total; for(int i=0; I<100; I++) {number=I + 1; K=new Random (). NextInt (100) + 1; M=new Random (). NextInt (100) + 1; E=new Random (). NextInt (100) + 1; S=new Random (). NextInt (100) + 1; Total=k + m + e + s; Record record1=new Record (number, k, m, e, s); Record1. Sum=total; Records. The add (record1); } System. Out. Println (" ID Number/Korean Math English Science Sum \ t "); for(int i=0; I<100; I++) {Record record2=records. The get (I); Number=record2. GetIdNumber (); K=record2. Korean; M=record2. Math; E=record2. English; S=record2. Science; Total=record2. Sum; System. Out. Println (" "+ number +" \ t \ \ t t + k + "t \ \ t + m +" \ t "\ t" + e + "t \ \ t + s +" \ t "\ t" + total + "\ t"); }}
}

CodePudding user response:

Can't find the Record this class, guide packages or create inner class and class names don't pick up the Object and core JDK class libraries

CodePudding user response:

refer to the original poster weixin_46704732 response:
job is to make the written in the Java subjects and 100 students randomly generated a total score of form but the outcome of the goose is full of mistakes the worst is still don't know what wrong
Really good hard top online class??


Record class does not import, an import

CodePudding user response:

Give you built an inner class Record
 
import java.util.ArrayList;
Import the Java. Util. Random;

Public class Record {

Private int IdNumber;
Private int Korean;
Private int Math;
Private int English;
Private int Science;
Private int Sum;

Record (int IdNumber, int Korean, int Math, int English, int Science) {
Enclosing IdNumber=IdNumber;
This. Korean=Korean;
This. Math=Math;
This. English=English;
This. Science=Science;
}

Public int getIdNumber () {
Return IdNumber;
}

Public void setIdNumber (int idNumber) {
IdNumber=IdNumber;
}

Public int getKorean () {
Return the Korean;
}

Public void setKorean (int Korean) {
Korean=Korean;
}

Public int getMath () {
Return Math;
}

Public void setMath (int) math {
Math=Math;
}

Public int getEnglish () {
Return English;
}

Public void setEnglish (int). English {
English=English;
}

Public int getScience () {
Return Science;
}

Public void setScience (int science) {
Science=Science;
}

Public int getSum () {
Return the Sum.
}

Public void setSum (int sum) {
Sum=Sum;
}



The static ArrayList Records=new ArrayList ();

Public static void main (String arg []) {
Int number=0, k=0, m=0, e=0, s=0;
Int total;
for (int i=0; I & lt; 100; I++) {
Number=I + 1;
K=new Random (). NextInt (100) + 1;
M=new Random (). NextInt (100) + 1;
E=new Random (). NextInt (100) + 1;
S=new Random (). NextInt (100) + 1;
Total=k + m + e + s;
Record record1=new Record (number, k, m, e, s);
Record1. SetSum (total);
Records. The add (record1);
}
System. The out. Println (" ID Number/Korean Math English Science Sum \ t ");
for (int i=0; I & lt; 100; I++) {
Record record2=records. The get (I);
Number=record2. GetIdNumber ();
K=record2. GetKorean ();
M=record2 getMath ();
E=record2. GetEnglish ();
S=record2. GetScience ();
Total=record2. GetSum ();
System. Out.println (
"" + number +" \ t \ \ t t "" t \ \ t + +, k + m +" t \ \ t + e + "\ t" \ t "+ s +" t \ \ t + total "+" \ t ");
}
}
}



Something like this:


Don't align yourself to it

CodePudding user response:

reference 1/f, tears panda head response:
can't find the Record this class, guide packages or create inner class and class names don't pick up the Object and core JDK class libraries conflict
ok?? Thank you for your reply to me

CodePudding user response:

reference 3 floor programming jianghu reply:
give you built an inner class Record
 
import java.util.ArrayList;
Import the Java. Util. Random;

Public class Record {

Private int IdNumber;
Private int Korean;
Private int Math;
Private int English;
Private int Science;
Private int Sum;

Record (int IdNumber, int Korean, int Math, int English, int Science) {
Enclosing IdNumber=IdNumber;
This. Korean=Korean;
This. Math=Math;
This. English=English;
This. Science=Science;
}

Public int getIdNumber () {
Return IdNumber;
}

Public void setIdNumber (int idNumber) {
IdNumber=IdNumber;
}

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related