Question

Use java and continue stage 2 and 3
the in to The objective of the second stage is to develop a Cash Register application which will utilize th developed in Stag

Each class will contain a static variable which will store the total BabyType cost and total BabyType tax type (if applicable

Stage 3: Prompt the user for a receipt file name, write the contents of the receipt to the text file. The objective of this t

stage 1 code 
public abstract class BabyItem {



    protected String name;



    public BabyItem() {

        name="";

    }



    public BabyItem(String name) {

        this.name = name;

    }



    public String getName() {

        return name;

    }



    public void setName(String name) {



    }



    public abstract double getCost();

}

========================================================================================

public class BabyFood extends BabyItem {



    private int numberOfJars;

    private double pricePerDozen;



    public BabyFood() {

        super();

        numberOfJars = 0;

        pricePerDozen = 0;

    }



    public BabyFood(int numberOfJars, double pricePerDozen) {

        this.numberOfJars = numberOfJars;

        this.pricePerDozen = pricePerDozen;

    }



    public BabyFood(String name, int numberOfJars, double pricePerDozen) {

        super(name);

        this.numberOfJars = numberOfJars;

        this.pricePerDozen = pricePerDozen;

    }



    @Override

    public double getCost() {

        return numberOfJars * pricePerDozen / 12;

    }



    public double getPricePerDozen() {

        return pricePerDozen;

    }



    public int getNumberOfJars() {

        return numberOfJars;

    }



    public void setPricePerDozen(double pricePerDozen) {

        this.pricePerDozen = pricePerDozen;

    }



    public void setNumberOfJars(int numberOfJars) {

        this.numberOfJars = numberOfJars;

    }



    @Override

    public String toString() {

        String description;

        description = getName() + "\t\t\t\t$" + String.format("%.2f", getCost());

        description += "\n" + "\t" + getNumberOfJars() + " jars @ " + getPricePerDozen() + " per Dozen";

        return description;

    }

}

========================================================================================

public class BabyClothes extends BabyItem {



    private int quantity;

    private double pricePerItem;



    public BabyClothes(){

        super();

        quantity=0;

        pricePerItem=0.0;

    }



    public BabyClothes(int quantity, double pricePerItem) {

        this.quantity = quantity;

        this.pricePerItem = pricePerItem;

    }



    public BabyClothes(String name, int quantity, double pricePerItem) {

        super(name);

        this.quantity = quantity;

        this.pricePerItem = pricePerItem;

    }



    @Override

    public double getCost() {

        return getQuantity()*getPricePerItem();

    }



    public double getPricePerItem() {

        return pricePerItem;

    }



    public int getQuantity() {

        return quantity;

    }



    public void setPricePerItem(double pricePerItem) {

        this.pricePerItem = pricePerItem;

    }
    public void setQuantity(int quantity) {

        this.quantity = quantity;  }
    @Override

    public String toString() {

        String description;

        description = getName() + "\t\t\t\t$" + String.format("%.2f", getCost());

        description += "\n" + "\t" + getQuantity() + " each @ $" +String.format("%.2f",getPricePerItem());

        return description;

    }

}

========================================================================================

public class BabyToy extends BabyItem {
 private int quantity;
 private double pricePerToy;
 private double accessoryPrice;
 public BabyToy(){
 super();
 quantity=0;
 pricePerToy=0.0;
 accessoryPrice=0.0;
 }
 public BabyToy(int quantity, double pricePerToy, double accessoryPrice) {
 this.quantity = quantity;
this.pricePerToy = pricePerToy;
this.accessoryPrice = accessoryPrice;
 }
 public BabyToy(String name, int quantity, double pricePerToy, double accessoryPrice) {
 super(name);
 this.quantity = quantity;
 this.pricePerToy = pricePerToy;
 this.accessoryPrice = accessoryPrice;

    }
 @Override
 public double getCost() {
 return quantity*pricePerToy+accessoryPrice;

    }
 public int getQuantity() {
 return quantity;

    }
  public double getPricePerToy() {
 return pricePerToy;

    }
 public double getAccessoryPrice() {
 return accessoryPrice;

    }



    public void setQuantity(int quantity) {

        this.quantity = quantity;

    }



    public void setPricePerToy(double pricePerToy) {

        this.pricePerToy = pricePerToy;

    }



    public void setAccessoryPrice(double accessoryPrice) {

        this.accessoryPrice = accessoryPrice;

    }



    @Override

    public String toString() {

        String description;

        description = getName() + "\t\t\t\t$" + String.format("%.2f", getCost());

        description += "\n" + "\t" + getQuantity() + " toys @ " +String.format("%.2f",getPricePerToy()+

                "/each + "+getAccessoryPrice());

        return description;

    }

}

Stage 2: Enhance the classes defined in Stage 1 to develop a Cash Register Application

The objective of the second stage is to develop a Cash Register application which will utilize the classes developed in Stage 1.

Stage 2: Task(s)

The programmer will use and extend the classes and methods developed in Stage 1 to develop a Cash Register type of application. This application will declare an enumerated type ‘BabyType’, which will be used in a switch statement to determine which action needs to be taken.

Depending on the BabyType, the program should prompt for specific details in order to calculate the price for each item.

FOOD

Prompt for Name of Food, the Number of Jars and the Price per Dozen of Jars

CLOTHES

Prompt for Name of Clothes, the number of clothes and price per item

TOY

Prompt for Name of the Toy, the Number of Toys, the Price of Each and the Price of any Accessories

The application should be called ‘BabyShop’, which will prompt the user for items to purchase one at a time. This application will prompt the user for the name of the product. If no name is entered, the application will calculate the total cost of items entered.

The application will define three arrays for each BabyType, which can store up to 5 items each.

Each derived class will contain a static variable which will store the total BabyType cost and total BabyType tax (if applicable) for that specific BabyType. The CLOTHES and TOYS baby types are taxable at 7%. The FOOD type is non-taxable. As each BabyType item is added, the cost and tax should be added to the individual BabyType static values.

The BabyItem superclass will also contain a total cost and total tax static variable that will be shared between all items that were derived from that superclass. As each BabyType item is added, the cost and tax should be added to the BabyItem static values.

Upon entering all items, the application should print out a summary of all purchased BabyItem, along with the count, the cost and tax. (See Sample Output)

Stage 2: Sample Output

Baby Shirt $ 8.98 [Tax: $0.63]

2.00 @ $4.49

Burp Cloth $ 0.75 [Tax: $0.05]

0.50 lbs @ $1.50

Strained Pea $ 1.33 [Tax: $0.09]

4 jars @ $3.99 per Dozen

Teething Cookies $ 4.25 [Tax: $0.30]

12 cookies @ $4.25 per Dozen

Lego’s $ 2.75

2 toys @ $1.05 + $0.65

Baby Dolls $ 5.29

3 toys @ $1.33 + $1.30

CLOTHES [ 2] Cost: $ 9.73 Tax: $0.68

FOOD [ 2] Cost: $ 5.58 Tax: $0.39

TOYS [ 2] Cost: $ 8.04

---- -------- -----

Subtotals [ 6] $23.35 $1.07

========

Total $24.42

Stage 3: Prompt the user for a receipt file name, write the contents of the receipt to the text file.

The objective of this third stage is to save the receipt information to a text file.

Stage 3: Task(s)

The objective of this third stage is to enhance the application developed in stage 2 to prompt for a filename to store the receipt information. Upon entering the receipt, the receipt contents developed in stage 2 will be output to the text file.

The application should create a NoItemsEnteredException. The application should create a static method called itemsEntered which returns the total number of items purchased. If there are no items, the method should throw the NoItemsEnteredException.

the in to The objective of the second stage is to develop a Cash Register application which will utilize th developed in Stage 1. Stage 2: Task(s) The programmer will use and extend the classes and methods developed in Stage 1 to develop a Cash Reg ister type of application. T his application will declare an enumerated type 'BabyType', which will be used in a switch Depending on the BabyType, the program should prompt for specific details in order to calculate the price for each item FOOD Prompt for Name of Food, the Number of Jars and the Price per Dozen of Jars Prompt for Name of Clothes, the number of clothes and price per item TOY Prompt for Name of the Toy, the Number of Toys, the Price of Each and the Price of any Accessories The application should be called 'Babyshop, which will prompt the user for items to purchase one at a time. This application will prompt the user for the name of the product. If no name is entered, the application will calculate the total cost of items entered. The application will define three arrays for each BabyType, which can store up to 5 items each. 2| Page
Each class will contain a static variable which will store the total BabyType cost and total BabyType tax type (if applicable) for that specific BabyType. The CLOTHES and TOYS baby types are taxable at 7%. The FOOD is non-taxable. As each BabyType item is added, the cost and tax should be added to the individual BabyT ype static values. The Babyltem superclass will also contain a total cost and total tax static variable that will be shared between all items that were derived from that superclass. As each BabyType item is added, the cost and tax should be added to the Babyltem static values. Upon entering all items, the application should print out a summary of all purchased Babyltem, along with the count, the cost and tax. (See Sample Output) Baby Shirt 2.00 e $4.49 $ 8.98 [Tax: $0.63] 0.75 [Tax: $0.05] Burp Cloth 0.50 lbs $1.50 Strained Pea 4 jars $3.99 per Dozen Teething Cookies 12 cookies $4.25 per Dozen Lego's 2 toys e $1.05 $0.65 Baby Dol1s 3 toys $1.33 $1.30 $ 1.33 [Tax: $0.09] s 4.25 (Tax: $0.30] s 2.75 s 5.29 Cost: $ 9.73 Tax: $0.68 Cost: 5.58 Tax: $0.39 Cost: $ 8.04 I 21 I 21 I 21 CLOTHES FOOD TOYS $1.07 6] $23.35 Subtotals $24.42 Total
Stage 3: Prompt the user for a receipt file name, write the contents of the receipt to the text file. The objective of this third stage is to save the receipt information to a text file e 3: Task(s) The objective of this third stage is to enhance the application developed in stage 2 to prompt for a filename to store the receipt information. Upon entering the receipt, the receipt contents developed in stage 2 will be output to the text file. The application should create a NoltemsEnteredException. The application should create a static method called itemsEntered which returns the total number of items purchased. If there are no items, the method should throw the NoltemsEnteredException t Evalu Your assignment will be graded based upon all tasks being performed and handed in with all required documentation Points 10 points 10 points Definition of the abstract Babyltem superclass Proper implementation of static variables for storing superclass cost and tax, as well as each individual derived cost and tax Definition of enumerated BabyType and use of switch statement to determine actions required Use of Arrays for storing up to 5 items of the four different BabyType's Definition of the BabyFood derived class Definition of the BabyClothes derived class 5 points 5 points 5 points 5 points 5 points Definition of the BabyToy derived class Proper output of itemized purchases Integration of ItemsEntered method Proper implementation and use of NoltemsEnteredException Properly saving receipt information to Text file 5 points 5 points 5 point 10 points Proper
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Clas Comput c Comp lan Laptop Youbneuo Laptopt) my. compute method C) laPtop )

