Answered step by step
Verified Expert Solution
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
The ZipCode Class
- the attributes
- String fiveDigit
- String plus4
The App class
- create 2 ZipCode objects called z1 and z2.
- z1 data
- fiveDigit - "90210"
- plus4 - "" (blank, no spaces)
- z2 data
- fiveDigit - 16802
- plus4 - 1503
- z1 data
- display all the data from each object
- if the second attribute, plus4, is blank, display only the first attribute fivedigit
- for instance, 16801
- 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
- display only the first attribute fivedigit followed by a "-" and then the plus4 attribute
- 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
- A statement using a fixed string is not a correct answer
- if the second attribute, plus4, is blank, display only the first attribute fivedigit
Output
The output should be similar to
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started