Skip to content

Commit 1929652

Browse files
committed
feat: Add Inputs class to demonstrate reading different data types from user
Add a program that: - Takes roll number (int), name (String), and marks (float) as input - Uses `Scanner` to read and store user input - Prints the collected data to the console - Demonstrates handling of multiple primitive data types via standard input.
1 parent 56e3e97 commit 1929652

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Section5OperatorExpression/src/Inputs.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
public class Inputs {
44
public static void main(String[] args) {
55
Scanner input = new Scanner(System.in);
6-
// System.out.print("Please enter some input: ");
7-
// int rollno = input.nextInt();
8-
// System.out.println("Your roll number is " + rollno);
96

10-
// String name = input.next();
11-
// System.out.println(name);
7+
System.out.print("Please enter your Roll No: ");
8+
int rollno = input.nextInt();
9+
System.out.println("Your Roll No is: " + rollno);
1210

13-
// float marks = input.nextFloat();
14-
// System.out.println(marks);
11+
System.out.println("Please enter your Name: ");
12+
String name = input.next();
13+
System.out.println(name);
14+
15+
System.out.println("Please enter your Marks: ");
16+
float marks = input.nextFloat();
17+
System.out.println(marks);
1518
}
1619
}

0 commit comments

Comments
 (0)