Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package question;
- import java.util.*;
- public class Question {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- //input name
- String name = new String();
- System.out.println("Please input your full name");
- name = input.nextLine();
- //input student number
- String number = new String();
- System.out.println("Please input your student number");
- number = input.nextLine();
- //output first name initial
- String x = new String(name.toUpperCase());
- char first = name.charAt(0);
- System.out.print(first);
- //output last name initial
- for (int y = 1; y < x.length(); y++)
- {
- char last = x.charAt(y);
- if (last == ' ')
- {
- System.out.print(x.charAt(y + 1)+" ");
- }
- }
- //output student number
- System.out.println(number.substring(6, 9));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement