SlideShare a Scribd company logo
1 of 17
Download to read offline
These are the outputs which should match they are 4 of them :-
output 1 -
output 2 -
output 3 -
output 4 -
Here is the Assingment5.java file can make changes to it :-
You are required, but not limited, to turn in the following source files:
Assignment5.java (Download this file and use it as your driver program for this assignment. You
need to add more codes to complete it.)
Soup.java
SoupInBox.java
SoupInCylinder.java
SoupParser.java
Requirements to get full credits in Documentation
The assignment number, your name, StudentID, Lecture number/time, and a class description
need to be included at the top of each class/file.
A description of each method is also needed.
Some additional comments inside of methods (especially for a "main" method) to explain code
that are hard to follow should be written.
You can look at Java programs in the text book to see how comments are added to programs.
Skills to be Applied
In addition to what has been covered in previous assignments, the use of the following items,
discussed in class, will probably be needed:
Inheritance
The protected modifier
The super Reference
Abstract class
NumberFormat/DecimalFormat
Wrapper classes
ArrayList
Program Description
Class Diagram:
In Assignment #5, you will need to make use of inheritance by creating a class hierarchy for
vehicles.
Soup is an abstract class, which represents the basic attributes of any soup in a container to be
sold. It is used as the root of the soup hierarchy. It has the following attributes (should be
protected):
Attribute name
Attribute type
Description
volume
int
The volume of the soup
unitPrice
double
The price per unit of the soup
totalPrice
double
The total price of the soup
soupId
String
The Id of the soup
The following constructor method should be provided to initialize the instance variables.
publicSoup(String id, double someUnitPrice)
The instance variable volume is initialized to 0, totalPrice is initialized to 0.0, unitPrice is
initialized to the value of the second parameter, and soupId is initialized to the string value of the
first parameter.
The following accessor method should be provided for soupId :
publicString getSoupId()
The Class Soup also has an abstract method (which should be implemented by its child classes,
SoupInCylinder and SoupInBox) to compute the volume of the soup:
publicabstract void computeTotalPrice();
The following public method should be provided:
publicString toString()
toString method returns a string of the following format:
 The SoupId:tttomatosoup591
The Volume:tt150
The Unit Price:tt0.0015
The Total Price:t$330.00
You should make use of the NumberFormat class and DecimalFormat (in java.text package) to
format the total price in the dollar format (NumberFormat) and the unit price using 4 digits after
their decimal point (DecimalFormat using "0.0000").
SoupInCylinder class
SoupInCylinder is a subclass of Soup class. It represents a soup in a can (cylinder). It has the
following attribute in addition to the inherited ones:
Attribute name
Attribute type
Description
radius
int
The radius of the cylinder of the soup.
height
int
The height of the cylinder of the soup.
The following constructor method should be provided:
publicSoupInCylinder(String id, double someUnitPrice, int someRadius, int someHeight)
The radius is initialized to the value of the third parameter, the height is initialized to the value of
the forth parameter, and the constructor of the parent class Soup should be called using the first
and second parameters. Leave volume and totalPrice as their default values (defined in the
parent’s constructor).
The following method should be implemented:
publicvoid computeTotalPrice()
First, it computes the volume for the cylinder of the soup. (computed by
PI*(radius*radius*height), the constant value PI is defined in the Math class. -- (int)
(Math.PI*(radius*radius*height)) Also, compute (radius*radius*height) first since they are all
integers. PI is a float point number, so you need to cast the final value to an integer ("volume"
is an integer.) Then compute the total price of the soup. (computed by volume * unitPrice)
Also, the following method should be implemented:
publicString toString()
The toString() method inherited from Soup class should be used to create a new string, and
display a cylinder soup's information using the following format:
 TheSoup in a Cylinder
The Radius:tt5
The Height:tt10
The SoupId:tttomatosoup591
The Volume:tt785
The Unit Price:tt0.0022
The Total Price:t$1.73 
This toString method should make use of the toString method of the parent class.
SoupInBox class
SoupInBox is a subclass of Soup class. It represents a soup in a carton. It has the following
attributes:
Attribute name
Attribute type
Description
height
int
The height of the box of the soup.
width
int
The width of the box of the soup.
depth
int
The depth of the box of the soup.
The following constructor method should be provided:
publicSoupInBox(String id, double someUnitPrice, int someHeight, int someWidth, int
someDepth)
The height, width, depth are initialized to the value of the third parameter, the fourth parameter,
and the fifth parameter, respectively, and the constructor of the parent class Soup should be
called using the first and second parameters. Leave volume and totalPrice as their default value.
The following method should be implemented:
publicvoid computeTotalPrice()
First, it computes the volume of the box of the soup. (computed by height*width*depth)
Then compute the total price of the soup. (computed by volume * unitPrice)
Also, the following method should be implemented:
publicString toString()
The toString() method inherited from the Soup class should be used to create a new string, and
display a box soup's information using the following format:
 TheSoup in a Box
The Height:tt5
The Width:tt10
The Depth:tt5
The SoupId:ttsplitPeaSoup515
The Volume:tt250
The Unit Price:tt0.0055
The Total Price:t$1.38 
This toString method should make use of the toString method of the parent class.
SoupParser class
The SoupParser class is a utility class that will be used to create a soup object (either a cylinder
soup object or a box soup object) from a parsable string. The SoupParser class object will never
be instantiated. It must have the following method:
publicstatic Soup parseStringToSoup(String lineToParse)
The parseStringToSoup method's argument will be a string in the following format:
For a cylinder soup,
shape/soupId/unitPrice/radius/height
For a box soup,
shape/soupId/unitPrice/height/width/depth
A real example of this string would be:
Cylinder/tomateSoup514/0.0054/5/10
OR
Box/splitPeaSoup7192/0.0035/10/15/10
This method will parse this string, pull out the information, create a new SoupInCylinder or
SoupInBox object using their constructor with attributes of the object, and return it to the calling
method. The type will always be present and always be either Cylinder or Box. (It can be lower
case or upper case) You may add other methods to the SoupInCylinder and SoupInBox class in
order to make your life easier.
Assignment5 class
In this assignment, download Assignment5.java file by clicking the link, and use it for your
assignment. You need to add code to this file. The parts you need to add are written in the
Assignment5.java file, namely for the four cases "Add Soup", "Add Compute Total Prices",
"Search for Soup", and "List Soups".
All input and output should be handled here. The main method should start by displaying this
updated menu in this exact format:
ChoicettAction
------tt------
AttAdd Soup
CttCompute Total Prices
DttSearch for Soup
LttList Soups
QttQuit
?ttDisplay Help 
Next, the following prompt should be displayed:
What action would you like to perform?
Read in the user input and execute the appropriate command. After the execution of each
command, redisplay the prompt. Commands should be accepted in both lowercase and
uppercase.
Add Soup
Your program should display the following prompt:
Please enter a soup information to add:
Read in the information and parse it using the soup parser.
Then add the new soup object (created by soup parser) to the soup list.
Compute Total Prices
Your program should compute total price for all soups created so far by calling
computeTotalPrice method for each of them in the soup list.
After computing total prices, display the following:
totalprices computed
Search for Soup
Your program should display the following prompt:
Please enter a soupId to search:
Read in the string and look up the soup list, if there exists a soup object with the same soup ID,
then display the following:
soupfound
Otherwise, display this:
soupnot found
List Soups
List all soups in the soup list. Make use of toString method defined in SoupInBox and
SoupInCylinder classes.
A real example is looked like this:
The Soup in a Cylinder Container
The Radius: 5
The Height: 10
The SoupId: chickensoup200
The Volume: 0
The Unit Price: 0.0054
The Total Price: $0.00
The Soup in a Box Container
The Height: 10
The Width: 15
The Depth: 10
The SoupId: tomatosoup03
The Volume: 0
The Unit Price: 0.0035
The Total Price: $0.00
If there is no soup in the soup list (the list is empty), then display following:
nosoup
Quit
Your program should stop executing and output nothing.
Display Help
Your program should redisplay the "choice action" menu.
Invalid Command
If an invalid command is entered, display the following line:
Unknown action
Attribute name
Attribute type
Description
volume
int
The volume of the soup
unitPrice
double
The price per unit of the soup
totalPrice
double
The total price of the soup
soupId
String
The Id of the soup SoupParser parseString ToSoup(lineToParse String): Soup Arizona State
University, CSE205 Spring 2017, Assignment5 Assi nment +main(StringU): void +print
Menu0:void Souplncylinder radius :int -height: int +Souplncylinder(String,double,int,int)
ttoString0: String Sou #volume int 0 #unit Price:double #total Price: double 0.0 #soupld: String
Soup (String,double) tgetSoupld0: String +toString(): String compute Total Price() void
SouplnBox ght: int -width: int -depth: int tSoupInBox (String, nt ttoString0:String
Solution
Assignment.java:
package testProject;
// Assignment #: 5
//Arizona State University - CSE205
// Name: Your name
// StudentID: Your id
// Lecture: Your lecture time (for instance, MWF 10:40am)
//Description: The Assignment 5 class displays a menu of choices
// (add cylinder soup, box soup,search soup,
// list soups, quit, display menu) to a user
// and performs the chosen task. It will keep asking a user to
// enter the next choice until the choice of 'Q' (Quit) is
// entered.
import java.io.*; //to use InputStreamReader and BufferedReader
import java.text.NumberFormat;
import java.util.*; //to use ArrayList
public class Assignment5
{
public static void main (String[] args)
{
char input1;
String inputInfo = new String();
String line = new String();
boolean operation;
// ArrayList object is used to store soup objects
ArrayList soupList = new ArrayList();
try
{
printMenu(); // print out menu
// create a BufferedReader object to read input from a keyboard
InputStreamReader isr = new InputStreamReader (System.in);
BufferedReader stdin = new BufferedReader (isr);
do
{
System.out.println("What action would you like to perform?");
line = stdin.readLine().trim();
input1 = line.charAt(0);
input1 = Character.toUpperCase(input1);
if (line.length() == 1)
{
switch (input1)
{
case 'A': //Add Soup
System.out.print("Please enter some soup information to add: ");
inputInfo = stdin.readLine().trim();
Soup someSoup=SoupParser.parseStringToSoup(inputInfo);
soupList.add(someSoup);
/*****************************************************************************
******
*** ADD your code here to create an object of one of child classes of Soup class
*** and add it to the soupList
*****************************************************************************
******/
break;
case 'C': //Compute Total Prices
for (Object object : soupList) {
Soup tempsoup=(Soup) object;
tempsoup.computeTotalPrice();
}
/*****************************************************************************
******
*** ADD your code here to compute the total price for each soup in the soupList.
*****************************************************************************
******/
System.out.print("total prices computed ");
break;
case 'D': //Search for Soup
System.out.print("Please enter a soupID to search: ");
inputInfo = stdin.readLine().trim();
operation = false;
for (Object object : soupList) {
Soup tempsoup=(Soup) object;
if(tempsoup.getSoupId().equals(inputInfo)){
operation=true;
break;
}
}
/*****************************************************************************
******
*** ADD your code here to search the soup with the entered soupId and set operation
*** to true or false based on its result
*****************************************************************************
******/
if (operation == true)
System.out.print("soup found ");
else
System.out.print("soup not found ");
break;
case 'L': //List Soups
if(soupList.size()==0)
System.out.println("no soup ");
else{
for (Object object : soupList) {
Soup tempsoup=(Soup) object;
System.out.println(tempsoup.toString());
}
}
/*****************************************************************************
******
*** ADD your code here to print out all soup objects. If there is no soup,
*** print "no soup "
*****************************************************************************
******/
break;
case 'Q': //Quit
break;
case '?': //Display Menu
printMenu();
break;
default:
System.out.print("Unknown action ");
break;
}
}
else
{
System.out.print("Unknown action ");
}
} while (input1 != 'Q'); // stop the loop when Q is read
}
catch (IOException exception)
{
System.out.println("IO Exception");
}
}
/** The method printMenu displays the menu to a use **/
public static void printMenu()
{
System.out.print("ChoicettAction " +
"------tt------ " +
"AttAdd Soup " +
"CttCompute Total Prices " +
"DttSearch for Soup " +
"LttList Soups " +
"QttQuit " +
"?ttDisplay Help  ");
}
}
Soup.java:
package testProject;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
public abstract class Soup {
int volume=0;
double unitPrice;
double totalPrice=0.0;
String soupId;
public Soup(String soupId,double unitPrice) {
this.unitPrice = unitPrice;
this.soupId = soupId;
}
public String getSoupId() {
return soupId;
}
@Override
public String toString() {
NumberFormat usFormat = NumberFormat.getCurrencyInstance(new
Locale("en","US"));
DecimalFormat decFormat = new DecimalFormat("#.####");
return " The SoupId:tt"+soupId+" The Volume:tt"+volume+" The Unit
Price:tt"+decFormat.format(unitPrice)+" The Total
Price:t"+usFormat.format(totalPrice)+"  ";
}
public abstract void computeTotalPrice();
}
SoupInBox.java:
package testProject;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
public class SoupInBox extends Soup{
int height,width,depth;
public SoupInBox(String id, double someUnitPrice, int someHeight, int someWidth, int
someDepth){
super(id, someUnitPrice);
this.width=someWidth;
this.height=someHeight;
this.depth=someDepth;
}
@Override
public void computeTotalPrice() {
// TODO Auto-generated method stub
volume=(int) (Math.PI*(height*depth*width));
totalPrice=volume * unitPrice;
}
public String toString(){
NumberFormat usFormat = NumberFormat.getCurrencyInstance(new
Locale("en","US"));
DecimalFormat decFormat = new DecimalFormat("#.####");
return " The Soup in a Box The Height:tt"+height+" The Width:tt"+width+" The
Depth:tt"+depth+" The SoupId:tt"+soupId+" The Volume:tt"+volume+" The Unit
Price:tt"+decFormat.format(unitPrice)+" The Total
Price:t"+usFormat.format(totalPrice)+"  ";
}
}
SoupInCylinder.java:
package testProject;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
public class SoupInCylinder extends Soup{
int radius;
int height;
public SoupInCylinder(String id, double someUnitPrice, int someRadius, int someHeight){
super(id, someUnitPrice);
this.radius=someRadius;
this.height=someHeight;
}
@Override
public void computeTotalPrice() {
// TODO Auto-generated method stub
volume=(int) (Math.PI*(radius*radius*height));
totalPrice=volume * unitPrice;
}
public String toString(){
NumberFormat usFormat = NumberFormat.getCurrencyInstance(new
Locale("en","US"));
DecimalFormat decFormat = new DecimalFormat("#.####");
return " The Soup in a Cylinder The Radius:tt"+radius+" The
Height:tt"+height+" The SoupId:tt"+soupId+" The Volume:tt"+volume+" The
Unit Price:tt"+decFormat.format(unitPrice)+" The Total
Price:t"+usFormat.format(totalPrice)+"  ";
}
}
SoupParser.java:
package testProject;
public class SoupParser {
public static Soup parseStringToSoup(String lineToParse){
//shape/soupId/unitPrice/radius/height;
String temp[]=lineToParse.split("/");
String shape=temp[0].toLowerCase();
Soup s=null;
if(shape.equals("cylinder"))
s=new SoupInCylinder(temp[1],Double.parseDouble(temp[2]), Integer.parseInt(temp[3]),
Integer.parseInt(temp[4]));
else if(shape.equals("box"))
s=new SoupInBox(temp[1],Double.parseDouble(temp[2]), Integer.parseInt(temp[3]),
Integer.parseInt(temp[4]),Integer.parseInt(temp[5]));
return s;
}
}
output:
Choice Action
------ ------
A Add Soup
C Compute Total Prices
D Search for Soup
L List Soups
Q Quit
? Display Help
What action would you like to perform?
A
Please enter some soup information to add:
Cylinder/tomateSoup514/0.0054/5/10
What action would you like to perform?
A
Please enter some soup information to add:
Box/splitPeaSoup7192/0.0035/10/15/10
What action would you like to perform?
L
The Soup in a Cylinder
The Radius: 5
The Height: 10
The SoupId: tomateSoup514
The Volume: 0
The Unit Price: 0.0054
The Total Price: $0.00
The Soup in a Box
The Height: 10
The Width: 15
The Depth: 10
The SoupId: splitPeaSoup7192
The Volume: 0
The Unit Price: 0.0035
The Total Price: $0.00
What action would you like to perform?
D
Please enter a soupID to search:
tomatoSoup514
soup not found
What action would you like to perform?
D
Please enter a soupID to search:
tomateSoup514
soup found
What action would you like to perform?
?
Choice Action
------ ------
A Add Soup
C Compute Total Prices
D Search for Soup
L List Soups
Q Quit
? Display Help
What action would you like to perform?
C
total prices computed
What action would you like to perform?
L
The Soup in a Cylinder
The Radius: 5
The Height: 10
The SoupId: tomateSoup514
The Volume: 785
The Unit Price: 0.0054
The Total Price: $4.24
The Soup in a Box
The Height: 10
The Width: 15
The Depth: 10
The SoupId: splitPeaSoup7192
The Volume: 4712
The Unit Price: 0.0035
The Total Price: $16.49
What action would you like to perform?
B
Unknown action
What action would you like to perform?
?
Choice Action
------ ------
A Add Soup
C Compute Total Prices
D Search for Soup
L List Soups
Q Quit
? Display Help
What action would you like to perform?
Q

More Related Content

Similar to These are the outputs which should match they are 4 of them -outp.pdf

ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com donaldzs157
 
Ecet 370 Education Organization -- snaptutorial.com
Ecet 370   Education Organization -- snaptutorial.comEcet 370   Education Organization -- snaptutorial.com
Ecet 370 Education Organization -- snaptutorial.comDavisMurphyB81
 
Can someoen help me to write c++ program including C++ inheritance, .pdf
Can someoen help me to write c++ program including C++ inheritance, .pdfCan someoen help me to write c++ program including C++ inheritance, .pdf
Can someoen help me to write c++ program including C++ inheritance, .pdfarrowvisionoptics
 
Goals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxGoals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxjosephineboon366
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignmentzjkdg986
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignmentsdfgsdg36
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignmentfdjfjfy4498
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docxwilcockiris
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxtiffanyd4
 
Modeling separation systems_with_aspen_plus
Modeling separation systems_with_aspen_plusModeling separation systems_with_aspen_plus
Modeling separation systems_with_aspen_plusTecna
 
Loop structures chpt_6
Loop structures chpt_6Loop structures chpt_6
Loop structures chpt_6cmontanez
 
OverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxOverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxalfred4lewis58146
 
Write a Temperature class that represents temperatures in degrees in .docx
 Write a Temperature class that represents temperatures in degrees in .docx Write a Temperature class that represents temperatures in degrees in .docx
Write a Temperature class that represents temperatures in degrees in .docxajoy21
 
exercises_for_live_coding_Java_advanced-2.pdf
exercises_for_live_coding_Java_advanced-2.pdfexercises_for_live_coding_Java_advanced-2.pdf
exercises_for_live_coding_Java_advanced-2.pdfenodani2008
 

Similar to These are the outputs which should match they are 4 of them -outp.pdf (18)

ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com ECET 370 Exceptional Education - snaptutorial.com
ECET 370 Exceptional Education - snaptutorial.com
 
Savitch ch 04
Savitch ch 04Savitch ch 04
Savitch ch 04
 
Ecet 370 Education Organization -- snaptutorial.com
Ecet 370   Education Organization -- snaptutorial.comEcet 370   Education Organization -- snaptutorial.com
Ecet 370 Education Organization -- snaptutorial.com
 
Can someoen help me to write c++ program including C++ inheritance, .pdf
Can someoen help me to write c++ program including C++ inheritance, .pdfCan someoen help me to write c++ program including C++ inheritance, .pdf
Can someoen help me to write c++ program including C++ inheritance, .pdf
 
Goals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docxGoals1)Be able to work with individual bits in java.2).docx
Goals1)Be able to work with individual bits in java.2).docx
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
 
