Answer to Question #201815 in Java | JSP | JSF for Shema Derrick

Question #201815

. develop a java application that uses a class called person which has 2 functions: getdata() and putdata(). The getdata() prompts the user to enter his or her first name, last name and age, the putdata() displays on the screen the user first name last, name and age. 


1
Expert's answer
2021-06-01T17:39:54-0400
import java.util.Scanner;

public class Person {
    private String firstName;
    private String lastName;
    private int age;

    public void getData() {
        Scanner in = new Scanner(System.in);
        System.out.println("Enter your first name:");
        firstName = in.nextLine();
        System.out.println("Enter your last name:");
        lastName = in.nextLine();
        System.out.println("Enter your age:");
        age = in.nextInt();
    }

    public void putData() {
        System.out.println(firstName + " " + lastName + " of the age " + age);
    }
}


public class Main {
    public static void main(String[] args) {
        Person person = new Person();
        person.getData();
        person.putData();
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Shema Derrick
02.06.21, 21:11

good

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS