Write a subroutine that excutes the following a Ask the user
Write a subroutine that excutes the following
a. Ask the user for his name
b. Ask the user foe his or her student ID in the form 1234-5678
c. Creat a pin number for each user with the last, forth,first, and second numbers in his or her student number.
use LEFT/RIGHT/MID functions
Solution
Code:
import java.util.Scanner;
 
 class Main{
 public static void main(String args[]){
 String name;
 String id;
 String pin;
 
 Scanner in = new Scanner(System.in);
 
 System.out.print(\"Enter your name: \");
 name = in.nextLine();
 System.out.print(\"Enter your ID (1234-5678): \");
 id = in.nextLine();
   
 pin = String.valueOf(id.charAt(8))+String.valueOf(id.charAt(3))+String.valueOf(id.charAt(0))+String.valueOf(id.charAt(1));
  System.out.println(\"Pin is: \"+pin);   
 }
 }
Output:

