Microsoft Word - A2.docx DPIT111 Assignment 2 Week 4-5 Objectives  Get familiar with UML class and object diagrams  Distinguish pass-by-value and pass-by-reference  Get familiar with class...

1 answer below »
These are four simple programming questions.


Microsoft Word - A2.docx DPIT111 Assignment 2 Week 4-5 Objectives  Get familiar with UML class and object diagrams  Distinguish pass-by-value and pass-by-reference  Get familiar with class constructors  Master how to implement classes and their relationships according to UML diagrams  Get familiar with if statement and if-else statement Assignment 2 (12%) is marked on a scale from 0-12 marks. Important notices: This assignment is scheduled to be done in Week 4-5 (Monday 20 July - Saturday 1 August 19:00). Comments for your work can be checked on Moodle site. You may be asked questions about your code. Your marks will be deducted if you could not answer the questions presented by the assessor. 1. Students must submit all assessment tasks by the due date or penalties will be applied. No. of calendar days late Penalty 1 10% of the original mark. 2 20% of the original mark. 3 30% of the original mark. More than 3 A mark of zero will be awarded for the assessment. 2. Make sure that you include following personal information in every file, otherwise it will result in 0 points. /*------------------------------------------------------ My name: My subject code: My student number: My email address: Assignment number: -------------------------------------------------------*/ 3. Ensure each file in your submission is runnable, compiling error in your file will result in 0 points for the current question. If it is runnable, though it fails to realize all functionalities, you can get partial points for what you have done. Question 1 (4 mark): Implement a program with two classes according to the following UML diagram: REQUIREMENTS  The constructor College(String, String, int, int) shall create two component objects of type StudentAccount , i.e., the first lab student and the second lab student, and initialize them using corresponding names and student numbers.  The program shall create in the main() function an object of type College using its constructor with four parameters that contain names and student numbers of two students (the first lab student, the second lab student), your code should use the following given student information: 2019001 Frank White – for the 1st lab student 2019002 Jurgen Klopp – for the 2nd lab student  The constructor StudentAccount(String, int) shall initialize the student’s name and student number, and store the name in the field name, store the student number in the field studentNumber.  Then the main() method shall call printStudents() method to print information about the students in the following example format.  Your code must work exactly as the specification and the output should be exactly the same as the output example. Example of the program output: The first lab student: Frank White 2019001 The second lab student: Jurgen Klopp 2019002 Question 2 (3 mark): Write a program to implement the class Coffee according to the following UML diagram and description so that it can display as the output example. REQUIREMENTS  The program has three constructors: the first one is a default constructor, it initializes the 3 data fields (50.0, 1.5, 1.7) at default; the second initializes the 3 data fields with its three double arguments; the last one is the copy constructor.  The method printNutritionInformation() takes no argument and returns nothing, it is to display the nutrition information of an object generated from the Coffee class. The displaying format is as follows: It contains … Cal energy, … g protein and … g fat per serving.  The main() method is to build 3 objects from the Coffee class: the first object is built by the default constructor; the second object is built by the second constructor where parameters should be passed; the last object is built by the copy constructor where the source object is the second object. Then the nutrition information of the three objects is displayed.  Your code must work exactly as the specification and the output should be exactly the same as the output example. Example of the program output: It contains 50.0 Cal energy, 1.5 g protein and 1.7 g fat per serving. It contains 72.0 Cal energy, 1.8 g protein and 1.6 g fat per serving. It contains 72.0 Cal energy, 1.8 g protein and 1.6 g fat per serving. Question 3 (2 mark) : Write a class to compute the property cost according to the following UML diagram and expressions. The area of a property is obtained from the command line arguments. REQUIREMENTS  The method calcTotalCharges(double) is to calculate the total charges based on its argument which represents area and expressions required in this method are as follows: actualArea = area * RATE propertyCharge = actualArea * UNITPRICE propertyCost = propertyCharge + propertyCharge * GST  The main() method should ask user to input a double number area and accordingly call the method calcTotalCharges().  Your code must work exactly as the specification and the output should be exactly the same as the output example. Two examples of the program output (the texts in bold indicate the user input): Example 1: Enter the area: 155.67 Property cost: 263.70 Example 2: Enter the area: 12.17 Property cost: 20.62 Question 4 (3 mark) : Write a Java program to ask the user to input an integer number from the keyboard. The output should indicate whether it is positive, zero, or negative, an even number or an odd number. REQUIREMENTS  Your code should ask user to input an integer number, then decide its sign and parity based on this input.  Your code should use if-else statement.  Your code must work exactly as the specification and the output should be exactly the same as the output example. 5 example of the program output (the texts in bold indicate the user input): Example 1: Property Please input a number: 6 6 is a positive, even number. Example 2: Please input a number: -27 -27 is a negative, odd number. Example 3: Property Please input a number: 25 25 is a positive, odd number. Example 4: Property Please input a number: -16 -16 is a negative, even number. Example 5: Property Please input a number: 0 0 is a zero, even number. Submission requirements: 1. Put the solutions to Question 1 in a text file (.txt) and upload this file to Part 1 of the submission link; put the solution to Question 2 in a text file (.txt) and upload this file to Part 2 of the submission link; put solutions to Question 3 in a text file (.txt) and upload this file to Part 3 of the submission link; put solutions to Question 4 in a text file (.txt) and upload this file to Part 4. The submission link is called Assignment 2 Submission under Week 4 Section on the subject Moodle site. 2. Submission via email is not acceptable without permission. 3. Enquiries about the marks can only be made within a maximum of 1 week after the assignment results are published. After 1 week the marks cannot be changed. Mark deductions: late submission, compilation errors, incorrect result, program is not up to spec, poor comments, poor indentation, meaningless identifiers, required numeric constants are not defined, the program uses approaches which has not been covered in the lectures. The deductions here are merely a guide. Marks may also be deducted for other mistakes and poor practices. END OF THE ASSIGNMENT
Answered Same DayJul 31, 2021

Answer To: Microsoft Word - A2.docx DPIT111 Assignment 2 Week 4-5 Objectives  Get familiar with UML class and...

Aditya answered on Aug 01 2021
143 Votes
DPIT111/build.xml

Builds, tests, and runs the project DPIT111.


DPIT111/build/built-jar.properties
#Sat, 01 Aug 2020 03:02:33 +0530
F\:\\eclipsbrenze4julyeprgram\\DPIT111=
DPIT111/build/classes/.netbeans_automatic_build
DPIT111/build/classes/.netbeans_update_resources
DPIT111/build/classes/Coffee.class
public synchronized class Coffee {
private double energy;
private double protien;
private double fat;
public void Coffee();
public void Coffee(double, double, double);
public void Coffee(Coffee);
public void printNutritionInformation();
public static void main(String[]);
}
DPIT111/build/classes/College.class
public synchronized class College {
private StudentAccount firstLabStudent;
private StudentAccount secondLabStudent;
public void College(String, String, int, int);
public void printStudents();
public static void main(String[]);
}
DPIT111/build/classes/Part4.class
public synchronized class Part4 {
public
void Part4();
public static void main(String[]);
}
DPIT111/build/classes/PropertyCost.class
public synchronized class PropertyCost {
private final double rate;
private final double unitPrice;
private final double GST;
public void PropertyCost();
public double calcTotalCharges(double);
public static void main(String[]);
}
DPIT111/build/classes/StudentAccount.class
public synchronized class StudentAccount {
private String name;
private int studentNumber;
public void StudentAccount(String, int);
public String getName();
public int getStudentNumber();
}
DPIT111/dist/DPIT111.jar
META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.9.4
Created-By: 1.8.0_121-b13 (Oracle Corporation)
Class-Path:
X-COMMENT: Main-Class will be added automatically by build
Main-Class: Part4
Coffee.class
public synchronized class Coffee {
private double energy;
private double protien;
private double fat;
public void Coffee();
public void Coffee(double, double, double);
public void Coffee(Coffee);
public void printNutritionInformation();
public static void main(String[]);
}
College.class
public synchronized class College {
private StudentAccount firstLabStudent;
private StudentAccount secondLabStudent;
public void College(String, String, int, int);
public void printStudents();
public static void main(String[]);
}
Part4.class
public synchronized class Part4 {
public void Part4();
public static void main(String[]);
}
PropertyCost.class
public synchronized class PropertyCost {
private final double rate;
private final double unitPrice;
private final double GST;
public void PropertyCost();
public double calcTotalCharges(double);
public static void main(String[]);
}
StudentAccount.class
public synchronized class StudentAccount {
private String name;
private int studentNumber;
public void StudentAccount(String, int);
public String getName();
public int getStudentNumber();
}
DPIT111/dist/README.TXT
========================
BUILD OUTPUT DESCRIPTION
========================
When you build an Java application project that has a main class, the IDE
automatically copies all of the JAR
files on the projects classpath to your projects dist/lib folder. The IDE
also adds each of the JAR files to the Class-Path element in the application
JAR files manifest file (MANIFEST.MF).
To run the project from the command line, go to the dist folder and
type the following:
java -jar "DPIT111.jar"
To distribute this project, zip up the dist folder (including the lib folder)
and distribute the ZIP file.
Notes:
* If two JAR files on the project classpath have the same name, only the first
JAR file is copied to the lib folder.
* Only JAR files are copied to the lib folder.
If the classpath contains other types of files or folders, these files (folders)
are not copied.
* If a library on the projects classpath also has a Class-Path element
specified in the manifest,the content of the Class-Path element has to be on
the projects runtime path.
* To set a main class in a standard Java project, right-click the project node
in the Projects window and choose Properties. Then click Run and enter the
class name in the Main Class field. Alternatively, you can manually type the
class name in the manifest Main-Class element.
DPIT111/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
DPIT111/nbproject/build-impl.xml








































































































































































































Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar




































































































Must set javac.includes

















































...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here