Home > Back-end >  But there are no mistakes, not run a result, the answer
But there are no mistakes, not run a result, the answer

Time:10-18

Package com. LAN;

import java.util.Scanner;

/* public void test () {
Student s_1=new Student (" ice cream ", 21, "female", "school");
S_1. Chengjiluru ();
S_1. Pingjun ();
}
*/
The class Person {
private String name;
Private int the age;
Private String sex;
Public Person () {
}
Public Person (String name, int the age, the String sex) {
this.name=name;
this.age=age;
This. Sex=sex;
}
}
The class Student extends the Person {
Private double [] score=new double [4].
Public Student (String name, int the age, the String sex, String school) {
Super (name, age, sex);
}
Public void chengjiluru () {
Scanner scan=new Scanner (System. In);
System. The out. Println (" please enter grades respectively: name, age, sex, school ");
for(int i=0; i<4. I++) {
Score. [I]=scan nextDouble ();
}
}
Public void pingjun () {
Double sum=0;
for(int i=0; i<4. I++) {
The sum +=score [I];
}
Double jun=sum/4;
System. The out. Println (" grade point average is: "+ jun);
}}
Public class xuegao {
Public static void main (String [] args) {

}
}

CodePudding user response:

Program from a total of class's main () method into execution, you didn't write anything in the main () method, without any definite result output

CodePudding user response:

Right on the ground floor, you have to realize what function, at least also need new an object in the main method, method is called by "object." ah,
  • Related