ICT104: Program Design and Development - Java Program - IT Assignment Help

Download Solution Order New Solution

Highlights

Internal Code: 1ABCGC

IT Assignment Help

Task: Diesel Consumption App Preamble: A transportation business owner (client) has approached you with a request to write a software application to track the diesel usage of their vehicle fleet. Following data are gathered for each filling;
  1. Amount of diesel purchased (x litres) [float]
  2. Price of diesel (y cents/litre) [integer]
  3. Number of kilometres the vehicle was driven on that filling (z km) [float]
The client requires the application to track the last five such fillings for any given vehicle and alert if the average cost goes above the threshold as per the following table. (Important: The value of threshold is as per the last two digits of student ID from the following table.) IT IT Let’s calculate the average fuel consumption for a single filling. Using the notation above; The average fuel consumption (afc1) = x/z (liters per km) The average cost (ac1) = (x/z)*y (cents per km) Then for five fillings; The overall Average Fuel Consumption (afc) = {afc1+ afc2+...+ afc5}/5 The overall Average Cost (ac) = {ac1+ ac2+...+ ac5}/5 You’ll also need to check if ac exceeds client set threshold warning. Part 1: Write a simple Java program to calculate the average diesel consumption and the average cost for a single filling. Then extend this to include five fillings and calculate the overall average diesel consumption (afc) and average cost (ac) for the five fillings. You’ll also need to warn the user if the average cost is equal to higher than the threshold. In Part 1, you will be developing a Java program without a GUI. Input and output are via the console. When the program is executed, the user will be asked to input for five consecutive fillings:
  • Amount of diesel purchased (in litres)
  • Price of ONE litre of diesel (in cents)
  • The distance travelled after the filling (in km)
Then the program should display afc and ac for the data and indicate if the ac is below the warning level. Hint/Steps for Part 1:
  1. Think about your strategy for how you will calculate the afcn and ac_n for each filling. And then how you work out the overall afc and ac using these calculations. Think about writing simple functions/methods for the repetitive calculations.
  2. Add a simple Java class named Part1. Do not add a GUI.
  3. Declare and instantiate the variables that you will need for Part 1. You will also need several ArrayLists to hold the diesel amount, price, and distance travelled, at the start of the main method, for example (you’ll need to add additional ArraysLists as well): Make use of Generics to define your Collection Framework classes. i.e. ArrayList
  4. Add code to read in the data from the user for the five fillings. A recommended way is to use the Scanner class.
  5. Now add the code that implements your strategy of calculating the afc and ac.
  6. Finally, add three System.out.println() statements that state the overall afc, ac and the warning message if ac exceeds the threshold.
  7. Test your implementation with the test cases mentioned above (and additionally your own).
Part 2: Design and implement a Java Swing GUI application (Java Swing components) that provides an easy to use interface. This GUI application must allow a user to input the various data elements. To this end, the user can
  • input the data using Java Swing GUI elements, e.g. text fields, radio buttons, drop down lists, etc.
  • Click on a Calculate button that starts the calculation of the final results, and
  • An Exit or Quit button to properly close the program.
Use the same code for the calculations from Part 1. Reusing code is an important part of software development. You have a great degree of freedom in what GUI elements you choose and how you would like to design the layout of your GUI. The below example is really just that – an example the design, but you are free to come up with your own design. Notes:
  • For this assignment, you do not have to do any checking for invalid user input (you may of course, if you want to), for example you do not have to check whether the user has typed in a negative number or a zero as discussed earlier.
  • Your user interface does not have to be identical to the one above. This is just an example of how the GUI could look.
  • Your GUI should update the output labels “Average Diesel Consumption “, “Average Cost” and another label to show a warning if the average cost is higher when the Calculate button has been clicked. If “Average Cost” is greater than threshold then display the warning message in Red colour.
Hint/Steps for Part 2:
  1. Draw a sketch of your graphical user interface on paper. What Java Swing components will you use? Where will you place them? The above GUI is just an example. You are free to create your own GUI.
  2. Add all the components for your GUI. Use Java Swing components like JFrame, JLabel, JTextField, JButton.
  3. Add event handlers (ActionListeners) for your buttons, radio buttons, check boxes, etc.
  4. Add the code that does the actions, e.g. that does the calculation for afc and ac. Reuse your code for the calculation Part 1 by copying and pasting it from the Part1main method into the Calculate button’s event handler.
  5. Test your application. Run it as a Java Application. Enter the test cases listed above and make sure your code adheres to the Java style guide. You need to manually add more comments than the automatically generated comments.
This ICT104: IT Assignment has been solved by our IT experts at My Uni Paper. Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.
 

Get It Done! Today

Country
Applicable Time Zone is AEST [Sydney, NSW] (GMT+11)
+

Every Assignment. Every Solution. Instantly. Deadline Ahead? Grab Your Sample Now.