Add a comment
Know the answer?
Add Answer to:
Use java and continue stage 2 and 3 stage 1 code public abstract class BabyItem { protected String 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
  • What is output? public abstract class People { protected string name; protected int age; public abstract...

    What is output? public abstract class People { protected string name; protected int age; public abstract void PrintInfo(); public void PrintInformation() { System.out.println("In Base Class People"); public class Teacher extends People { private int experience; public void PrintInfo() { System.out.println("In Child Class Teacher"); public class Principal extends Teacher { public void PrintInformation() { System.out.println("In Child Class Principal"); public static void main(String args[]) { Principal tim; tim = new Principal(); tim.PrintInfo(); In Base Class People Error: Compiler error In Child Class...

  • in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "Ret...

    in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "RetailItem" class which simulates the sale of a retail item. It should have a constructor that accepts a "RetailItem" object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. Your class should have these methods: getSubtotal: returns the subtotal of the sale, which is quantity times price....

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • Cant figure out how to fix error Code- import java.io.File; import java.io.IOException; import java.util.*; public class Program8 {    public static void main(String[] args)throws IOException{       ...

    Cant figure out how to fix error Code- import java.io.File; import java.io.IOException; import java.util.*; public class Program8 {    public static void main(String[] args)throws IOException{        File prg8 = new File("program8.txt");        Scanner reader = new Scanner(prg8);        String cName = "";        int cID = 0;        double bill = 0.0;        String email = "";        double nExempt = 0.0;        String tExempt = "";        int x = 0;        int j = 1;        while(reader.hasNextInt()) {            x = reader.nextInt();}        Customers c1 [] = new Customers [x];        for (int...

  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {    super();    System.out.println(“B() called”);...

  • For Questions 1-3: consider the following code: public class A { private int number; protected String...

    For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {   super();   System.out.println(“B() called”); } public...

  • Need Help....Java MyProgram.java: public class MyProgram { public static void main(String[] args) { } } House.java:...

    Need Help....Java MyProgram.java: public class MyProgram { public static void main(String[] args) { } } House.java: public class House { private String address; private double cost; private double interst; private int mortgageTime; private double monthPayment; } As you consider your life before you, one thing you may consider is buying a house in the future. In this assignment, you will explore concepts of this amazing opportunity and create a program that may be of benefit to you in the future!...

  • In Java. Please use the provided code Homework 5 Code: public class Hw05Source { public static...

    In Java. Please use the provided code Homework 5 Code: public class Hw05Source { public static void main(String[] args) { String[] equations ={"Divide 100.0 50.0", "Add 25.0 92.0", "Subtract 225.0 17.0", "Multiply 11.0 3.0"}; CalculateHelper helper= new CalculateHelper(); for (int i = 0;i { helper.process(equations[i]); helper.calculate(); System.out.println(helper); } } } //========================================== public class MathEquation { double leftValue; double rightValue; double result; char opCode='a'; private MathEquation(){ } public MathEquation(char opCode) { this(); this.opCode = opCode; } public MathEquation(char opCode,double leftVal,double rightValue){...

  • Some java questions: 18. Consider the following class definitions public class TestAB public static void main (String a...

    Some java questions: 18. Consider the following class definitions public class TestAB public static void main (String args) A bl new B() в ь2 -new B() ; b1.х, А.у, Ь2.х, в.у); System.out.printf ("%d, Sd, %d, d\n", class A public int x = 2; public static int y = 4; public A () ( X=y- class Bextends A public int x = 32; public static int y = 45; public B ( x ++y What is the result of attempting to...

  • Java Inventory Management Code Question

    Inventory ManagementObjectives:Use inheritance to create base and child classesUtilize multiple classes in the same programPerform standard input validationImplement a solution that uses polymorphismProblem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes...

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
ADVERTISEMENT