Menu

[Solved]1 Complete Following Method Takes String Parameter Time American 12 Hour Format 06 12 Pm M Q37291384

1. Complete the following method that takes a String parameterthat is a time in American 12 hour format, such as “06:12PM.”

The method returns a String with the same time in standardinternational 24 hour form. For example, given the parameter in theexample above, the method would return “18:12.” Values with AMcorrespond to times from 00:00 to 11:59 and PM for times from 12:00to 23:59.

Recall the method Integer.parseInt() takes a String parameter andreturns the integer equivalent.

// precondition: the String value of the time parameter is validand
// has a length of 8 characters.
public static String convertTime(String amerFormat)
{

}

2.

Complete the DiskDrive class shown below. A DiskDrive keepstrack of how much disk space is used and how much is free. Themaximum size of the drive is a parameter to the constructor. Theoccupied space on the drive can never exceed the maximum size ofthe drive and can never go below zero.

public class DiskDrive
{
     // declare instance variables

     // postcondition: all instancevariables are initialized
     public DiskDrive(doublesizeCapacity)
     {

     }

     // postcondition: the disk spaceoccupied is increased by the amount given by the
     // parameter and cannot exceed themaximum
     public void addFile(doublesize)
     {

     }

     // postcondition: the disk spaceoccupied is decreased by the amount given by the
     // parameter and cannot benegative
     public void deleteFile(doublesize)
     {

     }

     // postcondition: a quantity equal tothe unoccupied disk space is provided and is
      // not negative
     public double getFreeSpace()
     {

     }

     // other methods not shown
}

Expert Answer


Answer to 1. Complete the following method that takes a String parameter that is a time in American 12 hour format, such as “06:12… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *