로그인 바로가기

중앙 내용으로 바로가기

수성컴퓨터학원

본문내용

본문

프로그래밍 실습
+ Home > 커뮤니티 > 프로그래밍 실습
자바 첫날
  • 작성자
    secoma
  • 등록일
    2020-04-23 18:23:57
    조회수
    612

 

package s1;

public class Student {
 
 String no;
 String name;
 int k, e, m, t;
 
 Student(String no, String name, int k, int e, int m){
  this.no=no;
  this.name=name;
  this.k=k;
  this.e=e;
  this.m=m;
 }
 
 void tot() {
  t = k+e+m;
 }
 
 void output() {
  System.out.printf("%4s, %6S, %4d %4d %4d %4d\n",no, name,k,e,m,t);
  
 }
 
public static void main(String [] args) {
 
 Student s[];
 s=new Student[3];
 
 s[0]= new Student("001","김민우",99,100,100);
 s[1]= new Student("001","김민우",99,100,100);
 s[2]= new Student("001","김민우",99,100,100);
 
 for(int i=0;i<3;i++) {
  
  s[i].tot();
 }
 
 for(int i=0;i<3;i++) {
  
  s[i].output();
 }
}

 

 

목록보기
답글달기수정하기
삭제하기

관련 쪽지글