Use java and continue stage 2 and 3


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

Use java and continue stage 2 and 3 stage 1 code public abstract class BabyItem { protected String name;...
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 "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 {
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)...
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 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...
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...
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 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 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...
Companies and people often buy and sell stocks. Often, they buy the same stock for different prices at different times. Say a person owns 1000 shares a certain stock (such as Google) he/she may have bought the stock in amounts of 100 shares over 10 different times with 10 different prices. We will analyze two different methods of accounting, FIFO and LIFO accounting used for determining the “cost” of a stock. This information is typically calculated when a stock is...