-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathOOPScore.java
More file actions
39 lines (33 loc) · 1018 Bytes
/
OOPScore.java
File metadata and controls
39 lines (33 loc) · 1018 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
public class OOPScore {
//属性(1静态行为 ,全局变量 )
int javaScore;
int cScore;
int sqlScore;
public static void main(String[] args) {
OOPScore score = new OOPScore();
score.inputScore();
double avg = score.calcAvg();
int sum = score.calcSum();
System.out.println(avg + "--" + sum);
}
public void inputScore() {
Scanner input = new Scanner(System.in);
System.out.println("请输入java成绩:");
javaScore = input.nextInt();
System.out.println("请输入C成绩:");
cScore = input.nextInt();
System.out.println("请输入SQL成绩:");
sqlScore = input.nextInt();
}
//计算平均分并返回
public double calcAvg() {
double av = (javaScore + cScore + sqlScore) / 3.0;
return av;
}
//计算总分并返回
public int calcSum() {
int sum = javaScore + cScore + sqlScore;
return sum;
}
}