Question

1. Build a Java Class that prints out your name. Print your first name on the...


1. Build a Java Class that prints out your name. Print your first name on the first line of output, and print your last name on the second line of output. Use variables to hold your firstName and lastName before printing them. All your code should go in the main() method. Call your class “Names.java”.


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

import java.util.Scanner;

public class Name

{

public static void main(String[] args)

{

Scanner Input = new Scanner (System.in);

System.out.print("Input your first name: ");

String fname = input.next();

System.out.print("Input your last name: ");

String lname = input.next();

System.out.println();

System.out.println( fname + " \n " + lname);

}}

Add a comment
Know the answer?
Add Answer to:
1. Build a Java Class that prints out your name. Print your first name on the...
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
  • Build a Java Class to print out your age, your salary (exaggerate), and your IQ (be...

    Build a Java Class to print out your age, your salary (exaggerate), and your IQ (be kind). Each item should be on a separate line of output. Again use variable to hold these values. All your code should go in the main() method. Call your class “Data.java”. lab 2 2371

  • JAVA PROGRAMMING In this final review lab from our intro course, use the Name class you...

    JAVA PROGRAMMING In this final review lab from our intro course, use the Name class you created in the previous lab. In this lab, create a Student class with the following class variable: Student name: Name (Note: Name is a datatype) Student Id: String Create the getter and setter methods. In addition to these methods, create a toString() method, which overrides the object class toString() method. This override method prints the current value of any of this class object. Complete...

  • read the code and comments, and fix the program by INSERTING the missing code in Java...

    read the code and comments, and fix the program by INSERTING the missing code in Java THank you please import java.util.Scanner; public class ExtractNames { // Extract (and print to standard output) the first and last names in "Last, First" (read from standard input). public static void main(String[] args) { // Set up a Scanner object for reading input from the user (keyboard). Scanner scan = new Scanner (System.in); // Read a full name from the user as "Last, First"....

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

  • JAVA This PoD, builds off the Book class that you created on Monday (you may copy...

    JAVA This PoD, builds off the Book class that you created on Monday (you may copy your previously used code). For today’s problem, you will add a new method to the class called lastName() that will print the last name of the author (you can assume there are only two names in the author name – first and last). You can use the String spilt (“\s”) method that will split the String by the space and will return an array...

  • In Java, Develop a class definition for a Person. Then develop a class definition for a...

    In Java, Develop a class definition for a Person. Then develop a class definition for a Military Person that inherits the properties of the Person, and a Navy Sailor that inherits the properties of a Military Person.   At each level, include the following class variables: Person: FirstName, MiddleInitial, LastName, Gender Military Person: Active Duty or Reserve Navy Sailor: Base where stationed, Surface Ship or Submarine, Date Commissioned, Rank Include a toString() method in each class that will print out the...

  • Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char...

    Convert this C program to Js (Java script) from Visual Studio Code #include<stdio.h> int main(){ char firstName[100]; char lastName[100]; printf("Enter Your Full Name: \n"); scanf("%s %s", firstName, lastName); printf("First Name: %s\n", firstName); printf("Last Name: %s\n", lastName); return 0; }

  • In JAVA #3 Write a program named nameChanger.java. This program will only have a driver class...

    In JAVA #3 Write a program named nameChanger.java. This program will only have a driver class with a main. This program will have the user enter a series of names(first and last), which will then be stored in a String array. You will then change the values of each of the names in the array, so that they are stored lastname, firstname, and then output the revised array. Sample: Enter a name (first and last): Tonya Pierce Enter a name...

  • Prelab Exercises Your task is to write a Java program that will print out the following...

    Prelab Exercises Your task is to write a Java program that will print out the following message (including the row of equal marks): Computer Science, Yes!!!! ========================= An outline of the program is below. Complete it as follows: a. In the documentation at the top, fill in the name of the file the program would be saved in and a brief description of what the program does. b. Add the code for the main method to do the printing. //...

  • C++ plane boarding problem. using a vector passengers check in using first name, last name, and class (first, business,...

    C++ plane boarding problem. using a vector passengers check in using first name, last name, and class (first, business, economy) people border in this order -first class -if no first class then business -if no first or business, then economy use class Boarding (in file Boarding.h) followinf public functions for the class: Boarding (); void checkin(string firstname, string lastname, string class); void boardNextPassenger(); followinf is output example checkin(“Tommy”, “Titan”, “First”); checkin(“Tina“, “Tusker“, “First”); checkin(“Jim“, “Jumbo“, “Economy“); boardNextPassenger(); // should print...

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