Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help creating a method the satisfies the following requirements using jav

ID: 3848497 • Letter: I

Question

I need help creating a method the satisfies the following requirements using java.

o The identifier field will be created using the first 7 letters (uppercased) of the last name.

If the last name has less than 7 letters, the code should append Xs to the end of the name, so that there will be 7 letters total.

o The code in the body of method will:

Declare an integer constant to hold an id length of 7.

Declare a second String constant to hold seven Xs ("XXXXXXX").

Use decisions with these constants and the last name to create the drinker identifier, WITHOUT using brute force.

o NOTE: You will need to check the length of the last name BEFORE trying to extract any letters, and then use a decision statement to decide which letters to extract. Otherwise the program may crash when there are less than 7 letters in the last name.

Explanation / Answer

package sample1;

import java.util.Scanner;

import java.io.*;

public class test {

    public static void main(String args[]) throws IOException
     {
       create();
       }
    public static void create(){
       int id_length=7;
       String identifier="XXXXXXX";
       System.out.println(" enter last name : ");
       Scanner s=new Scanner(System.in);
        String lastName=s.nextLine();
        identifier=lastName.substring(0,id_length);
        System.out.println(" identifier : "+identifier.toUpperCase());
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote