Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

Why are flexible resources essential to lean production?

Answered: 1 week ago

Question

Explain the market segmentation.

Answered: 1 week ago

Question

Mention the bases on which consumer market can be segmented.

Answered: 1 week ago