Here is the assignment5.java file -You are required, but not limi.pdfmallik3000
Here is the assignment5.java file :-
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:\\t\\ttomatosoup591\
The Volume:\\t\\t150\
The Unit Price:\\t\\t0.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.
heig.
These are the outputs which should match they are 4 of them -outp.pdfudit652068
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:\\t\\ttomatosoup591\
The Volume:\\t\\t150\
The Unit Price:\\t\\t0.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.
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docxalfred4lewis58146
Page 8 of 8
3.Tutorial: Get Started with Eclipse in the Computer Lab[footnoteRef:1] [1: This tutorial is modified from
Eclipse Tutorial – Getting Started by Dr. John Dean (http://captain.park.edu/jdean/tutorials/eclipseDnldTutorial.doc ) and
How To Install Eclipse and Get Started with Java Programming from https://www3.ntu.edu.sg/home/ehchua/programming/howto/EclipseJava_HowTo.html (retrieved on 8/8/2015)]
(Last updated: 8/16/2015)
In this tutorial you will practice using Eclipse to build Java programs in computer labs (such as SC113) on campus. We will practice:
A. Get familiar with the Eclipse IDE
B. Set up the coding style preference (such as two-space indent and soft tab) used in this course
C. Build and run the famous Hello World! Project
D. Create a project by copying from an existing project
E. Terminate a running program
* * *
Eclipse is an Integrated Development Environment (IDE) that allows you to enter, compile, and run programs. The programs can be written in one of many different languages, such of Java, C/C++, and PHP. Computer labs on campus already has Eclipse ready for Java development.
The screenshot below shows the default layout of Eclipse. Take a look now and refer back to this screenshot as to where things are while you work through this tutorial.
1. Menu
2. Toolbar
3. Package Explorer: display all your projects and files. Yours will be empty at this point.
4. Editor
5. Outline view: displays data and method members of the currently selected Java class
6. Console panel
If you accidentally closed or moved one of the panels above, you can always restore this default layout by:
· First choose “Window” menu => “Open Perspective” => “Other…” and select “Java (default)” in the “Open Perspective” dialog. In Eclipse a perspective defines the initial set and layout of views in the Workbench window.
· Then choose “Window” menu => “Reset Perspectives” and click “Yes”
* * *
Tip: when taking screenshots of the running result for your homework report, you may temporarily make the console panel section bigger so it shows the complete running result. Afterwards follow the steps above to restore the layout.
* * *
SAVING FILES:
· Naturally, you are required to save your program files. In the lab, you are required to save your files on a USB flash drive storage device. If you're working at home, you may save your files on your computer's hard disk, but you're still required to have a flash drive so that you can transport your files to and from school. If you're at the school's lab, do not use the hard disks ever!
ECLIPSE TUTORIAL:
If you forget how to do something in Eclipse, it is up to you to carefully reread this Eclipse tutorial and figure out how to do things. To reduce the number of rereads, go through this tutorial slowly and try to remember what you're doing.
This tutorial uses x: to refer to the drive that you're saving your work on. In the lab, x: should be replaced by the USB drive (assuming that yo.
Here is the assignment5.java file -You are required, but not limi.pdfmallik3000
Here is the assignment5.java file :-
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:\\t\\ttomatosoup591\
The Volume:\\t\\t150\
The Unit Price:\\t\\t0.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.
heig.
These are the outputs which should match they are 4 of them -outp.pdfudit652068
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:\\t\\ttomatosoup591\
The Volume:\\t\\t150\
The Unit Price:\\t\\t0.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.
Page 8 of 83.Tutorial Get Started with Eclipse in the Compute.docxalfred4lewis58146
Page 8 of 8
3.Tutorial: Get Started with Eclipse in the Computer Lab[footnoteRef:1] [1: This tutorial is modified from
Eclipse Tutorial – Getting Started by Dr. John Dean (http://captain.park.edu/jdean/tutorials/eclipseDnldTutorial.doc ) and
How To Install Eclipse and Get Started with Java Programming from https://www3.ntu.edu.sg/home/ehchua/programming/howto/EclipseJava_HowTo.html (retrieved on 8/8/2015)]
(Last updated: 8/16/2015)
In this tutorial you will practice using Eclipse to build Java programs in computer labs (such as SC113) on campus. We will practice:
A. Get familiar with the Eclipse IDE
B. Set up the coding style preference (such as two-space indent and soft tab) used in this course
C. Build and run the famous Hello World! Project
D. Create a project by copying from an existing project
E. Terminate a running program
* * *
Eclipse is an Integrated Development Environment (IDE) that allows you to enter, compile, and run programs. The programs can be written in one of many different languages, such of Java, C/C++, and PHP. Computer labs on campus already has Eclipse ready for Java development.
The screenshot below shows the default layout of Eclipse. Take a look now and refer back to this screenshot as to where things are while you work through this tutorial.
1. Menu
2. Toolbar
3. Package Explorer: display all your projects and files. Yours will be empty at this point.
4. Editor
5. Outline view: displays data and method members of the currently selected Java class
6. Console panel
If you accidentally closed or moved one of the panels above, you can always restore this default layout by:
· First choose “Window” menu => “Open Perspective” => “Other…” and select “Java (default)” in the “Open Perspective” dialog. In Eclipse a perspective defines the initial set and layout of views in the Workbench window.
· Then choose “Window” menu => “Reset Perspectives” and click “Yes”
* * *
Tip: when taking screenshots of the running result for your homework report, you may temporarily make the console panel section bigger so it shows the complete running result. Afterwards follow the steps above to restore the layout.
* * *
SAVING FILES:
· Naturally, you are required to save your program files. In the lab, you are required to save your files on a USB flash drive storage device. If you're working at home, you may save your files on your computer's hard disk, but you're still required to have a flash drive so that you can transport your files to and from school. If you're at the school's lab, do not use the hard disks ever!
ECLIPSE TUTORIAL:
If you forget how to do something in Eclipse, it is up to you to carefully reread this Eclipse tutorial and figure out how to do things. To reduce the number of rereads, go through this tutorial slowly and try to remember what you're doing.
This tutorial uses x: to refer to the drive that you're saving your work on. In the lab, x: should be replaced by the USB drive (assuming that yo.
Hadj Ounis's most notable work is his sculpture titled "Metamorphosis." This piece showcases Ounis's mastery of form and texture, as he seamlessly combines metal and wood to create a dynamic and visually striking composition. The juxtaposition of the two materials creates a sense of tension and harmony, inviting viewers to contemplate the relationship between nature and industry.
2137ad - Characters that live in Merindol and are at the center of main storiesluforfor
Kurgan is a russian expatriate that is secretly in love with Sonia Contado. Henry is a british soldier that took refuge in Merindol Colony in 2137ad. He is the lover of Sonia Contado.
Explore the multifaceted world of Muntadher Saleh, an Iraqi polymath renowned for his expertise in visual art, writing, design, and pharmacy. This SlideShare delves into his innovative contributions across various disciplines, showcasing his unique ability to blend traditional themes with modern aesthetics. Learn about his impactful artworks, thought-provoking literary pieces, and his vision as a Neo-Pop artist dedicated to raising awareness about Iraq's cultural heritage. Discover why Muntadher Saleh is celebrated as "The Last Polymath" and how his multidisciplinary talents continue to inspire and influence.
2137ad Merindol Colony Interiors where refugee try to build a seemengly norm...luforfor
This are the interiors of the Merindol Colony in 2137ad after the Climate Change Collapse and the Apocalipse Wars. Merindol is a small Colony in the Italian Alps where there are around 4000 humans. The Colony values mainly around meritocracy and selection by effort.
1. Assignment: Object Oriented Programming in Java
Information
This assignment is to be done in pairs (groups of 2).
Total: 20 marks
o Exercises a-d : 12 marks
o Exercises e: 3 marks
o Exercise f: 5 marks
Case Description
The Michelin is a restaurant situated in a small city called Winsum, located in the northern part of The
Netherlands. The owner, Miss Lisanne, has enlisted your help, as a technology consultant, to develop a
Java application for automating the customer ordering process. Miss Lisanne describes menus (dishes) in
her restaurant as follows.
All menus are identified by a name, e.g. “stamppot boerenkool”, the amount of calories of the dish, e.g.
564.65 kcal, the estimated cooking time in minutes, e.g. 45 min (only integer values), the price per
person, e.g. 20.5, and the number of wine bottles included, e.g. 0.5.
Based on this description, complete the assignment by following the exercises listed below.
Exercise a
Create a Java class (in a Java Project in Eclipse) to represent a menu from the description Miss
Lisanne. You can call your class Menu (or any other name that you prefer). Note that this class
only serves as a “template” (you do not give values to the attributes yet, but simply define the
attributes and the methods).
Hint:
o Define the attributes of the class, their types (e.g. String) and visibility.
o Add the constructor in the class
o Define the getter and setter methods for each of the attributes
o Pay attention to the Java naming conventions for classes and methods
Exercise b
Add a method in your class to print the details of the menus in the format below:
o Menu <name> contains <calories> calories, comes with <number of wine bottles> bottles
and cost <price>
o Note that <name>, <calories> , <number of wine bottles> and <price> correspond to the
attributes of your class.
You are free to use any name for your method.
2. Exercise c
(In the same Java Project) Create another class containing the “main” method.
In this “main class”, create 5 objects of the class Menu, as defined in the table below.
name amount of calories cooking time price per person number of wine bottles
Stamppot
boerenkool
564.65 45 20.5 0.5
Metworst 345 12 10.99 0
Hutspot 560.4 65 30.9 1
Biefstuk 780 46 50.34 2
Kibbeling 450.4 23 20.78 1
Exercise d
In your “main class” create an array of length 5, and store the 5 objects (Exercise c) into the
array. You can use any name for your array.
From the array, use a loop to
o Print the details of all the objects using the method you defined in Exercise b. An
example output:
Exercise e
Use another loop to:
o Print only the name and cooking time of all the dishes that take less than 30 minutes to
cook. Hint: you may use the getter methods for the name and cooking time attributes,
and then, print these values (name, cooking time). An example output is shown below.
“Metworst” and “Kibbeling” correspond to the names, while 12 and 23
correspond to the cooking time.
Menu Stamppot boerenkool contains 564.65 calories, comes with 0.5 bottles and
cost 20.5
Menu Metworst contains 345.0 calories, comes with 0.0 bottles and cost 10.99
Menu Hutspot contains 560.4 calories, comes with 1.0 bottles and cost 30.9
Menu Biefstuk contains 780.0 calories, comes with 2.0 bottles and cost 50.34
Menu Kibbeling contains 450.4 calories, comes with 1.0 bottles and cost 20.78
Metworst cooks in 12
Kibbeling cooks in 23
3. Exercise f
Use another loop to
o Calculate and print the total price of all the objects (in the array). Example output:
o Calculate the total price of all the objects. If the price is more than 65, give a discount of
10% and print the total price and the discounted price. Example output:
Submission
Locate your 2 classes (Menu and “main class”). In your PC, these files will have extension “.java”.
They will be in a folder that has the same name as your Java Project name in Eclipse.
Copy these 2 files to a new folder. The folder name should be the ids of the 2 group members
separated by an underscore (“_”). For e.g. if the members have ids S1 and S2, then the folder
name is “S1_S2”.
Zip the folder and submit it via Lol@, under Travaux Java Assignment. (Only 1 of the team
member needs to submit)
To evaluate your work, we will first look at the codes, and then run it (the “main class”) to see if
the results are correct.
The total price is: 133.51
The total price is: 133.51
The discounted price is: 120.15