Instructions
Requirements and Specifications
![Solutions to questions based on code provided](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided.webp)
Question 1:Give the name of all the methods.
Question 2:Give the name of all the fields.
Question 3: Give the name of all data types that is used in the code.
Question 4: Give the name of the parameters of all the methods.
Question 5:You are to write the code for a method named showPostageCost, which will expect to be given an array of doublevalues that specify the weights of a group of parcels/packages.
For example, assume we have made an array of double values, namedwednesdayParcels, containing the values{14.2, 8.9, 17.4, 5.0, 23.5} and gave that array to the showPostageCost method. When called, the method will produce the following output (no gaps between lines):
These are the costs to post the packages:
To send package 1 which weighs 14.2 will cost 52.93
To send package 2 which weighs 8.9 will cost 26.611000000000004
To send package 3 which weighs 17.4 will cost 64.60999999999999
To send package 4 which weighs 5.0 will cost 14.950000000000001
To send package 5 which weighs 23.5 will cost 102.125
That is, it displays an introductory message, followed by one line of output for each package. The structure of each line is the same, but the values will be different.
The rules about package costs are as follows:
- For packages that weigh 18kg or greater, the price is $4.25 multiplied by the weight, plus an extra $2.25 handling fee.
- For packages that weigh 10kg or more, but less than 18kg, the price is $3.65 multiplied by the weight, plus a handling fee of $1.10.
- For packages that weigh less than 10kg, the price is $2.99 multiplied by the weight with no handling fees.
Write the code for the showPostageCost method, so that it will work with any array of double values that maybe provided to it.
Part 2 :We are writing a system that could be used by the Olympics Team for a country, to keep track of the details of all the athletes it is sending to this year's Olympic Games, and what events they are going to individually be competing in. The following class diagram, shows the domain classes required for the system:
![Solutions to questions based on code provided 1](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-1.webp)
Question 6:Which class of the ones shown in the diagram, is the best candidate to be made into an abstract class?
Question7: Why is that class you answered for A, suited to being made an abstract class?
Question8: Give the name of all subclasses for this program?
Question9: What classes are the superclasses of your answer for C ?
Question 10: What is the meaning of the asterisk (*) which appears near the line that connects between Event and Athlete, andwhy has it been placed close to the Event class instead of the Athlete class?
Question 11: Give the names of the fields which are unique to the WeightLifting class.
Question 12:Give the names of the fields inherited by the Running class.
PART 3:
Question 13:We are writing a program to help count the votes of the recent Australian Election.
The following diagram illustrates part of the system's classes, regarding the votes.
![Solutions to questions based on code provided 2](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-2.webp)
Each vote is done at a place called a Polling Booth on paper, but the information about who each person votes forneeds to be transferred from paper into the computer as objects. Each vote will be given a unique integer ID whenit is entered into the computer.
When people vote, they must number the candidates in their preferred order (1 = most preferred, 2 = next most preferred and so on). There are two separate votes each person must do. One is for the "House of Representatives", and the other is for "The Senate". There are different rules about how these two votes are counted.
You now need to write the complete code for the HouseVote class, including all constructors and methods as indicated by the information in the diagram, so that these votes can be recorded in the system. A vote for the House of Representatives requires the person to specify a complete order of all the candidates (e.g. if there are 4candidates, they must choose someone to be 1, someone else to be 2, someone else to be 3 and the remaining person as 4). When initially created, a vote is waiting for the first-preference to be obtained (sonextUnprocessedPref will be 1). Each time getNextUnprocessedPref is called, it will return the candidate number (a number from 1 to the number of candidates, according to the next preference stored in the array) and increase thenextUnprocessedPref number by 1 ready for the next time it is called.
If you include things that are not required, marks may be deducted. If you miss-out including things which should be included, you will miss-out on marks.
PART 4:
A program is being written for an Airport. The following shows one class in the system, representing Flights that depart or arrive at the airport:
Question 14:Write a declaration suitable for an array capable of storing up to 250 objects of the Flight class type, and a separate declaration suitable for a variable to keep track of how many have been added so far to the array (initially no objects are added):
Question 15: Write the code for a method named addFlight which will expect to receive (as a parameter) an object of the Flightclass. If the parameter is indeed a Flight object, then it should add the object to the array in the next availableposition, and make other suitable adjustments so that a subsequent call of the method will work in the samemanner. If all positions of the array are in use, or the parameter is inappropriate, then just return false, otherwiseif the parameter is acceptable and the object stored into the array, then return true.
Question 16: Write the code for a method named showDeparting which expects to receive (as a parameter) a string specifying aplace where flights may depart from. It should then display a list of all flights that have the same place set as their'origin' location. For example, if 'Melbourne' was the parameter, it would show all the flights which originate fromMelbourne.
For each flight reported, show the Origin, Destination, and date and time for the flight, one flight per line.
PART 5:
Question 17: When using git, what is the difference between 'fetch' and 'pull' when updating the local copy of the repository? Use an example scenario to help explain your answer
PART 6:
Consider the following GUI Frame which has been generated by some Java code, then answer the questions which follow:
Question 18:What are the Java classes used to create the component which appears as the wide box saying "Get Quote" in themiddle?
Question 19:Write the complete lines of codes which most likely created the component which appears as the wide box saying"Get Quote" in the middle
Question 20: Write are the lines of code which most likely created the component which is showing 23.6 in the above image.
Question 21: What are the the Java classes used to create the component which appears as the box with the tick in it, beside the words"Night (12am-6am)?"
PART 7:
Consider again the following GUI Frame (the same as for the previous question) which has been generated by some Java code:
The first white box on the right is named txtDistance.
The second white box on the right is named txtPassengers
The box with the tick is named chkNightFare
The label which appears underneath the button, but has no contents at the moment is named lblFare.
Question 22:Write the code to create a suitable inner-classthat could be provided to the addActionListener method of the button that says "Get Quote" in the image, so that when the button is clicked, it will calculate the fare and display it in the lblFare label, using the following rules:
-If the box labeled "Night (12am-6am)?" is ticked, the fare rate is 2.11 per kilometer. Otherwise it is 1.98 perkilometer.
- For each passenger, there is a charge of $3.20 added to the fare.
(So for the above image, the fare would be 56.196)
PART 8:
Question 23: Please find the code file property.java in the text file attached
Provide the address of the property, and the owner. At some later time, we are able to set the 'valuation' amount, which is how much the agency estimates that the property can be sold for. Once that has occurred, photographs must betaken to be used in advertising of the property. After the photographs are taken, the property is advertised as being for sale and people can inspect the property. Eventually, someone will offer to buy the property, and when that happens we will record the amount that they pay for it (which may be higher or lower than the valuation amount was).
Write JUnit tests to test each of the set Methods at least once each, both for expected right behaviour, andalso for expected coping with invalid usage of the method. You should write a separate Test Method for each of the set methods. Take care to consider the object's various states
Solution
![Solutions to questions based on code provided3](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided3.webp)
![Solutions to questions based on code provided 4](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-4.webp)
![Solutions to questions based on code provided 5](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-5.webp)
![Solutions to questions based on code provided 6](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-6.webp)
![Solutions to questions based on code provided 7](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-7.webp)
![Solutions to questions based on code provided 8](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-8.webp)
![Solutions to questions based on code provided 9](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-9.webp)
![Solutions to questions based on code provided 10](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-10.webp)
![Solutions to questions based on code provided 11](https://www.programminghomeworkhelp.com/uploads/images/Solutions-to-questions-based-on-code-provided-11.webp)
Related Samples
Explore our Programming Assignments sample section, featuring diverse programming tasks solved with clarity and expertise. Covering languages like Java, Python, C++, and more, these examples provide insightful solutions to aid students in mastering programming concepts and excelling in their coursework. Perfect for enhancing understanding and achieving academic success in programming assignments.
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming
Programming