Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Java) Open up a new Java project called Activity6 and create a class called Person Inside of the class, define three attributes that a person

(Java)

  • Open up a new Java project called Activity6 and create a class called Person
  • Inside of the class, define three attributes that a person has as variables of the class
    • Name
    • Age
    • Gender
  • Next, define two actions that can be performed as methods of the class:
  • The method is named greeting
    • It takes no parameters
    • It prints out the message "Hi, my name is " + name + "!"
    • It returns nothing
  • The method is named addYear
    • It takes in no parameters
    • It adds one year to the person's age
    • It returns nothing
  • Then, create a new Java file called PersonTest.java.
  • Copy and paste the below test code into PersonTest.java:
/** * @author * CIS 36B, Activity 6.1 */ public class PersonTest { public static void main(String[] args) { Person wen = new Person(); wen.name = "Wen"; wen.age = 19; wen.gender = "male"; wen.greeting(); wen.addYear(); System.out.println("I just turned " + wen.age + " years old."); } }
  • Now, run the program and verify that you get the following output:
Hi, my name is Wen! I just turned 20 years old.
  • When you are getting the correct output, submit your Person.java file

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

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago