subject

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 not null and 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 variable name represents the name of the customer, and the variable currAccNum represents the customer’s account number. Each time a Customer object is created, the static variable nextAccNum is 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) Write a method for the Customer class that that will return a string representing a bill notice when passed a double value representing an amount due.

For example, if the customer has name "Jeremiah", has account number 3, and has amount due 50.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) Write a method for the Customer class 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 the Customer class. The method is intended to update the name of a customer but does not work as intended.

public void updateName(String name)
{
name = name;
}
Write a correct implementation of the updateName method that avoids the error in the student’s implementation.

Write the method below.

ansver
Answers: 2

Other questions on the subject: Advanced Placement (AP)

image
Advanced Placement (AP), 24.06.2019 18:00, jhart2876
Ap courses are college level courses overseen by the
Answers: 1
image
Advanced Placement (AP), 26.06.2019 13:50, rhlalbin
Which of the following activities would conserve the most energy? installing a dimmer switch on a light using a blender instead of a food processor hanging clothes to dry on a clothesline instead of ironing them opening a window instead of turning on the air conditioning setting your computer's screen saver to turn on after less time has elapsed
Answers: 1
image
Advanced Placement (AP), 27.06.2019 04:30, TheRealKodakBlack
To what condition is a stable family life, strong focus on education, and assimilation into the mainstream culture linked for minorities? a. mental well-being b. interracial marriage c. healthier relationships d. economic success
Answers: 1
image
Advanced Placement (AP), 28.06.2019 05:30, laurynrobinson21
Critics claim that the biological theory of personality may be problematic for research due to which of the following? a. there is already too much theoretical work concerning biological influences on personality. b. biological influences on personality are impossible to scientifically research. c. the biological theory provides little structure to direct or guide research. d. biological theorists have had difficulty establishing supportive research for the biological perspective.
Answers: 1
You know the right answer?
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the class...

Questions in other subjects:

Konu
Mathematics, 05.11.2020 07:40
Konu
Biology, 05.11.2020 07:40