Question: Problem 2 (9 points): Disk capacity is usually measured in bytes, KB, MB, GB, and TB. Your goal is to write a program that asks
Problem 2 (9 points): Disk capacity is usually measured in bytes, KB, MB, GB, and TB. Your goal is to write a program that asks the user to enter the disk capacity in bytes and then display it in KB, MB, GB and TB. You will need to implement the following methods: public static long readDiskcapacity (String message) Asks reads the disk capacity from the user in bytes. Since the disk capacity can be a very large value use long instead of int. o public static double convertToMetric (long capacity, long metric) Converts the disk capacity to the desired metric. The first parameter is the disk capacity in bytes and the second is the desired metric o 1024 for KB 1048576 for MB 1073741824 for GB 1099511627776 for TB Declare these variables as final variables in your main method. The method returns the capacity in the desired metric. Hint: to declare a long integer value add an "L' on to the end of the long value. Example: final long example 123456789L; o o public static void displayCapacity (String message, double capacity) Displays the capacity of the disk. For this method you will use the methodprintf to format your output as shown in the example below. o Input: 65465756867 Output: Capacity in KB is Capacity in MB is Capacity in GB is Capacity in TB is 63931403.19 62433.01 60.97 0.06
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
