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: John.Smith@pa2.com

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: Username@cs.utep.du. Your username must have a limit of 10 characters. Your program, will provide three...

  • java create java class "nameperson" the example of output would be this: //if the user inputs...

    java create java class "nameperson" the example of output would be this: //if the user inputs sophia 206999109 2 //then the output shows this My name is None and my studentid is 0 My name is sophia and studentid is 0 My name is sophia and studentid is 206999109 My grade is 2 so i have to create two classes   class nameperson{ } class studentid extends person{ } class grade extends studentid{ } my main method is this class Main...

  • 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...

  • 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 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) +...

  • how to delete first word and last word in a string of user input ex: int...

    how to delete first word and last word in a string of user input ex: int main) string fullname; cout << "Enter Full Name ex: Rob John Smith" << endl; cin >fullname; //Some code that will delete the first and /last name to get middle name cout < "Your middle name is:" midname;

  • PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class...

    PART I: Create an abstract Java class named “Student” in a package named “STUDENTS”. This class has 4 attributes: (1) student ID: protected, an integer of 10 digits (2) student name: protected (3) student group code: protected, an integer (1 for undergraduates, 2 for graduate students) (4) student major: protected (e.g.: Business, Computer Sciences, Engineering) Class Student declaration provides a default constructor, get-methods and set-methods for the attributes, a public abstract method (displayStudentData()). PART II: Create a Java class named...

  • Write a Java program that reads a series of strings from a user until STOP is...

    Write a Java program that reads a series of strings from a user until STOP is entered. Each input consists of information about one student at the ABC Professional School. The input consists of the student’s last name (the first 15 characters with extra blanks on the right if the name is not 15 characters long), the student’s number (the next 4 characters, all digits, a number between 1000 and 5999), and the student’s program of study (one character, either...

  • java Create a program that utilized a multi-dimensional array for the user to input the name...

    java Create a program that utilized a multi-dimensional array for the user to input the name of a team and their number of wins. The user should be able to input up to 10 teams and the wins for each team.

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