Question: import java.util.Scanner; public class Measurement { private int src; // Source value (v) private int[] indices = new int[2]; // Indices into the conversions array

 import java.util.Scanner; public class Measurement { private int src; // Source

import java.util.Scanner; public class Measurement { private int src; // Source value (v) private int[] indices = new int[2]; // Indices into the conversions array of units private double dst; // Value in destination units private double[] conversions = {1.0, 1000.0, 12.0, 3.0, 22.0, 10.0, 8.0, 3.0}; // Hard-code conversion factors from smallest to largest // As we are using OOP, have main do as little as possible. public static void main(String[] args) { Measurement obj = new Measurement(); obj.run(); } // This does all the hard work private void run() { Scanner kb = new Scanner(System.in); String aLine = kb.nextLine(); String[] items = aLine.split(" "); // Useful for splitting input up src = Integer.parseInt(items[0]); indices[0] = getIndex(items[1]); indices[1] = getIndex(items[3]); kb.close(); computeDestination(); // Does the actual algorithm System.out.println(dst); // Output final value } // Since the start and end indices are known, now all we have to do // is multiply (or divide) the conversion factors together, // depending on the units private void computeDestination() { // TODO: Implement the algorithm here // End of TODO } // Takes the unit and determines the index where it is stored in // the conversions data attribute. private int getIndex(String unit) { int index = 0; if((unit.compareToIgnoreCase("thou") == 0) || (unit.compareToIgnoreCase("th") == 0)) { index = 0; } else if((unit.compareToIgnoreCase("inch") == 0) || (unit.compareToIgnoreCase("in") == 0)) { index = 1; } else if((unit.compareToIgnoreCase("foot") == 0) || (unit.compareToIgnoreCase("ft") == 0)) { index = 2; } else if((unit.compareToIgnoreCase("yard") == 0) || (unit.compareToIgnoreCase("yd") == 0)) { index = 3; } else if((unit.compareToIgnoreCase("chain") == 0) || (unit.compareToIgnoreCase("ch") == 0)) { index = 4; } else if((unit.compareToIgnoreCase("furlong") == 0) || (unit.compareToIgnoreCase("fur") == 0)) { index = 5; } else if((unit.compareToIgnoreCase("mile") == 0) || (unit.compareToIgnoreCase("mi") == 0)) { index = 6; } else if((unit.compareToIgnoreCase("league") == 0) || (unit.compareToIgnoreCase("lea") == 0)) { index = 7; } return index; } } 

Please Implement the computeDestination()

In Java

NOTE: Submit this part as a file submission by Saturday, Feb. 13 at noon.This file must be in a readable source code format that I can compile and test. This part is worth 50 points total. Show your work and write comments to get partial credit. Code in Java is provided on BlackBoard. You mus implement the computeDestination method. Exercise 1 (50 pts) The traditional imperial system has eight units of distance (excluding maritime units and some units used in surveying), related as follows: thou (th) inch (in) foot (ft) yard (yd) chain (ch) furlong (fur) mile (mi) league (lea) 1000 thous 12 inches 3 feet 22 yards 10 chains 8 furlongs 3 miles Given a distance measured in one of these units, can you figure out what it will be in another unit? Input The input consists of a single line of the form av u in , where 1 su s 100 is an integer amount and u, are any of the units listed above, indicating that we are converting v u's into s. Units are given either by their full name or by their acronym, but will always be given in singular using only lower case letters. Output Output the distance converted into . You do not need to worry about the precise formatting of the answer (e.g., number of decimals), but either the absolute error or the relative error of your output must be smaller than 10%. 1 Sample Input 42 ft in inch 10 furlong in lea Sample Output 504 0.4166666666667

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To implement the computeDestination method you need to perform conversions based on the conversion f... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!