Cmis 212 module 2 assignment
Cmis 212 module 2 assignmentCmis 212 module 2 assignment
Cmis 212 module 2 assignment
 
Hw5
Hw5Hw5
Hw5
 
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
import java.util.Scanner;Henry Cutler ID 1234  7202.docximport java.util.Scanner;Henry Cutler ID 1234  7202.docx
import java.util.Scanner;Henry Cutler ID 1234 7202.docx
 
Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
 
Unit iii
Unit iiiUnit iii
Unit iii
 
03b loops
03b   loops03b   loops
03b loops
 
Modeling separation systems_with_aspen_plus
Modeling separation systems_with_aspen_plusModeling separation systems_with_aspen_plus
Modeling separation systems_with_aspen_plus
 
Loop structures chpt_6
Loop structures chpt_6Loop structures chpt_6
Loop structures chpt_6
 
OverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docxOverviewUsing the C-struct feature, design, implement and .docx
OverviewUsing the C-struct feature, design, implement and .docx
 
Write a Temperature class that represents temperatures in degrees in .docx
 Write a Temperature class that represents temperatures in degrees in .docx Write a Temperature class that represents temperatures in degrees in .docx
Write a Temperature class that represents temperatures in degrees in .docx
 
exercises_for_live_coding_Java_advanced-2.pdf
exercises_for_live_coding_Java_advanced-2.pdfexercises_for_live_coding_Java_advanced-2.pdf
exercises_for_live_coding_Java_advanced-2.pdf
 

