Question

Console Welcome to the Customer Viewer Enter a customer number: 1003 Ronda Chavan 518 Commanche Dr. Greensboro, NC 27410 Disp

Complete Project 4-1 as outlined above. There are no starter files for this project. You will make it from scratch. You should end up with 5 files in your package (.settings, bin, src, .classpath, and .project)

0 0
Add a comment Improve this question Transcribed image text
Answer #1


/*Java test program that prompts user to enter customer
* number.If found then display the Customer record
* otherwise display that the record is not found.*/
//CustomerConsole.java

import java.util.Scanner;
public class CustomerConsole
{
   public static void main(String[] args)
   {
       int customerNumber;
       //Create a Scanner class object
       Scanner console=new Scanner(System.in);
      
       System.out.println("Welcome to the Customer Viewer");
       System.out.println();
       String choice="y";
       /*repeat until user enter n to close*/
       while(!choice.equals("n"))
       {
           System.out.print("Enter a customer number: ");
           customerNumber=Integer.parseInt(console.nextLine());
           Customer cutomer=CustomerDB.getCustomer(customerNumber);
           if(cutomer!=null)
           {
               System.out.println();
               System.out.println(cutomer.getNameAndAddress());
           }
           else
           {
               System.out.println("There is no customer number "+customerNumber
                       +" in our records.");
           }
           System.out.println();
           System.out.print("Display another customer? (y/n): ");
           choice=console.nextLine();  
           System.out.println();
       }//end of while loop
      
   } //end of the main method
} //end of the class,CustomerConsole
------------------------------------------------------------------------------------------------------------

//Customer.java
public class Customer
{
   //private instance variables
   private String name;
   private String address;
   private String city;
   private String state;
   private int postalCode;
   /*Constructor */
   public Customer(String name, String address, String city, String state, int postalCode) {
       this.name = name;
       this.address = address;
       this.city = city;
       this.state = state;
       this.postalCode = postalCode;
   }

   public String getName()
   {
       return name;
   }

   public void setName(String name)
   {
       this.name = name;
   }

   public String getAddress()
   {
       return address;
   }

   public void setAddress(String address)
   {
       this.address = address;
   }

   public String getCity()
   {
       return city;
   }

   public void setCity(String city)
   {
       this.city = city;
   }

   public String getState()
   {
       return state;
   }

   public void setState(String state)
   {
       this.state = state;
   }

   public int getPostalCode()
   {
       return postalCode;
   }

   public void setPostalCode(int postalCode)
   {
       this.postalCode = postalCode;
   }
   /*Method that returns name and address
   * of the customer*/
   public String getNameAndAddress()
   {
       return name+"\n"
                   +address+"\n"
                   +city+", "+state+" "+postalCode;
   }
} //end of the Customer class

------------------------------------------------------------------------------------------------------------

//CustomerDB.java
public class CustomerDB
{
   /*Static method that takes customer number
   * and then search for customer number using
   * if else statement and then return the
   * create customer object if matched otherwise
   * return null*/
   public static Customer getCustomer(int cusNumber)
   {
       if(cusNumber==1001)
       {
           return new Customer("Barbara White",
                   "3400 Richmond Parkway #3423",
                   "Bristol", "CT", 06010);
       }
       else if(cusNumber==1002)
       {
           return new Customer("Karl Vang",
                   "327 Frangklin Street",
                   "Edina", "MN", 55435);
       }
       else if(cusNumber==1003)
       {
           return new Customer("Ronda Chavan",
                   "518 Commanche Dr.",
                   "Greensboro", "NC", 27410);
       }      
       //returns null if customer number is not found
       return null;
   }//end of the method ,getCustomer
}

------------------------------------------Sample Run#---------------------------------------------------

Welcome to the Customer Viewer Enter a customer number: 1003 Ronda Chavan 518 Commanche Dr. Greensboro, NC 27410 Display anot

