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....

  • Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending...

    Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account. --->Console Welcome to the Account application Starting Balances Checking: $1,000.00 Savings:  $1,000.00 Enter the transactions for the month Withdrawal or deposit? (w/d): w Checking or savings? (c/s): c Amount?: 500 Continue? (y/n): y Withdrawal or deposit? (w/d): d Checking or savings? (c/s): s Amount?: 200 Continue? (y/n): n Monthly Payments and Fees Checking fee:              $1.00 Savings...

  • Your task for this project is to write a parser for a customer form. You need to develop a Java a...

       Your task for this project is to write a parser for a customer form. You need to develop a Java application using Parboiled library. Your program should include a grammar for the parser and display the parse tree with no errors. Remember that your fifth and sixth assignments are very similar to this project and you can benefit from them. The customer form should include the following structure: First name, middle name (optional), last name Street address, city, state (or...

  • Write a program for a Buffet to display the bill Sor the cashicr The buffet serves a chef's meu with two options 31 50 The total adu bill is roduced by $5.00 if there are 9 aor more ad $15....

    Write a program for a Buffet to display the bill Sor the cashicr The buffet serves a chef's meu with two options 31 50 The total adu bill is roduced by $5.00 if there are 9 aor more ad $15.00 It is free after the third child maximum of 3 childrm) The program requests the name and zip code ofthe buf1ส and converts the tru The pr- then aceepts the number of adults and children, performs the necessary calculations compues...

  • 1.     This project will extend Project 3 and move the encryption of a password to a...

    1.     This project will extend Project 3 and move the encryption of a password to a user designed class. The program will contain two files one called Encryption.java and the second called EncrytionTester.java. 2.     Generally for security reasons only the encrypted password is stored. This program will mimic that behavior as the clear text password will never be stored only the encrypted password. 3.     The Encryption class: (Additionally See UML Class Diagram) a.     Instance Variables                                                i.     Key – Integer...

  • 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...

  • java In this project you will implement a trivia game. It will ask random trivia questions,...

    java In this project you will implement a trivia game. It will ask random trivia questions, evaluate their answers and keep score. The project will also have an administrative module that will allow for managing the question bank. Question bank management will include adding new questions, deleting questions and displaying all of the questions, answers and point values. 2. The project can be a GUI or a menu based command line program. 3. Project details 1. Create a class to...

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
ADVERTISEMENT