More from udit652068

Discuss briefly and with examples, What key measures need to be take.pdf
Discuss briefly and with examples, What key measures need to be take.pdfDiscuss briefly and with examples, What key measures need to be take.pdf
Discuss briefly and with examples, What key measures need to be take.pdfudit652068
 
Did BP respond in a manner that was appropriate with the oil spill t.pdf
Did BP respond in a manner that was appropriate with the oil spill t.pdfDid BP respond in a manner that was appropriate with the oil spill t.pdf
Did BP respond in a manner that was appropriate with the oil spill t.pdfudit652068
 
Describe and provide at least two examples of direct transmission of.pdf
Describe and provide at least two examples of direct transmission of.pdfDescribe and provide at least two examples of direct transmission of.pdf
Describe and provide at least two examples of direct transmission of.pdfudit652068
 
Define VRIO in business strategy Define VRIO in business strat.pdf
Define VRIO in business strategy Define VRIO in business strat.pdfDefine VRIO in business strategy Define VRIO in business strat.pdf
Define VRIO in business strategy Define VRIO in business strat.pdfudit652068
 
Define e-commerce and describe how it differs from e-business.So.pdf
Define e-commerce and describe how it differs from e-business.So.pdfDefine e-commerce and describe how it differs from e-business.So.pdf
Define e-commerce and describe how it differs from e-business.So.pdfudit652068
 
Building Social Business - EssaySolutionBuilding social busine.pdf
Building Social Business - EssaySolutionBuilding social busine.pdfBuilding Social Business - EssaySolutionBuilding social busine.pdf
Building Social Business - EssaySolutionBuilding social busine.pdfudit652068
 
