Question: The ZipCode Class the attributes String fiveDigit String plus4 The App class create 2 ZipCode objects called z1 and z2. z1 data fiveDigit - 90210
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
90210 16802-1503
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
