Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have

SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA.

  • Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
  • Unless otherwise noted in the question, assume that parameters in method calls are notnulland that methods are called only when their preconditions are satisfied.
  • In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit.

The following class represents a customer. The variablenamerepresents the name of the customer, and the variablecurrAccNumrepresents the customer's account number. Each time aCustomerobject is created, the static variablenextAccNumis used to assign the customer's account number.

public class Customer

{

private static int nextAccNum = 1;

private String name;

private int currAccNum;

public Customer(String n)

{

name = n;

currAccNum = nextAccNum;

nextAccNum++;

}

}

(a)Make a method for theCustomerclass that that will return a string representing a bill notice when passed adoublevalue representing an amount due.

For example, if the customer has name"Jeremiah", has account number3, and has amount due50.50, the method should return a string in the following format.

Jeremiah, account number 3, please pay $50.50

Write the method below. Your implementation must conform to the example above.

(b)Make a method for theCustomerclass that returns the value of the next account number that will be assigned.

Write the method below.

(c)A student has written the following method to be included in theCustomerclass. The method is intended to update the name of a customer but does not work as intended.

public void updateName(String name)

{

name = name;

}

Make a correct implementation of theupdateNamemethod that avoids the error in the student's implementation.

Write the method below.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions

Question

In evolutionary terms with is the oldest pat of the brain ?

Answered: 1 week ago

Question

The limbic system includes?

Answered: 1 week ago

Question

Which is the most common neurotransmitter in the brain?

Answered: 1 week ago

Question

What was new York's original name?

Answered: 1 week ago