Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help with Java coding Write a Java class named Pencil.java to represent a pencil type Create a new Java class named Pencil that
I need help with Java coding
Write a Java class named Pencil.java to represent a pencil type Create a new Java class named Pencil that has the following fields: color, brand, price (use appropriate data type) In addition, the Pencil class should have the following methods. Constructor - The constructor should accept the color, brand, price as arguments These values should be used to initialize the pencil color, brand, and price Getter Methods and setter methods for all instance variables to String method which returns info about the pencil in the following format: Pencil Color Brand unit Price For example exist0.90 Black BIC Create a class named PencilBox. There are 10 pencils in each PencileBox with two mixed colors (at your choice). The PencilBox has the following fields and methods Pencil type1, Pencil type2, int gty1, int qty2 Constructor (Pencil type1 int qty1, Pencil type 2, int qty2) getter and setter methods a method:public double grandTotal() which returns grand total cost (total price of the pencils in a pencilBox) overwrite the toString method which returns the info about pencils in the box. For example there are 5 brown and 5 black color pencils in a pencilBox, the unit price for a brown color pencil is exist0.90 and exist0.80 for black ones. Then the toString method return a String as shown below: Brown BIC exist4.50 Black CIS201 exist4.00 Write driver (tester) class named School Bag.java that uses your Pencil and PencilBox class: create two pencil objects create a PencilBox object that uses the pencil object created in step 1 print out th pencilBox as followsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started