You are to write a C++ program to produce an inventory repor.pdf
You are to write a C++ program to produce an inventory repor.pdfYou are to write a C++ program to produce an inventory repor.pdf
You are to write a C++ program to produce an inventory repor.pdfudit652068
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfudit652068
 
Write a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdfWrite a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdfudit652068
 
Which of the following defines a method doubleEach that returns an ar.pdf
Which of the following defines a method doubleEach that returns an ar.pdfWhich of the following defines a method doubleEach that returns an ar.pdf
Which of the following defines a method doubleEach that returns an ar.pdfudit652068
 
When the Fed provides more reserves toprovides more reserves to.pdf
When the Fed provides more reserves toprovides more reserves to.pdfWhen the Fed provides more reserves toprovides more reserves to.pdf
When the Fed provides more reserves toprovides more reserves to.pdfudit652068
 
What is a common infrastructure and what does it provideSolutio.pdf
What is a common infrastructure and what does it provideSolutio.pdfWhat is a common infrastructure and what does it provideSolutio.pdf
What is a common infrastructure and what does it provideSolutio.pdfudit652068
 
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdf
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdfWhat are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdf
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdfudit652068
 
What are some of the commonly seen WLAN devices What role does each.pdf
What are some of the commonly seen WLAN devices What role does each.pdfWhat are some of the commonly seen WLAN devices What role does each.pdf
What are some of the commonly seen WLAN devices What role does each.pdfudit652068
 
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdf
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdfUsing the header(dlist) and mainline file (dlistapp) belowYou are .pdf
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdfudit652068
 
Virology.Explain the make up and role of different complexes for .pdf
Virology.Explain the make up and role of different complexes for .pdfVirology.Explain the make up and role of different complexes for .pdf
Virology.Explain the make up and role of different complexes for .pdfudit652068
 
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdfTOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdfudit652068
 
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdf
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdfThe test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdf
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdfudit652068
 
The selection of officials in which of the following branches of the.pdf
The selection of officials in which of the following branches of the.pdfThe selection of officials in which of the following branches of the.pdf
The selection of officials in which of the following branches of the.pdfudit652068
 
the distance between the N-terminal and C-ternimal amino acids varie.pdf
the distance between the N-terminal and C-ternimal amino acids varie.pdfthe distance between the N-terminal and C-ternimal amino acids varie.pdf
the distance between the N-terminal and C-ternimal amino acids varie.pdfudit652068
 

More from udit652068 (20)

Discuss briefly and with examples, What key measures need to be take.pdf
Discuss briefly and with examples, What key measures need to be take.pdfDiscuss briefly and with examples, What key measures need to be take.pdf
Discuss briefly and with examples, What key measures need to be take.pdf
 
Did BP respond in a manner that was appropriate with the oil spill t.pdf
Did BP respond in a manner that was appropriate with the oil spill t.pdfDid BP respond in a manner that was appropriate with the oil spill t.pdf
Did BP respond in a manner that was appropriate with the oil spill t.pdf
 
Describe and provide at least two examples of direct transmission of.pdf
Describe and provide at least two examples of direct transmission of.pdfDescribe and provide at least two examples of direct transmission of.pdf
Describe and provide at least two examples of direct transmission of.pdf
 
Define VRIO in business strategy Define VRIO in business strat.pdf
Define VRIO in business strategy Define VRIO in business strat.pdfDefine VRIO in business strategy Define VRIO in business strat.pdf
Define VRIO in business strategy Define VRIO in business strat.pdf
 
Define e-commerce and describe how it differs from e-business.So.pdf
Define e-commerce and describe how it differs from e-business.So.pdfDefine e-commerce and describe how it differs from e-business.So.pdf
Define e-commerce and describe how it differs from e-business.So.pdf
 
Building Social Business - EssaySolutionBuilding social busine.pdf
Building Social Business - EssaySolutionBuilding social busine.pdfBuilding Social Business - EssaySolutionBuilding social busine.pdf
Building Social Business - EssaySolutionBuilding social busine.pdf
 
You are to write a C++ program to produce an inventory repor.pdf
You are to write a C++ program to produce an inventory repor.pdfYou are to write a C++ program to produce an inventory repor.pdf
You are to write a C++ program to produce an inventory repor.pdf
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
Write a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdfWrite a java program that would ask the user to enter an input file .pdf
Write a java program that would ask the user to enter an input file .pdf
 
Which of the following defines a method doubleEach that returns an ar.pdf
Which of the following defines a method doubleEach that returns an ar.pdfWhich of the following defines a method doubleEach that returns an ar.pdf
Which of the following defines a method doubleEach that returns an ar.pdf
 
When the Fed provides more reserves toprovides more reserves to.pdf
When the Fed provides more reserves toprovides more reserves to.pdfWhen the Fed provides more reserves toprovides more reserves to.pdf
When the Fed provides more reserves toprovides more reserves to.pdf
 
What is a common infrastructure and what does it provideSolutio.pdf
What is a common infrastructure and what does it provideSolutio.pdfWhat is a common infrastructure and what does it provideSolutio.pdf
What is a common infrastructure and what does it provideSolutio.pdf
 
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdf
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdfWhat are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdf
What are the eukaryotic kingdomsQuestion 4 optionsBacteria, Ar.pdf
 
What are some of the commonly seen WLAN devices What role does each.pdf
What are some of the commonly seen WLAN devices What role does each.pdfWhat are some of the commonly seen WLAN devices What role does each.pdf
What are some of the commonly seen WLAN devices What role does each.pdf
 
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdf
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdfUsing the header(dlist) and mainline file (dlistapp) belowYou are .pdf
Using the header(dlist) and mainline file (dlistapp) belowYou are .pdf
 
Virology.Explain the make up and role of different complexes for .pdf
Virology.Explain the make up and role of different complexes for .pdfVirology.Explain the make up and role of different complexes for .pdf
Virology.Explain the make up and role of different complexes for .pdf
 
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdfTOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
TOPOLOGY 541Let M be a set with two members a and b. Define the fu.pdf
 
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdf
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdfThe test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdf
The test solution is made basic and drops of 0.1 M Ca(NO3)2 are adde.pdf
 
