java scanner

This commit is contained in:
2026-10-15 13:16:44 -04:00
parent 52ffb923fc
commit 7758699dde
+28 -1
View File
@@ -1,4 +1,31 @@
package PACKAGE_NAME;
// Ian An
// Oct 15 2026
// User Input Assignment
import java.util.Scanner;
public class MyText {
public static void output() {
Scanner s = new Scanner (System.in);
String name;
String lastName;
int grade;
System.out.println("What is your first name?");
name = s.nextLine();
System.out.println("Hello "+name);
System.out.println("What is your last name");
lastName = s.nextLine();
System.out.println("Hello "+lastName);
System.out.println("What is your grade?");
grade = s.nextInt();
System.out.printf("So, %s %s, are you really in grade %d?",name,lastName,grade);
}
public static void main(String[] args) {
output();
}
}