Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Youve been given an empty Person class. Inside this empty class, you will create the fields firstName and lastName. We have given you a constructor

Youve been given an empty Person class. Inside this empty class, you will create the fields firstName and lastName. We have given you a constructor which takes in the first and last name and assigns them to those fields. We have also created a toString() method to output the first and last names separated by one space.

The main method in PoD.java has been written for you. It reads in 2 strings, instantiates the class Person (once as the targeted person and another the identity thefts copy of that same person), and then prints out the result using the toString() method.

image text in transcribed

image text in transcribed

public class Person

{

// PLEASE START YOUR CODE HERE

// *********************************************************

// *********************************************************

// PLEASE END YOUR CODE HERE

//constructor

public Person(String firstName, String lastName)

{

this.firstName = firstName;

this.lastName = lastName;

}

public String toString()

{

return firstName + " " + lastName;

}

}

import java.util.Scanner;

public class PoD {

public static void main( String [] args ) {

Scanner in = new Scanner(System.in);

String firstName = in.next();

String lastName = in.next();

Person targetPerson = new Person(firstName, lastName);

Person identityThief = new Person(firstName, lastName);

//output using toString() method

System.out.println(targetPerson);

System.out.println(identityThief);

System.out.print("END OF OUTPUT");

}

}

Input (main method of PoD. java) The following input values are expected: a string (first Name): the first name of the person (also used by the identity theft) a string (lastName): the last name of the person (also used by the identity theft) Processing (in PoD.java) Read in two strings (first name of person, followed by last name) Instantiate the class Person twice First, the person that is the target o Second, the identity theft (a "copy" of the target person) Output the results using the toString) method of Person.java Processing (in Person. java) This is the work that you need to complete Create fields: o a string firstName: the first name of the person o a string last Name: the last name of the person Note A constructor is already created for you which takes in the first and last name and assions them to the appropriate felds .A method exists which returns the first and last name toString() separated by a space

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Aided Database Design

Authors: Antonio Albano, Valeria De Antonellis, A. Di Leva

1st Edition

0444877355, 978-0444877352

More Books

Students also viewed these Databases questions

Question

Question Can a self-employed person adopt a profit sharing plan?

Answered: 1 week ago