package com.zzzy.lx;
public class mains {
public static void main(String[] args) {
// 創建名爲hello的對象
mains hello = new mains();
// 調用hello對象的calcAvg()方法,並將返回值保存在變量avg中
double avg = hello.calcAvg();
System.out.println("平均成績爲:" + avg);
}
// 定義一個返回值爲double類型的方法
public double calcAvg() {
double java = 92.5;
double php = 83.0;
double avg = (java + php) / 2; // 計算平均值
return avg;
// 使用return返回值
}
}