The selection of officials in which of the following branches of the.pdf
The selection of officials in which of the following branches of the.pdfThe selection of officials in which of the following branches of the.pdf
The selection of officials in which of the following branches of the.pdf
 
the distance between the N-terminal and C-ternimal amino acids varie.pdf
the distance between the N-terminal and C-ternimal amino acids varie.pdfthe distance between the N-terminal and C-ternimal amino acids varie.pdf
the distance between the N-terminal and C-ternimal amino acids varie.pdf
 

Recently uploaded

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Pooja Bhuva
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfstareducators107
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Celine George
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxPooja Bhuva
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 

Recently uploaded (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 

These are the outputs which should match they are 4 of them -outp.pdf

  • 1. These are the outputs which should match they are 4 of them :- output 1 - output 2 - output 3 - output 4 - Here is the Assingment5.java file can make changes to it :- You are required, but not limited, to turn in the following source files: Assignment5.java (Download this file and use it as your driver program for this assignment. You need to add more codes to complete it.) Soup.java SoupInBox.java SoupInCylinder.java SoupParser.java Requirements to get full credits in Documentation The assignment number, your name, StudentID, Lecture number/time, and a class description need to be included at the top of each class/file. A description of each method is also needed. Some additional comments inside of methods (especially for a "main" method) to explain code that are hard to follow should be written. You can look at Java programs in the text book to see how comments are added to programs. Skills to be Applied In addition to what has been covered in previous assignments, the use of the following items, discussed in class, will probably be needed: Inheritance The protected modifier The super Reference Abstract class NumberFormat/DecimalFormat Wrapper classes ArrayList Program Description Class Diagram: In Assignment #5, you will need to make use of inheritance by creating a class hierarchy for vehicles.
  • 2. Soup is an abstract class, which represents the basic attributes of any soup in a container to be sold. It is used as the root of the soup hierarchy. It has the following attributes (should be protected): Attribute name Attribute type Description volume int The volume of the soup unitPrice double The price per unit of the soup totalPrice double The total price of the soup soupId String The Id of the soup The following constructor method should be provided to initialize the instance variables. publicSoup(String id, double someUnitPrice) The instance variable volume is initialized to 0, totalPrice is initialized to 0.0, unitPrice is initialized to the value of the second parameter, and soupId is initialized to the string value of the first parameter. The following accessor method should be provided for soupId : publicString getSoupId() The Class Soup also has an abstract method (which should be implemented by its child classes, SoupInCylinder and SoupInBox) to compute the volume of the soup: publicabstract void computeTotalPrice(); The following public method should be provided: publicString toString() toString method returns a string of the following format: The SoupId:tttomatosoup591 The Volume:tt150 The Unit Price:tt0.0015 The Total Price:t$330.00
  • 3. You should make use of the NumberFormat class and DecimalFormat (in java.text package) to format the total price in the dollar format (NumberFormat) and the unit price using 4 digits after their decimal point (DecimalFormat using "0.0000"). SoupInCylinder class SoupInCylinder is a subclass of Soup class. It represents a soup in a can (cylinder). It has the following attribute in addition to the inherited ones: Attribute name Attribute type Description radius int The radius of the cylinder of the soup. height int The height of the cylinder of the soup. The following constructor method should be provided: publicSoupInCylinder(String id, double someUnitPrice, int someRadius, int someHeight) The radius is initialized to the value of the third parameter, the height is initialized to the value of the forth parameter, and the constructor of the parent class Soup should be called using the first and second parameters. Leave volume and totalPrice as their default values (defined in the parent’s constructor). The following method should be implemented: publicvoid computeTotalPrice() First, it computes the volume for the cylinder of the soup. (computed by PI*(radius*radius*height), the constant value PI is defined in the Math class. -- (int) (Math.PI*(radius*radius*height)) Also, compute (radius*radius*height) first since they are all integers. PI is a float point number, so you need to cast the final value to an integer ("volume" is an integer.) Then compute the total price of the soup. (computed by volume * unitPrice) Also, the following method should be implemented: publicString toString() The toString() method inherited from Soup class should be used to create a new string, and display a cylinder soup's information using the following format: TheSoup in a Cylinder The Radius:tt5 The Height:tt10
  • 4. The SoupId:tttomatosoup591 The Volume:tt785 The Unit Price:tt0.0022 The Total Price:t$1.73 This toString method should make use of the toString method of the parent class. SoupInBox class SoupInBox is a subclass of Soup class. It represents a soup in a carton. It has the following attributes: Attribute name Attribute type Description height int The height of the box of the soup. width int The width of the box of the soup. depth int The depth of the box of the soup. The following constructor method should be provided: publicSoupInBox(String id, double someUnitPrice, int someHeight, int someWidth, int someDepth) The height, width, depth are initialized to the value of the third parameter, the fourth parameter, and the fifth parameter, respectively, and the constructor of the parent class Soup should be called using the first and second parameters. Leave volume and totalPrice as their default value. The following method should be implemented: publicvoid computeTotalPrice() First, it computes the volume of the box of the soup. (computed by height*width*depth) Then compute the total price of the soup. (computed by volume * unitPrice) Also, the following method should be implemented: publicString toString() The toString() method inherited from the Soup class should be used to create a new string, and display a box soup's information using the following format: TheSoup in a Box
  • 5. The Height:tt5 The Width:tt10 The Depth:tt5 The SoupId:ttsplitPeaSoup515 The Volume:tt250 The Unit Price:tt0.0055 The Total Price:t$1.38 This toString method should make use of the toString method of the parent class. SoupParser class The SoupParser class is a utility class that will be used to create a soup object (either a cylinder soup object or a box soup object) from a parsable string. The SoupParser class object will never be instantiated. It must have the following method: publicstatic Soup parseStringToSoup(String lineToParse) The parseStringToSoup method's argument will be a string in the following format: For a cylinder soup, shape/soupId/unitPrice/radius/height For a box soup, shape/soupId/unitPrice/height/width/depth A real example of this string would be: Cylinder/tomateSoup514/0.0054/5/10 OR Box/splitPeaSoup7192/0.0035/10/15/10 This method will parse this string, pull out the information, create a new SoupInCylinder or SoupInBox object using their constructor with attributes of the object, and return it to the calling method. The type will always be present and always be either Cylinder or Box. (It can be lower case or upper case) You may add other methods to the SoupInCylinder and SoupInBox class in order to make your life easier. Assignment5 class In this assignment, download Assignment5.java file by clicking the link, and use it for your assignment. You need to add code to this file. The parts you need to add are written in the Assignment5.java file, namely for the four cases "Add Soup", "Add Compute Total Prices", "Search for Soup", and "List Soups". All input and output should be handled here. The main method should start by displaying this updated menu in this exact format: ChoicettAction
  • 6. ------tt------ AttAdd Soup CttCompute Total Prices DttSearch for Soup LttList Soups QttQuit ?ttDisplay Help Next, the following prompt should be displayed: What action would you like to perform? Read in the user input and execute the appropriate command. After the execution of each command, redisplay the prompt. Commands should be accepted in both lowercase and uppercase. Add Soup Your program should display the following prompt: Please enter a soup information to add: Read in the information and parse it using the soup parser. Then add the new soup object (created by soup parser) to the soup list. Compute Total Prices Your program should compute total price for all soups created so far by calling computeTotalPrice method for each of them in the soup list. After computing total prices, display the following: totalprices computed Search for Soup Your program should display the following prompt: Please enter a soupId to search: Read in the string and look up the soup list, if there exists a soup object with the same soup ID, then display the following: soupfound Otherwise, display this: soupnot found List Soups List all soups in the soup list. Make use of toString method defined in SoupInBox and SoupInCylinder classes. A real example is looked like this: The Soup in a Cylinder Container
  • 7. The Radius: 5 The Height: 10 The SoupId: chickensoup200 The Volume: 0 The Unit Price: 0.0054 The Total Price: $0.00 The Soup in a Box Container The Height: 10 The Width: 15 The Depth: 10 The SoupId: tomatosoup03 The Volume: 0 The Unit Price: 0.0035 The Total Price: $0.00 If there is no soup in the soup list (the list is empty), then display following: nosoup Quit Your program should stop executing and output nothing. Display Help Your program should redisplay the "choice action" menu. Invalid Command If an invalid command is entered, display the following line: Unknown action Attribute name Attribute type Description volume int The volume of the soup unitPrice double The price per unit of the soup totalPrice double
  • 8. The total price of the soup soupId String The Id of the soup SoupParser parseString ToSoup(lineToParse String): Soup Arizona State University, CSE205 Spring 2017, Assignment5 Assi nment +main(StringU): void +print Menu0:void Souplncylinder radius :int -height: int +Souplncylinder(String,double,int,int) ttoString0: String Sou #volume int 0 #unit Price:double #total Price: double 0.0 #soupld: String Soup (String,double) tgetSoupld0: String +toString(): String compute Total Price() void SouplnBox ght: int -width: int -depth: int tSoupInBox (String, nt ttoString0:String Solution Assignment.java: package testProject; // Assignment #: 5 //Arizona State University - CSE205 // Name: Your name // StudentID: Your id // Lecture: Your lecture time (for instance, MWF 10:40am) //Description: The Assignment 5 class displays a menu of choices // (add cylinder soup, box soup,search soup, // list soups, quit, display menu) to a user // and performs the chosen task. It will keep asking a user to // enter the next choice until the choice of 'Q' (Quit) is // entered. import java.io.*; //to use InputStreamReader and BufferedReader import java.text.NumberFormat; import java.util.*; //to use ArrayList public class Assignment5 { public static void main (String[] args) { char input1; String inputInfo = new String(); String line = new String(); boolean operation;
  • 9. // ArrayList object is used to store soup objects ArrayList soupList = new ArrayList(); try { printMenu(); // print out menu // create a BufferedReader object to read input from a keyboard InputStreamReader isr = new InputStreamReader (System.in); BufferedReader stdin = new BufferedReader (isr); do { System.out.println("What action would you like to perform?"); line = stdin.readLine().trim(); input1 = line.charAt(0); input1 = Character.toUpperCase(input1); if (line.length() == 1) { switch (input1) { case 'A': //Add Soup System.out.print("Please enter some soup information to add: "); inputInfo = stdin.readLine().trim(); Soup someSoup=SoupParser.parseStringToSoup(inputInfo); soupList.add(someSoup); /***************************************************************************** ****** *** ADD your code here to create an object of one of child classes of Soup class *** and add it to the soupList ***************************************************************************** ******/ break; case 'C': //Compute Total Prices for (Object object : soupList) { Soup tempsoup=(Soup) object; tempsoup.computeTotalPrice(); }
  • 10. /***************************************************************************** ****** *** ADD your code here to compute the total price for each soup in the soupList. ***************************************************************************** ******/ System.out.print("total prices computed "); break; case 'D': //Search for Soup System.out.print("Please enter a soupID to search: "); inputInfo = stdin.readLine().trim(); operation = false; for (Object object : soupList) { Soup tempsoup=(Soup) object; if(tempsoup.getSoupId().equals(inputInfo)){ operation=true; break; } } /***************************************************************************** ****** *** ADD your code here to search the soup with the entered soupId and set operation *** to true or false based on its result ***************************************************************************** ******/ if (operation == true) System.out.print("soup found "); else System.out.print("soup not found "); break; case 'L': //List Soups if(soupList.size()==0) System.out.println("no soup "); else{ for (Object object : soupList) { Soup tempsoup=(Soup) object; System.out.println(tempsoup.toString());
  • 11. } } /***************************************************************************** ****** *** ADD your code here to print out all soup objects. If there is no soup, *** print "no soup " ***************************************************************************** ******/ break; case 'Q': //Quit break; case '?': //Display Menu printMenu(); break; default: System.out.print("Unknown action "); break; } } else { System.out.print("Unknown action "); } } while (input1 != 'Q'); // stop the loop when Q is read } catch (IOException exception) { System.out.println("IO Exception"); } } /** The method printMenu displays the menu to a use **/ public static void printMenu() { System.out.print("ChoicettAction " + "------tt------ " + "AttAdd Soup " +
  • 12. "CttCompute Total Prices " + "DttSearch for Soup " + "LttList Soups " + "QttQuit " + "?ttDisplay Help "); } } Soup.java: package testProject; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; public abstract class Soup { int volume=0; double unitPrice; double totalPrice=0.0; String soupId; public Soup(String soupId,double unitPrice) { this.unitPrice = unitPrice; this.soupId = soupId; } public String getSoupId() { return soupId; } @Override public String toString() { NumberFormat usFormat = NumberFormat.getCurrencyInstance(new Locale("en","US")); DecimalFormat decFormat = new DecimalFormat("#.####"); return " The SoupId:tt"+soupId+" The Volume:tt"+volume+" The Unit Price:tt"+decFormat.format(unitPrice)+" The Total Price:t"+usFormat.format(totalPrice)+" "; } public abstract void computeTotalPrice();
  • 13. } SoupInBox.java: package testProject; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; public class SoupInBox extends Soup{ int height,width,depth; public SoupInBox(String id, double someUnitPrice, int someHeight, int someWidth, int someDepth){ super(id, someUnitPrice); this.width=someWidth; this.height=someHeight; this.depth=someDepth; } @Override public void computeTotalPrice() { // TODO Auto-generated method stub volume=(int) (Math.PI*(height*depth*width)); totalPrice=volume * unitPrice; } public String toString(){ NumberFormat usFormat = NumberFormat.getCurrencyInstance(new Locale("en","US")); DecimalFormat decFormat = new DecimalFormat("#.####"); return " The Soup in a Box The Height:tt"+height+" The Width:tt"+width+" The Depth:tt"+depth+" The SoupId:tt"+soupId+" The Volume:tt"+volume+" The Unit Price:tt"+decFormat.format(unitPrice)+" The Total Price:t"+usFormat.format(totalPrice)+" "; }
  • 14. } SoupInCylinder.java: package testProject; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.Locale; public class SoupInCylinder extends Soup{ int radius; int height; public SoupInCylinder(String id, double someUnitPrice, int someRadius, int someHeight){ super(id, someUnitPrice); this.radius=someRadius; this.height=someHeight; } @Override public void computeTotalPrice() { // TODO Auto-generated method stub volume=(int) (Math.PI*(radius*radius*height)); totalPrice=volume * unitPrice; } public String toString(){ NumberFormat usFormat = NumberFormat.getCurrencyInstance(new Locale("en","US")); DecimalFormat decFormat = new DecimalFormat("#.####"); return " The Soup in a Cylinder The Radius:tt"+radius+" The Height:tt"+height+" The SoupId:tt"+soupId+" The Volume:tt"+volume+" The Unit Price:tt"+decFormat.format(unitPrice)+" The Total Price:t"+usFormat.format(totalPrice)+" "; } } SoupParser.java:
  • 15. package testProject; public class SoupParser { public static Soup parseStringToSoup(String lineToParse){ //shape/soupId/unitPrice/radius/height; String temp[]=lineToParse.split("/"); String shape=temp[0].toLowerCase(); Soup s=null; if(shape.equals("cylinder")) s=new SoupInCylinder(temp[1],Double.parseDouble(temp[2]), Integer.parseInt(temp[3]), Integer.parseInt(temp[4])); else if(shape.equals("box")) s=new SoupInBox(temp[1],Double.parseDouble(temp[2]), Integer.parseInt(temp[3]), Integer.parseInt(temp[4]),Integer.parseInt(temp[5])); return s; } } output: Choice Action ------ ------ A Add Soup C Compute Total Prices D Search for Soup L List Soups Q Quit ? Display Help What action would you like to perform? A Please enter some soup information to add: Cylinder/tomateSoup514/0.0054/5/10 What action would you like to perform? A Please enter some soup information to add: Box/splitPeaSoup7192/0.0035/10/15/10 What action would you like to perform?
  • 16. L The Soup in a Cylinder The Radius: 5 The Height: 10 The SoupId: tomateSoup514 The Volume: 0 The Unit Price: 0.0054 The Total Price: $0.00 The Soup in a Box The Height: 10 The Width: 15 The Depth: 10 The SoupId: splitPeaSoup7192 The Volume: 0 The Unit Price: 0.0035 The Total Price: $0.00 What action would you like to perform? D Please enter a soupID to search: tomatoSoup514 soup not found What action would you like to perform? D Please enter a soupID to search: tomateSoup514 soup found What action would you like to perform? ? Choice Action ------ ------ A Add Soup C Compute Total Prices D Search for Soup L List Soups Q Quit ? Display Help
  • 17. What action would you like to perform? C total prices computed What action would you like to perform? L The Soup in a Cylinder The Radius: 5 The Height: 10 The SoupId: tomateSoup514 The Volume: 785 The Unit Price: 0.0054 The Total Price: $4.24 The Soup in a Box The Height: 10 The Width: 15 The Depth: 10 The SoupId: splitPeaSoup7192 The Volume: 4712 The Unit Price: 0.0035 The Total Price: $16.49 What action would you like to perform? B Unknown action What action would you like to perform? ? Choice Action ------ ------ A Add Soup C Compute Total Prices D Search for Soup L List Soups Q Quit ? Display Help What action would you like to perform? Q