Advanced Placement (AP)

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.

answer
Answers: 2

Other questions on the subject: Advanced Placement (AP)

image
Advanced Placement (AP), 27.06.2019 08:00, santos200154
Thayer sometimes finds it difficult to understand what his instructor is saying. he raises his hand in class and asks his instructor to elaborate on what was just said, but it rarely . what should thayer do to overcome this obstacle? a. during class, ask other students what the instructor means b. raise more questions in class c. join a study group of his peers d. try to do the best he can with the information he has
Answers: 1
image
Advanced Placement (AP), 27.06.2019 13:00, 92terbes
Which part of the muscular and skeletal system work together to move muscles and bones?
Answers: 1
image
Advanced Placement (AP), 28.06.2019 07:30, jtmoney10
What type of power generation can cause air pollution a. wind b. natural gas c. geothermal d. solar
Answers: 2
image
Advanced Placement (AP), 29.06.2019 08:00, sighgabbie
In order to be proud of who you are, you must a. be the most popular student in your class b. embrace your culture and background c. be afraid to show others who you are d. embrace people who are unkind to you
Answers: 1
Do you know the correct 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, 12.01.2020 07:31