-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
59 lines (45 loc) · 1.12 KB
/
Main.java
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
47
48
49
50
51
52
53
54
55
56
57
58
59
package beginner.ex1005;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
TextInterface textInterface = new TextInterface();
textInterface.print();
}
}
class TextInterface
{
private Scanner input;
private Average average;
public TextInterface()
{
input = new Scanner(System.in);
average = new Average(input.nextDouble(), input.nextDouble());
}
public void print()
{
System.out.printf("MEDIA = %.5f%n", average.getWeightedAverage());
}
}
class Average
{
private double note1, note2, weightedAverage;
public Average(double note1, double note2)
{
this.note1 = noteValidator(note1);
this.note2 = noteValidator(note2);
}
public double getWeightedAverage()
{
double weight1 = 3.5, weight2 = 7.5;
weightedAverage = ((note1 * weight1) + ( note2 * weight2)) / 11;
return weightedAverage;
}
public double noteValidator(double value)
{
if (value >= 0 && value <= 10)
return value;
return 0;
}
}