Question
Our teacher wants us to use a class and a driver class for this problem.
Band Booster Class In this exercise, you will write a class that models a band booster and use your class to update sales of band candy. . Write the BandBooster class assuming a band booster object is described by two pieces of instanced name (a String) and boxes Sold (an integer that represents the number of boxes of band candy the booster has sold in the band fundraiser). The class should have the following methods: A constructor that has one parameter -a String containing the name of the band booster. The constructor should set boxesSold to 0 A method getName that returns the name of the band booster (it has no parameters). A method update Sales that takes a single integer parameter representing the number of additional boxes of candy sold. The method should add this number to boxesSold.int prveintbores A toString method that returns a string containing the name of the band booster and the number of boxes of candy sold in a format similar to the following: Joe: 16 boxes Write a program that uses BandBooster objects to track the sales of 2 band boosters over 3 weeks. Your program should do the following: Read in the names of the two band boosters and construct an object for each. Prompt for and read in the number of boxes sold by each booster for each of the three weeks. Your prompts should include the boosters name as stored in the BandBooster object. For example, Bnter, the nunpey of boxes sold by doe this veek For each member, after reading in the weekly sales, invoke the updateSales method to update the total sales by that member. After reading the data, print the name and total sales for each member (you will implicitly use the toString method here).
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note:

Please find the below BandBooster and BandBoosterDriver classes. Also find the sample output.

Please revert back in case of any concerns.

Program:

BandBooster Class


public class BandBooster {
private String name;
private int boxesSold;
public BandBooster(String name) {
this.name = name;
this.boxesSold = 0;
}
public String getName() {
return name;
}
public void updateSales(int boxes) {
this.boxesSold = this.boxesSold + boxes;
}
@Override
public String toString() {
return name + ": " + boxesSold + " boxes";
}
}

BandBoosterDriver Class


import java.util.Scanner;
public class BandBoosterDriver {
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
System.out.print("Enter the name of the band booster: ");
String boosterName1 = userInput.nextLine();
BandBooster booster1 = new BandBooster(boosterName1);
System.out.print("Enter the number of boxes sold by "+booster1.getName()+" this week: ");
int boxesCount1 = userInput.nextInt();
userInput.nextLine();
booster1.updateSales(boxesCount1);
System.out.print("\nEnter the name of the band booster: ");
String boosterName2 = userInput.nextLine();
BandBooster booster2 = new BandBooster(boosterName2);
System.out.print("Enter the number of boxes sold by "+booster2.getName()+" this week: ");
int boxesCount2 = userInput.nextInt();
userInput.nextLine();
booster2.updateSales(boxesCount2);
System.out.println("\nSales Information:");
System.out.println(booster1);
System.out.println(booster2);
userInput.close();
}
}

Output:

Enter the name of the band booster: Joe
Enter the number of boxes sold by Joe this week: 16

Enter the name of the band booster: Jim
Enter the number of boxes sold by Jim this week: 18

Sales Information:
Joe: 16 boxes
Jim: 18 boxes

Syste,.cut-9rlnt4Bter the nase ot the band booster! the band boostei

Add a comment
Know the answer?
Add Answer to:
Our teacher wants us to use a class and a driver class for this problem. Band...
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
  • Deliverable A zipped NetBeans project with 2 classes app ZipCode Address Classes Suggestion: Use Netbeans to...

    Deliverable A zipped NetBeans project with 2 classes app ZipCode Address Classes Suggestion: Use Netbeans to copy your last lab (Lab 03) to a new project called Lab04. Close Lab03. Work on the new Lab04 project then. The Address Class Attributes int number String name String type ZipCode zip String state Constructors one constructor with no input parameters since it doesn't receive any input values, you need to use the default values below: number - 0 name - "N/A" type...

  • In C++, Step 1: Implement the Student Class and write a simple main() driver program to...

    In C++, Step 1: Implement the Student Class and write a simple main() driver program to instantiate several objects of this class, populate each object, and display the information for each object. The defintion of the student class should be written in an individual header (i.e. student.h) file and the implementation of the methods of the student class should be written in a corresponding source (i.e. student.cpp) file. Student class - The name of the class should be Student. -...

  • Java: Create a class called Vehicle with the following features: a. It has three private data...

    Java: Create a class called Vehicle with the following features: a. It has three private data members (instance variables): one is the manufacturer’s name (String manufacturer), the second is the number of cylinders in the engine (int cylinder), and the third is the owner (Person owner). The class Person is described above. b. It has three constructors, a no-argument constructor, a constructor with three parameters, and a copy constructor. The no-argument constructor will set the manufacturer to “None”, cylinder to...

  • Make a LandTract class with the following fields: LandTract is a rectangle. * length - an...

    Make a LandTract class with the following fields: LandTract is a rectangle. * length - an int containing the tract's length * width - an int containing the tract's width The class should have a constructor with two arguments length and width and assign these to the class variables. Now define a Copy Constructor: The constructor that you will write will be a copy constructor that uses the parameter LandTract object to make a duplicate LandTract object, by copying the...

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

  • QUESTION 5 (15 Marks) Inheritance and Polymorphism Design a Ship class that has the following members:...

    QUESTION 5 (15 Marks) Inheritance and Polymorphism Design a Ship class that has the following members: • A private String data field named name for the name of the ship. • A private String data field named yearBuilt for the year that the ship was built. • A constructor that creates a ship with the specified name and the specified year that the ship was built. • Appropriate getter and setter methods. A toString method that overrides the toString method...

  • Here is a sample run of the tester program: Make sure your program follows the Java...

    Here is a sample run of the tester program: Make sure your program follows the Java Coding Guidelines. Consider the following class: /** * A store superclass with a Name and Sales Tax Rate */ public class Store {      public final double SALES_TAX_RATE = 0.06;      private String name;           /**      * Constructor to create a new store      * @param newName      */      public Store(String newName)      {           name = newName;      }     ...

  • Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super...

    Java Program (PLEASE PROVIDE SCREENSHOT OF THE CODE) Create a class Person which is a super class. The class includes four private String instance variables: first name, last name, social security number, and state. Write a constructor and get methods for each instance variable. Also, add a toString method to print the details of the person. After that create a class Teacher which extends the class, Person. Add a private instance variable to store number of courses. Write a constructor...

  • using CSCI300 java Given the following UML Class Diagram Club_Card # card_num : String # name...

    using CSCI300 java Given the following UML Class Diagram Club_Card # card_num : String # name : String # age: int # year: int + Club_Card (all parameters) + Setters & Getters + toString() : String + equals(x: Object): boolean [10 pts] Define the class Club_Card, which contains: 1. All arguments constructor which accepts all required arguments from the main and instantiate a Club_Card object. 2. Set & get method for each data attribute. 3. A toString() method which returns...

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

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