1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
goblinko [34]
3 years ago
9

Complete the following method that takes a String parameter that is a time in American 12 hour format, such as "06:12 PM." The m

ethod returns a String with the same time in standard international 24 hour form. For example, given the parameter in the example above, the method would return "18:12." Values with AM correspond to times from 00:00 to 11:59 and PM for times from 12:00 to 23:59. Recall the method Integer.parseInt() takes a String parameter and returns the integer equivalent. And then simply I am supposed to create a method like so... public static String convertTime(String amerFormat) { }
Engineering
1 answer:
goldfiish [28.3K]3 years ago
8 0

Answer:

public class AmericanTimeFormatting {

  public static String convertTime(String amerFormat)

  {

   

      if(amerFormat.length()<8) {

          System.out.println("Length of the input string should be 8");

          return null;

      }

   

      else if(!Character.isDigit(amerFormat.charAt(0)) && !Character.isDigit(amerFormat.charAt(1)) && !Character.isDigit(amerFormat.charAt(3)) && Character.isDigit(amerFormat.charAt(4))) {

          System.out.println("Digit is requird");

          return null;

      }

 

      else if(amerFormat.charAt(2)!=':'|| amerFormat.charAt(7)!='.') {

          System.out.println("Punctuation required");

          return null;

      }

      //Am or Pm specification check

      else if(!amerFormat.substring(5,7).equals("PM") && !amerFormat.substring(5,7).equals("AM")){

          System.out.println("Required PM or AM");

          return null;

      }

      else {

          //For PM

          if(amerFormat.substring(5,7).equals("PM")) {

              String time="";

              int hour=Integer.parseInt(amerFormat.substring(0,2));

              hour=24-(12-hour);

              time+=String.valueOf(hour)+":";

              int minute=Integer.parseInt(amerFormat.substring(3,5));

              time+=minute;

              return time;

          }

          //For AM

          else {

              return amerFormat.substring(0,5);

          }

         

      }

  }

  public static void main(String[] args) {

 

      String time=convertTime("06:12PM.");

   

      if(!time.equals(null)) {

          System.out.println("Time is "+time);

      }

  }

}

You might be interested in
An AX ceramic compound has the rock salt crystal structure. If the radii of the A and X ions are 0.137 and 0.241 nm, respectivel
Tju [1.3M]

Answer:

c) 1.75 g/cm³

Explanation:

Given that

Radii of the A ion, r(c) = 0.137 nm

Radii of the X ion, r(a) = 0.241 nm

Atomic weight of the A ion, A(c) = 22.7 g/mol

Atomic weight of the X ion, A(a) = 91.4 g/mol

Avogadro's number, N = 6.02*10^23 per mol

Solution is attached below

3 0
3 years ago
How many hours should I charge a 4.8v 600mah battery (I need it by today please)
prohojiy [21]

The number of hours that will be needed to charge a 600mah battery will be 1.5 hours.

<h3>What is a battery?</h3>

It should be noted that an electric battery simply means a source of electric power that consist of one or more electrochemical cells that are with external connections that are important for powering electrical devices.

It should be noted that when a battery is supplying power, then the positive terminal is the cathode while the negative terminal is the anode.

In conclusion, the number of hours that will be needed to charge a 600mah battery will be 1.5 hours.

Learn more about battery on:

brainly.com/question/16896465

#SPJ1

5 0
2 years ago
Which metal is used in planes.
wel

Answer:

<h2>Steel</h2>

Explanation:

Steel is the metal that using in planes.

Aluminum and titanium also used in this aircraft industry.

Aluminum is ideal for aircraft manufacture because it's lightweight and strong.

<em>hope</em><em> </em><em>this</em><em> </em><em>helps</em><em>!</em><em>!</em>

<em>have</em><em> </em><em>a</em><em> </em><em>nice</em><em> </em><em>day</em><em>!</em>

<em>follow</em><em> </em><em>me</em><em> </em><em>=</em><em>=</em><em>></em><em> </em><em>Hi1315</em>

5 0
3 years ago
Read 2 more answers
Which crystal system(s) listed below has (have) the following relationship for the unit cell edge lengths?
lianna [129]

Answer:

Both B and G ( Hexagonal and Tetragonal )

Explanation:

The crystals system listed below has the following relationship for the unit cell edge lengths; a = b ≠ c ( hexagonal and Tetragonal )

hexagonal ; represents  a crystal system  which has three equal axes that have an angle of 60⁰ between them while Tetragonal denotes crystals that have  three axes which have only two of its axes equal in length.

5 0
3 years ago
The tolerance for a geometric can be easily identified by reading the _________.
baherus [9]

Answer:

C

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • You’ve experienced convection cooling if you’ve ever extended your hand out the window of a moving vehicle or into a flowing wat
    6·1 answer
  • Consider the following program:
    15·1 answer
  • The screw of shaft straightener exerts a load of 30 as shown in Figure . The screw is square threaded of outside diameter 75 mm
    5·1 answer
  • Flow and Pressure Drop of Gases in Packed Bed. Air at 394.3 K flows through a packed bed of cylinders having a diameter of 0.012
    8·1 answer
  • a. To measure the water current in an ocean, a marker is dropped onto it. Determine if the trajectory traced by the drifting mar
    5·1 answer
  • Why are Gas cars Bad?(cons) give me reasons why gasoline cars are bad<br><br>Thx if u help ​
    14·1 answer
  • An individual is planning to take an 800-mile trip between two large cities. Three pos-sibilities exist: air, rail, or auto. The
    8·1 answer
  • saan nag tungo si Aguinaldo at ilang pinuno ng kilusan pagkatapos mapairal ang kasunduan na pansamantalang nag dulot ng kapayapa
    6·1 answer
  • For installations where the nonlinear load is huge, most consulting engineers will specify ____-rated transformers.
    8·1 answer
  • I NEED HELP!!!Situation: A client has hired Jose, a materials engineer, to develop a package for an item he has begun to market.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!