PA0
PA 0 -- DukeSpeedometer

PA Objectives
- Call and construct methods located in different classes/files
- Use static class constants
- Perform mathematical operations
- Format text and numbers
- Utilize scanner to obtain user input
Honor Code
This assignment must be completed individually. Your submission must conform to the JMU Honor Code. Authorized help is limited to general discussion on Piazza, the lab assistants assigned to CS149, and the instructor. Copying work from another student or the Internet is an honor code violation and will be grounds for a reduced or failing grade in the course. If you do receive help from a TA or the instructor, make sure you acknowledge that help in your Javadoc comments.
Background
In this assignment, you will develop a "smart" speedometer that will display information a driver. The Goldendoodle software company needs your help to build this speedometer. Given the current micro-chip shortage, the only speed sensing equipment available in cars is limited to kilometers per hour (KPH). However, most drivers in the United States are accustomed to speed being displayed in miles per hour (MPH). To make matters worse, the distances traveled for a trip is measured in YARDS. Your job is to make the speedometer display "sensible" information given these inputs.
Requirements
You will utilize 5 files in building this PA. You must place all these files in the same folder. For your files, you will need to compile them and make sure that the .class file exists and is update to date wtihin the folder.
- InputUtil.java - The class developed as part of HW 4.2. You will utilze the methods here to accept input for this PA.
- Convert.java - The class developed as part of HW 4.3. You will augment this class by adding a method, fromYardsToMiles.
- DukeDashboard.java - You will write this class and it must contain a main method that will accept and process user input (see below).
- Dashboard.class - This class provides the visual display of the speedometer. It has 2 methods that you will utilize for this PA:
- public static void setSpeed(double mph)
Displays the speed provided on the speedometer. - public static void setTripInfo(String averageMPHStr, int hoursTraveled, int minutesTraveled)
Displays the average speed on both kph and mph on the dashboard.
Calling these methods will make the Dashboard display and will set the information on it.
- public static void setSpeed(double mph)
- TestDukeDashboard.java - You will write this class. The main method should call into your conversion routines (fromYardstoMiles) and illustrate that they work.
DukeDashboard.java
The main method in this class must perform the following actions:
- Prompt the user for 3 values as shown below:
What speed is the car going currently (in kph): 130 How many yards has the car traveled so far on this trip: 176500 How long have you been driving (in minutes): 85
You must use the InputUtil class to read the input from the user. Solutions that return the correct answer but do not utilize the InputUtil method to perform these actions will not receive full credit. - You will need to convert the speed provided into miles per hour (MPH). You must update the speed of the speedometer calling the setSpeed method. You must use the Convert class to perform any conversions. Solutions that return the correct answer but do not utilize the Convert class will not receive full credit.
- The speedometer also displays the average speed (in MPH) and the trip duration (express in hours and minutes). You must compute these values and then call setTripInfo to update the information on the speedometer. Note that this method takes a String for the speed information and that the String should be exactly 6 positions in length and have 2 positions to the right of the decimal point. You do not need to worry about speeds greater than 999.99 MPH.
Hint You can use String.format to format the average speed. It takes the same arguments as System.out.printf: a format specifier followed by a sequence of values. The main difference is that System.out.printf displays the result on the screen. String.format creates and returns a new string but does not display anything. (Mayfield, Think Java Chp 6.11)
Example Input
What speed is the car going currently (in kph): 130 How many yards has the car traveled so far on this trip: 176500 How long have you been driving (in minutes): 85
What speed is the car going currently (in kph): 120 How many yards has the car traveled so far on this trip: 721600 How long have you been driving (in minutes): 424
Grading/Rubrics
This assignment is worth 50 points and are broken down as follows:
Requirement | Points |
---|---|
Checkstyle | 5 points |
Scanner questions formatted correctly | 10 points |
Methods from InputUtil are used (not checked by Autolab) | 5 points |
Speed conversions are performed and set in the dashboard correctly | 10 points |
Trip info computed correctly and set in the dashbord correctly | 15 points |
Test cases in TestDukeDashboard.java (note that Autolab will award 1 point for including the file, the other 4 points are from manually reviewing your file) | 5 points |
Submission
Submit InputUtil.java, Convert.java, DukeDashboard.java, and TestDukeDogDashboard.java as a single zip file named pa‑final-0.zip via https://autolab.cs.jmu.edu. For help creating zip files, see the CS Wiki.