-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab6.java
More file actions
46 lines (38 loc) · 1.53 KB
/
Copy pathLab6.java
File metadata and controls
46 lines (38 loc) · 1.53 KB
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
40
41
42
43
44
45
46
import java.util.Scanner;
import java.text.DecimalFormat;
public class Lab6
{
public static void main (String[]args)
{
Scanner keyboard = new Scanner(System.in);
DecimalFormat formatter = new DecimalFormat("#,###,##00");
TestScore_Lab6 math = new TestScore_Lab6();
TestScore_Lab6 history = new TestScore_Lab6();
TestScore_Lab6 physics = new TestScore_Lab6();
System.out.print("Enter your first course name:");
String course1=keyboard.nextLine();
System.out.print("Enter your first score:");
double score1=keyboard.nextDouble();
math.setCoursename(course1);
math.setCoursescore(score1);
keyboard.nextLine();
System.out.print("Enter your second course name:");
String course2=keyboard.nextLine();
System.out.print("Enter your second course score:");
double score2=keyboard.nextDouble();
history.setCoursename(course2);
history.setCoursescore(score2);
keyboard.nextLine();
System.out.print("Enter your third course name:");
String course3=keyboard.nextLine();
System.out.print("Enter your third score:");
double score3=keyboard.nextDouble();
physics.setCoursename(course3);
physics.setCoursescore(score3);
System.out.println(math.getCoursename()+"\t\t\t\t"+math.getCoursescore());
System.out.println(history.getCoursename()+"\t\t\t"+history.getCoursescore());
System.out.println(physics.getCoursename()+"\t\t\t"+physics.getCoursescore());
double average = (math.getCoursescore()+history.getCoursescore()+physics.getCoursescore())/3;
System.out.println("average is " + average);
}
}