-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram75.java
49 lines (41 loc) · 878 Bytes
/
Program75.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
/* Program 75
27/08/24 */
import java.util.Scanner;
class Student {
int no1, no2, no3, sum;
Student() {
no1 = 0;
no2 = 0;
no3 = 0;
sum = 0;
}
Student(int n1, int n2, int n3) {
no1 = n1;
no2 = n2;
no3 = n3;
}
void input() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter 3 numbers: ");
no1 = sc.nextInt();
no2 = sc.nextInt();
no3 = sc.nextInt();
}
void compute() {
sum = no1 + no2 + no3;
}
void display() {
System.out.println("The sum is " + sum);
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
Student s1 = new Student();
s1.input();
s1.compute();
s1.display();
System.out.println("Enter 3 numbers: ");
Student s2 = new Student(sc.nextInt(), sc.nextInt(), sc.nextInt());
s2.compute();
s2.display();
}
}