Add a comment
Know the answer?
Add Answer to:
Complete Project 4-1 as outlined above. There are no starter files for this project. You will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In this assignment, you will implement Address and Residence classes. Create a new java project. Part...

    In this assignment, you will implement Address and Residence classes. Create a new java project. Part A Implementation details of Address class: Add and implement a class named Address according to specifications in the UML class diagram. Data fields: street, city, province and zipCode. Constructors: A no-arg constructor that creates a default Address. A constructor that creates an address with the specified street, city, state, and zipCode Getters and setters for all the class fields. toString() to print out all...

  • This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description:...

    This is for Java Programming Please use comments Customer and Employee data (15 pts) Problem Description: Write a program that uses inheritance features of object-oriented programming, including method overriding and polymorphism. Console Welcome to the Person Tester application Create customer or employee? (c/e): c Enter first name: Frank Enter last name: Jones Enter email address: frank44@ hot mail. com Customer number: M10293 You entered: Name: Frank Jones Email: frank44@hot mail . com Customer number: M10293 Continue? (y/n): y Create customer...

  • Complete the assignments 1. After you finish the assignments , expand the content and then make...

    Complete the assignments 1. After you finish the assignments , expand the content and then make screen shot and submit your screen shot here. 2. Run the programming challenge assignments in Netbeans and submit the whole project file. A class named FeeRecord contains fields for a student’s name, enrolment number, annual fees, sports fees, and tuition fees. Write a constructor that accepts the two parameters name and enrolment number. Also write mutator and acceptor methods of the name setFees that...

  • Java Project In Brief... For this Java project, you will create a Java program for a...

    Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....

  • Download BankAccount.java and BankAccountTester.java starting files and drag and drop them into your eclipse project. The...

    Download BankAccount.java and BankAccountTester.java starting files and drag and drop them into your eclipse project. The BankAccount class declaration in file BankAccount.java is the blueprint of a BankAccount object. Check out the design of a BankAccount class. 1. In BankAccount.java class, all of the method stubs ( methods with a header but empty bodies ) are present to help you get started. Your task is to complete the method bodies. All comments in red in the diagram above indicates what...

  • Java Project For this assignment, you will write a simulation program to determine the average waiting...

    Java Project For this assignment, you will write a simulation program to determine the average waiting time at a grocery store checkout while varying the number of customers and the number of checkout lanes. Classes needed: SortedLinked List: Implement a generic sorted singly-linked list which contains all of the elements included in the unsorted linked list developed in class, but modifies it in the following way: delete the addfirst, addlast, and add(index) methods and instead include a single add method...

  • This is a Java project. It has alot of details T.T The project only uses the CONSOLE! I am looking for many ways to solv...

    This is a Java project. It has alot of details T.T The project only uses the CONSOLE! I am looking for many ways to solve this project so if you have the time, please try it! It means so much!! This is a store management system. It has 3 classes. (Goods, Management, UI)  There should be an array in the Management class contains Goods objects, and there should be a function that manages this array, meaning adding and deleting objects,...

  • This exercise guides you through the process of converting an Area and Perimeter application from a...

    This exercise guides you through the process of converting an Area and Perimeter application from a procedural application to an object-oriented application. Create and use an object 1. Open the project named ch04_ex2_Area and Perimeter that’s stored in the ex_starts folder. Then, review the code for the Main class. 2. Create a class named Rectangle and store it in the murach.rectangle package. 3. In the Rectangle class, add instance variables for length and width. The, code the get and set...

  • Objective In this assignment, you will practice solving a problem using object-oriented programming and specifically, you...

    Objective In this assignment, you will practice solving a problem using object-oriented programming and specifically, you will use the concept of object aggregation (i.e., has-a relationship between objects). You will implement a Java application, called MovieApplication that could be used in the movie industry. You are asked to implement three classes: Movie, Distributor, and MovieDriver. Each of these classes is described below. Problem Description The Movie class represents a movie and has the following attributes: name (of type String), directorName...

  • Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters...

    Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT