-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram19.java
More file actions
35 lines (24 loc) · 818 Bytes
/
Copy pathprogram19.java
File metadata and controls
35 lines (24 loc) · 818 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
// Create a method that returns the average of two & three numbers.
import java.util.Scanner;
class Calculator{
public double avg(int a, int b, int c){
return (a+b+c)/3;
}
public double avg(int a, int b){
return (a+b)/2;
}
}
public class program19 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Num1 : ");
int num1 = sc.nextInt();
System.out.print("Enter Num2 : ");
int num2 = sc.nextInt();
System.out.print("Enter Num3 : ");
int num3 = sc.nextInt();
Calculator obj = new Calculator();
double result = obj.avg(num1, num2, num3);
System.out.println(" Average : " + result);
}
}