-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram49.java
More file actions
45 lines (33 loc) · 1017 Bytes
/
Copy pathprogram49.java
File metadata and controls
45 lines (33 loc) · 1017 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
40
41
42
43
44
45
// Student Class with Parameterized Constructor
import java.util.Scanner;
class Student {
String name;
int rollNo;
double marks;
// Parameterized Constructor
Student(String n, int r, double m) {
name = n;
rollNo = r;
marks = m;
}
void display() {
System.out.println("Name : " + name);
System.out.println("Roll No : " + rollNo);
System.out.println("Marks : " + marks);
}
}
public class program49 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter Name : ");
String name = sc.nextLine();
System.out.print("Enter Roll No : ");
int roll = sc.nextInt();
System.out.print("Enter Marks : ");
double marks = sc.nextDouble();
Student s1 = new Student(name, roll, marks);
System.out.println("\nStudent Details");
s1.display();
sc.close();
}
}