Question

In Java, How would I create a program that does this from user input?

studentld: consists of the first two characters of the students first name, students birth year, and the last two character

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication1;

import java.util.Scanner;


public class new1 {
   public static void main(String[] args) {
   Scanner sc= new Scanner(System.in);
       String firstNAME, lastName;
       int dobYear;
       System.out.println("Hello User");
       System.out.println("Please enter your first name: ");
       firstNAME= sc.next();
System.out.println("Please enter your last name: ");
lastName= sc.next();
System.out.println("Please enter your year of birth: ");
dobYear= sc.nextInt();
  
new1 n1= new new1();
String userID=n1.userId(firstNAME, lastName, dobYear);
System.out.println("Your UserID is: "+userID);
String emailID=n1.email(firstNAME, lastName);
System.out.println("Your Email ID: "+emailID);
      
   }
  
   String userId(String firstN, String lastN, int YearOB) {
   String firstTwo= firstN.substring(0,2);
   String lastTwo= lastN.substring(lastN.length() - 2);
  
   String user_Id= firstTwo+YearOB+lastTwo;
;   return user_Id;
   }
  
   String email(String firstN,String lastN) {
   String email_id = firstN+"."+lastN+"@pa2.com";
   return email_id;
   }
  
}

OUTPUT:

Hello User
Please enter your first name:
John
Please enter your last name:
Smith
Please enter your year of birth:
1988
Your UserID is: Jo1988th
Your Email ID: [email protected]

String user Id= firstTwo+YearoB+lastTwo; return user_Id; String email (String firstN, String lastn) { String email id = first

Thanks and regards
if you like the answer please give a thumbs up
if you have a problem, feel free to comment.

Add a comment
Know the answer?
Add Answer to:
In Java, How would I create a program that does this from user input? studentld: consists...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Need Java help: 1. Create a Java program that accepts input String input from a user...

    Need Java help: 1. Create a Java program that accepts input String input from a user of first name. 2. Create a Java program that accepts input String input from a user of last name. 3. Concatenate the Strings in a full name variable and print to the console.

  • I need to create a code based off of what the users first name and last...

    I need to create a code based off of what the users first name and last name are along with a random set of numbers no longer than 10 characters as the picture below demonstrate (Java language) Scenario: You have been appointed by the CS department to create a username generator to create CS email accounts automatically. The CS email will have the following format: [email protected]. Your username must have a limit of 10 characters. Your program, will provide three...

  • Write a program in Java according to the following specifications: The program reads a text file...

    Write a program in Java according to the following specifications: The program reads a text file with student records (first name, last name and grade on each line). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "print" - prints the student records (first name, last name, grade). "sortfirst" - sorts the student records by first name. "sortlast" - sorts the student records by last name. "sortgrade" - sorts the...

  • Create a JAVA program that in two numbers from user input, the program then does the...

    Create a JAVA program that in two numbers from user input, the program then does the following arithmetic calculations. The program will run in ascending order if the first number is small and in descending order of the first number is bigger. The program then alternates between addition(ODD) and subtraction(EVEN) depending on the previous number see examples below   [15] Sample run 1: Enter two numbers: -3 2 Output: The following arithmetic calculations were performed : Arithmetic operations = (-3) +...

  • Design a modular program using pseudo-code which prompts a user for their first name, followed by...

    Design a modular program using pseudo-code which prompts a user for their first name, followed by their last name; then displays a "Hello" salutation which concatenates their first name with their last name. Sample output (user input shown in red): Please enter your first name: John Please enter your last name: Smith Hello, John Smith! Your program must include a main module and one function; this function prompts the user for either their first name or last name, using a...

  • Create a New Java Project called YourLastNameUpperCase. Write a program that asks the user for the...

    Create a New Java Project called YourLastNameUpperCase. Write a program that asks the user for the names of two files. The first file should be opened for reading and the second file should be opened for writing. The program should read the contents of the first file, change all characters to uppercase, and store the results in the second file. The second file will be a copy of the first file, except that all the characters will be uppercase. Use...

  • use Java and it must work for any name String Manipulator Write a program to manipulate...

    use Java and it must work for any name String Manipulator Write a program to manipulate Strings. Store your full name into one String variable. It must include first name, middle name, last name, cach separated by spaces. Spaces could vary. If you do not have a middle name make up one For example the string to be processed could be any of the following John Plain Doe John Plain Doc John Plain Doe Your program must be able to...

  • Create a program that allows a student to complete a registration form and displays a completion...

    Create a program that allows a student to complete a registration form and displays a completion message that includes the user’s full name and a temporary password. Console Registration Form First name: Bjarne Last name: Stroustrup Birth year: 1950 Welcome Bjarne! Your registration is complete. Name: Bjarne Stroustrup Temporary password: Bjarne*1950 Specifications • The user’s full name consists of the user’s first name, a space, and the user’s last name. • The temporary password consists of the user’s first name,...

  • Java Project In Brief... For this Java project, you will create a Java program for a...

    Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....

  • JAVA STRINGS AND CHARACTERS - USE SIMPLE CODING 1. Write a program that takes a string...

    JAVA STRINGS AND CHARACTERS - USE SIMPLE CODING 1. Write a program that takes a string of someone's full name and prints it out last name first. You may use the available string manipulation methods. Example: "George Washington" "Washington, George" 2. Write a program that will take a string of someone's full name, and break it into separate strings of first name and last name, as well as capitalize the first letter of each. Example: "joseph smith", "Joseph" "Smith"

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT