Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I am having problems with the following programming concept: create two cl

ID: 3670385 • Letter: H

Question

Hello

I am having problems with the following programming concept:

create two classes. The first holds customer data, specifically a customer numer and zipcode. The second is a class for cities. It holds the city name, state, and zipcode. Additionally each class must contain a constructor that takes paramaters to set the field values. Create a FRIEND function that displays a customer number and the customers city, state, and zip code. Write a brief main statement to test the classes and the friend function.

Explanation / Answer

public class Customer {
    public String number;
    public String zipcode;
    public City city;

    public Customer(String number, String zipcode,City city) {
        this.number = number;
        this.zipcode = zipcode;
        this.city=city;
    }
   
    public void display() {
    System.out.println(number);
    System.out.println(zipcode);
    System.out.println(city.getName());
    System.out.println(city.getState());
    System.out.println(city.getZipcode());
   
    }
    }
public class City {
   public String name;
   public String state;
   public String zipcode;

    public City(String name, String state, String zipcode) {
        this.name = name;
        this.state = state;
        this.zipcode = zipcode;
    }

    public String getName() {
        return name;
    }

    public String getState() {
        return state;
    }

    public String getZipcode() {
        return zipcode;
    }
}
public class JavaApplication13 {
public static void main(String[] args) {
        City c=new City("ap","amaravathi","123-12");
     Customer c1=new Customer("123","10-123", c);
     c1.display();
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote