十二章上机练习1

package rrr.com;

public class ppp {
	int java;
	int c;
	int db;
	public int calcTotalScore(){
		int total=java+c+db;
		return total;
	}
	public void showTotalScore(){
		System.out.println("总成绩:"+calcTotalScore());
	}
	public double calcAvg(){
		double avg=(java+c+db)/3.0;
		return avg;
		
	}
	public void showAvg(){
		System.out.println("平均成绩是;"+calcAvg());
	}

}

package rrr.com;

import java.util.Scanner;

public class lll {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner input = new Scanner(System.in);
		ppp a = new ppp();
		System.out.println("请输入jAVA成绩:");
		a.java = input.nextInt();
		System.out.println("请输入c成绩:");
		a.c = input.nextInt();
		System.out.println("请输入db成绩:");
		a.db = input.nextInt();
		
		a.showAvg();
		a.showTotalScore();

	}

}

你可能感兴趣的:(十二章上机练习1)