Download the file Metric.java Download Metric.java. Use this to perform the following: Read the code and run
Question:
Download the fileMetric.javaDownload Metric.java. Use this to perform the following:
- Read the code and run it once to make sure it works fine.
- Study the code and identify redundancy in it.
- Modify the program by defining and using additional static methods (minimum of 4 methods) to eliminate the redundancy. Make sure there is no code duplication.
- The main( ) method should contain only method calls. No System.out.println calls.
- Make sure your revised program producesexact same outputas the original program including spaces.
- Save your file as "Metric.java" and upload to Canvas.
Be sure to add the top comment block in the file giving your name, date, purpose of the program.
/* * CS210 Methods - Metric * Add your name, date, quarter * * * This writes the lyrics to The Metric Song */
public class Metric {
public static void main(String[] args) {
System.out.println("The Metric Song"); System.out.println(); System.out.println("Oh, metric. You're the one."); System.out.println("You make measuring more fun."); System.out.println("Based on ten. Let's start again"); System.out.println("And go the metric way."); System.out.println(); System.out.println("There was once a family of giants"); System.out.println("And Kilo was their name."); System.out.println("They were all so huge and tall"); System.out.println("And no two were the same."); System.out.println(); System.out.println("Oh, metric. You're the one."); System.out.println("You make measuring more fun."); System.out.println("Based on ten. Let's start again"); System.out.println("And go the metric way."); System.out.println(); System.out.println("There also were some tiny elves"); System.out.println("Who had the name of Milli."); System.out.println("One one thousandth-they're so small"); System.out.println("To think of them seems silly!"); System.out.println(); System.out.println("Oh, metric. You're the one."); System.out.println("You make measuring more fun."); System.out.println("Based on ten. Let's start again"); System.out.println("And go the metric way."); System.out.println(); System.out.println("Now milligrams, they don't weigh much."); System.out.println("And millimeters are short."); System.out.println("A milliliter's a tiny drop"); System.out.println("Of liquid they report."); System.out.println(); System.out.println("Oh, metric. You're the one."); System.out.println("You make measuring more fun."); System.out.println("Based on ten. Let's start again"); System.out.println("And go the metric way."); System.out.println(); System.out.println("So, grams you may have noticed"); System.out.println("Are things you can weigh."); System.out.println("Length is meter, liquid's liter."); System.out.println("That's the metric way."); System.out.println(); } }