Question

Classes A Customer Points class maintains information about a customer. This information is the customer name (entire name as
Complete the Customer Points class by filling in the blank boxes: Customer Points myName; myPoints; (String the Name) { = the
1 public void reducePoints(int thePoints) { if (myPoints < 0) { =0; 1 public toString() { return
0 0
Add a comment Improve this question Transcribed image text
Answer #1

input code:

public class Customer Points{ /*declare the variables*/ public String my Name; public int myPoints; /*constructori/ public Cu

public static void main(String[] args) { /*make object of CustomerPoints/ Customer Points cust=new Customer Points(Carl); /

output:

Carl 0 Carl 17 Carl 15 Carl 0 ... Program finished with excit code 0 Press ENTER to exit console. I

code:

public class CustomerPoints{
/*declare the variables*/
public String myName;
public int myPoints;
/*constructor*/
public CustomerPoints(String theName)
{
myName=theName;
myPoints=0;
}
/*return the myName*/
public String getName()
{
return myName;
}
/*return the myPoints*/
public int getPoints()
{
return myPoints;
}
/*make points to zero*/
public void clearPoints()
{
myPoints=0;
}
/*add points into current points*/
public void addPoints(int thePoints)
{
myPoints+=thePoints;
}
/*substract points from myPoints*/
public void reducePoints(int thePoints)
{
myPoints-=thePoints;
/*and if it is goes less than zero than set to 0*/
if(myPoints<0)
{
myPoints=0;
}
}
/*Override toString method*/
public String toString()
{
return myName+" "+myPoints;
}

   public static void main(String[] args) {
/*make object of CustomerPoints*/
   CustomerPoints cust=new CustomerPoints("Carl");
       /*print */
       System.out.println(cust);
       /*add values*/
       cust.addPoints(5);
       cust.addPoints(12);
       System.out.println(cust);
       /*remove values*/
       cust.reducePoints(2);
       System.out.println(cust);
       /*clear values*/
       cust.clearPoints();
       /*prin the output*/
       System.out.println(cust);
   }
}

blanks:

public class CustomerPoints /*declare the variables*/ public String myName; public int myPoints; /* constructor*/ public Cust

Add a comment
Know the answer?
Add Answer to:
Classes A Customer Points class maintains information about a customer. This information is the customer name...
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
  • 4. Command pattern //class Stock public class Stock { private String name; private double price; public...

    4. Command pattern //class Stock public class Stock { private String name; private double price; public Product(String name, double price) { this.name = name; this.price = price; } public void buy(int quantity){ System.out.println(“BOUGHT: “ + quantity + “x “ + this); } public void sell(int quantity){ System.out.println(“SOLD: “ + quantity + “x “ + this); } public String toString() { return “Product [name=” + name + “, price=” + price + “]”; } } a. Create two command classes that...

  • JAVA /** * This class stores information about an instructor. */ public class Instructor { private...

    JAVA /** * This class stores information about an instructor. */ public class Instructor { private String lastName, // Last name firstName, // First name officeNumber; // Office number /** * This constructor accepts arguments for the * last name, first name, and office number. */ public Instructor(String lname, String fname, String office) { lastName = lname; firstName = fname; officeNumber = office; } /** * The set method sets each field. */ public void set(String lname, String fname, String...

  • Add additional information to the student class below such as name, address, major, and contact information...

    Add additional information to the student class below such as name, address, major, and contact information along with all the getters and setters (methods) needed to access all data. Submit your code along with a sample run of your program. Comment all your code. Cite any sources of information you use. Write a note on the process of completing the assignment in a Microsoft Word document. // ShowStudent.java // client to test the Student class class ShowStudent { public static...

  • Add additional information to the student class below such as name, address, major, and contact information...

    Add additional information to the student class below such as name, address, major, and contact information along with all the getters and setters (methods) needed to access all data. Submit your code along with a sample run of your program. Comment all your code. Cite any sources of information you use. Write a note on the process of completing the assignment in a Microsoft Word document. // ShowStudent.java // client to test the Student class class ShowStudent { public static...

  • Correct the mistakes public class customer { public static void main(String[] args) { D customer=new d();...

    Correct the mistakes public class customer { public static void main(String[] args) { D customer=new d(); d.employee(56,”ali”); d.department(7,8.6,9); } public void employee(String name, int age) { System.out.println("Your name is"+name); System.out.println(“Age is”+age); } public int department(double d, double t, int a) { System.out.println("I have java exam at 3:00"); Return(1.1); } } V. PROGRAMMING. Write a complete JAVA program to implement the following. 1. Create a class named Exponent. Its main() method accepts an integer value from a user at the keyboard,...

  • This is my playlist class: class Playlist{       private String name;    private int numberOfRecordings...

    This is my playlist class: class Playlist{       private String name;    private int numberOfRecordings = 0;    private int durationInSeconds = 0;    private int MAX_PLAYLIST_SIZE;    Recording recordingslist[];       Playlist(){        name = "Unknown";        MAX_PLAYLIST_SIZE = 5;        recordingslist = new Recording[MAX_PLAYLIST_SIZE];        durationInSeconds = 0;    }       Playlist(String name, int size){        this.name = name;        this.MAX_PLAYLIST_SIZE = size;        recordingslist = new Recording[MAX_PLAYLIST_SIZE];   ...

  • Use inheritance to create a new class AudioRecording based on Recording class that: it will retain...

    Use inheritance to create a new class AudioRecording based on Recording class that: it will retain all the members of the Recording class, it will have an additional field bitrate (non-integer numerical; it cannot be modified once set), its constructors (non-parametrized and parametrized) will set all the attributes / fields of this class (reuse code by utilizing superclass / parent class constructors): Non-parametrized constructor should set bitrate to zero, If arguments for the parametrized constructor are illegal or null, it...

  • In java 8. Modify the averageTopSpeed() method (in the class FormulaOne) using only lambdas and streams...

    In java 8. Modify the averageTopSpeed() method (in the class FormulaOne) using only lambdas and streams and print it to the terminal via the driver class: import java.util.*; public class Racer implements Comparable { private final String name; private final int year; private final int topSpeed;    public Racer(String name, int year, int topSpeed){    this.name = name; this.year = year; this.topSpeed = topSpeed;    }    public String toString(){    return name + "-" + year + ", Top...

  • In this assignment, we will be making a program that reads in customers' information, and create...

    In this assignment, we will be making a program that reads in customers' information, and create a movie theatre seating with a number of rows and columns specified by a user. Then it will attempt to assign each customer to a seat in a movie theatre. 1. First, you need to add one additional constructor method into Customer.java file. Method Description of the Method public Customer (String customerInfo) Constructs a Customer object using the string containing customer's info. Use the...

  • How to create a constructor that uses parameters from different classes? I have to create a...

    How to create a constructor that uses parameters from different classes? I have to create a constructor for the PrefferedCustomer class that takes parameters(name, address,phone number, customer id, mailing list status, purchase amount) but these parameters are in superclasses Person and Customer. I have to create an object like the example below....... PreferredCustomer preferredcustomer1 = new PreferredCustomer("John Adams", "Los Angeles, CA", "3235331234", 933, true, 400); System.out.println(preferredcustomer1.toString() + "\n"); public class Person { private String name; private String address; private long...

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