Question

Please code following question in Java. Q) Prompt the user to enter the first initial of...

Please code following question in Java.

Q) Prompt the user to enter the first initial of their first name. Then prompt the user to enter their full last name. Then prompt the user to enter the last 4 digits of their student ID.

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

CODE IN JAVA:

Student.java file:

import java.util.Scanner;

public class StudentDemo {

public static void main(String args[]) {

Scanner sc = new Scanner(System.in);

String firstName, lastName;

int studentId;

System.out.print("Enter the first initial of the first name : ");

firstName = sc.nextLine();

System.out.print("Enter the full last name : ");

lastName = sc.nextLine();

System.out.print("Enter the last 4 digits of the student ID : ");

studentId = sc.nextInt();

}

}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Please code following question in Java. Q) Prompt the user to enter the first initial of...
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
  • Write Java code that prompts the user to enter his or her full name, then prints...

    Write Java code that prompts the user to enter his or her full name, then prints the name in reverse order (i.e., last name, first name). Read an entire line as a single string. Here is an example dialogue with the user: Please enter your full name: Sammy Jankis Your name in reverse order is Jankis, Sammy

  • 3,4,5,6,7,8 please 1. Enter the code to prompt a user to enter their name into a...

    3,4,5,6,7,8 please 1. Enter the code to prompt a user to enter their name into a script and save to name. imputl name) 2. Enter the code to display their name to the command window using "disp" function. 3. Enter the code to display their name using the "fprintf" function ame 4. What is the main difference between the "disp and "fprintf" commands? on 5. What is the main difference between the "fprintf" and "sprintf" commands? 6. What is a...

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

  • Write a "PYTHON" program to prompt the user to enter a fist name, last name, student...

    Write a "PYTHON" program to prompt the user to enter a fist name, last name, student ID and GPA. Create a dictionary with the data. Print out the data. Then remove the GPA and print again.

  • Task #1 Create a program that: 1. Has a comment in the JavaScript code with your...

    Task #1 Create a program that: 1. Has a comment in the JavaScript code with your name and student number 2. Asks the user for their first name with a pop-up prompt screen. Explorer User Prompt Script Prompt: ок Enter your first name: Cancel Joel 3. Asks the user for their last name with a pop-up prompt screen. Explorer User Prompt X Saript Prompt: ок Enter your last name: Cancel Smith 4. Performs string concatenation to combine their first and...

  • In Java please: Write a program that will prompt the user to enter GPA values one...

    In Java please: Write a program that will prompt the user to enter GPA values one per line, stopping when the user enters a negative Input: value. Print the following on separate lines: . The number of vaild GPAs entered » The sum of the GPAs 4.0 3.7 2.9 3.5 -1 The average GPA

  • MATLAB script 1) Prompt the user for their first name 2) Prompt the user for their...

    MATLAB script 1) Prompt the user for their first name 2) Prompt the user for their last name 3) Prompt the user for their age Display a sentence that greets the user using their first and last name, and congratulates them for what will be their age on their next birthday. Example: Hello John Smith. Congratulations on turning 45 on your next birthday!

  • Please write in JAVA ONLY Please use a dialog box to prompt the user to enter...

    Please write in JAVA ONLY Please use a dialog box to prompt the user to enter the radius for a circle (radius should be a double). Then, use a Message Box to display the Radius, Area and Circumference of the circle with that Radius. You will use the Math class constant Math.PI to calculate the Area and Circumference.

  • in java Write an application called Squaring that will: • Prompt the user to enter an...

    in java Write an application called Squaring that will: • Prompt the user to enter an integer greater than 1. Your code for this should be type-safe and validate the number, meaning that your code should re-prompt the user for another entry if they enter anything other than an integer that is greater than 1. • Repeatedly square the integer until it exceeds 1 million, outputting the value each time after squaring. • Output the number of squarings required to...

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