Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA - If you can explain each step, that'd be great too. In this lab you will create a ZipCode class and 2 objects

IN JAVA - If you can explain each step, that'd be great too.

In this lab you will create a ZipCode class and 2 objects of this class. You will also display the data from each object.

Deliverable

A zipped NetBeans project with 2 classes

  • app
  • ZipCode

Classes

image text in transcribed

The ZipCode Class

  1. the attributes
    • String fiveDigit
    • String plus4

The App class

  1. create 2 ZipCode objects called z1 and z2.
    1. z1 data
      • fiveDigit - "90210"
      • plus4 - "" (blank, no spaces)
    2. z2 data
      • fiveDigit - 16802
      • plus4 - 1503
  2. display all the data from each object
    1. if the second attribute, plus4, is blank, display only the first attribute fivedigit
      • for instance, 16801
    2. if the second attribute, plus4, is not blank,
      • display only the first attribute fivedigit followed by a "-" and then the plus4 attribute
        • for instance, 16802-1503
    3. make sure you display the data using the objects z1 and z2
      • A statement using a fixed string is not a correct answer
        • System.out.println("16802-1503"); is not the answer
      • looking at the data and having specific "system.out" is not the correct answer
      • You need to use if statements (or other kind of tests) to handle any variable/object

Output

The output should be similar to

image text in transcribed

App - Creates 2 ZipCode objects, 21 and 22. - Display the data from the 2 objects following the lab instructions Zip Code Attributes String five Digit; String plus4; 8218 16882-1503

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