본문 바로가기

콩's EDUCATION/콩's JAVA_RUN

Student 매개변수

매개변수


 

class Student{

 int id;
 String name;
 double score;
 
 double calcScore(int score1, int score2){
  score = score1+score2;
  return score;
 }
 void print(){
  System.out.println("ID ="+id+" Name ="+name+
    " score= "+score);
 }
}
public class StudentTest {
 public static void main(String[] args) {
  Student lee = new Student();
  lee.id = 140101;
  lee.name = "이학생";
  lee.calcScore(50, 30);
  System.out.println(lee.score);
  lee.print();
 }
}