-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram42.java
More file actions
47 lines (29 loc) · 946 Bytes
/
Copy pathprogram42.java
File metadata and controls
47 lines (29 loc) · 946 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
46
47
// Create a Student class with name, roll number, and marks. Display details.
import java.util.Scanner;
class Student{
String name;
int rollNo;
double marks;
void displayDetails(){
System.out.println("Name : " + name);
System.out.println("Roll No. : " + rollNo);
System.out.println("Marks : " + marks);
}
}
public class program42 {
public static void main(String[] args) {
Student s1 = new Student();
Scanner sc = new Scanner(System.in);
System.out.println("Enter Your Name : ");
String n = sc.nextLine();
System.out.println("Enter Your Roll.No : ");
int rn = sc.nextInt();
System.out.println("Enter Your Marks : ");
double m = sc.nextDouble();
s1.name = n;
s1.rollNo = rn;
s1.marks = m;
s1.displayDetails();
sc.close();
}
}