Write a Python program named DataByteConvert that asks the user to enter a Data in
MegaBytes (MB) Data is entered only in MegaBytes. The program will then present the
following menu of selections:
1. Convert to Bytes
2. Convert to KiloBytes (KB)
3. Convert to GigaBytes(GB)
4. Convert to TerraBytes(TB)
5. Quit the program
The program will convert the data in MegaBytes(MB) to bytes, kilobytes(KB), GigaBytes(MB),
or TerraBytes(TB), depending on the user's selection rounded to six decimals. Here are the
specific requirements:
• Write a void method named showKiloBytes, which accepts the number of
MegaBytes(MB) as an argument. The method should display the argument
converted to kilobytes(KB). Convert the MB to KB.
• Write a void method named showGigaBytes, which accepts the number of
MegaBytes(MB) as an argument. The method should display the argument
converted to Gigabytes(GB).
• Write a void method named show TerraBytes, which accepts the number of
MegaBytes(MB) as an argument. The method should display the argument
converted to TerraBytes(TB). Convert the MB to TB.
• Write a void method named showBytes, which accepts the number of MegaBytes
(MB) as an argument. The method should display the argument converted to
Bytes(B). Convert the MB to B
• Write a void method named menu that displays the menu of selections. This
method should not accept any arguments.
1. The program should continue to display the menu until the user enters 5 to quit the
program.
2. The program should not accept negative numbers for the data in MegaBytes.
3. If the user selects an invalid choice from the menu, the program should display an error
message.
4. Use Exponential format if needed when converted {:e) formats ...)
5. Use
6. Add comments to show what each function does.

Respuesta :

The program to convert MegaBytes to either Bytes, KiloBytes, GigaBytes, or TeraBytes is found in the attached image.

The program defines five helper functions to help the program do its work. The functions are:

  • showBytes: Accepts an argument in megabytes, converts it by multiplying by 1048576, and prints the result
  • showKiloBytes: Accepts an argument in megabytes, converts it by multiplying by 1024, and prints the result
  • showGigaBytes: Accepts an argument in megabytes, converts it by dividing by 1024, and prints the result
  • showTeraBytes: Accepts an argument in megabytes, converts it by dividing by 1048576, and prints the result
  • menu: Displays the menu of options to either convert or quit the program

Within the Main Program, a while loop is used to make sure the menu continues to be presented to the user until the user selects the option to quit.

The inner while loop makes sure the user enters an option within the menu.

Once the user enters an option to convert, the program requests the value to be be converted, in MegaBytes. then an if statement selects the correct conversion function.

Another numeric problem solved using Python can be found here: https://brainly.com/question/20379340

Ver imagen batolisis
ACCESS MORE