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]
2 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]2 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
Suppose that a wireless link layer using a CSMA-like protocol backs off 1ms on average. A packet’s link and physical layer heade
Liula [17]
Tell me why i got this question got it right and now won’t remember but i’ll get back at you when i remember
5 0
3 years ago
What are the laws that apply to one vehicle towing another?
Sergeu [11.5K]
The drawbar or other connections must be strong enough to pull all the weight of the vehicle being towed. The drawbar or other connection may not exceed 15 feet from one vehicle to the other.
5 0
2 years ago
Which list ranks these jobs in the STEM career cluster based on the years of schooling required, from the most to least?
shutvik [7]

Answer:

yes it's C

Explanation:

3 0
2 years ago
Read 2 more answers
Design an op amp circuit to average the input of six sensors used to measure temperature in restaurant griddles for a large fast
Marina CMI [18]

Answer:

See the attached file for the design.

Explanation:

Find attached for the explanation.

3 0
3 years ago
A 1,040 N force is recorded on a hemispherical vane as it redirects a 2.5 cm- blade diameter water jet through a 180 angle. Dete
Alex777 [14]

This question is incomplete, the complete question is;

A 1,040 N force is recorded on a hemispherical vane as it redirects a 2.5 cm- blade diameter water jet through a 180 angle.

Determine the velocity of the flowing water jet if the blade is assumed to be frictionless.

Answer: the velocity of the flowing water jet is 32.55 m/s  assuming the blade is frictionless

Explanation:

Given that;

Force Ft = 1040 N

diameter d = 2.5 cm = 0.025 m

we know that; force acting on Hemispherical plate is;

Ft = 2δav²

where

a is area = π/4(0.025)²

δ is density of water = 1000 kg/m³

v is velocity = ?

now we substitute

1040 = 2 × 1000 × (π/4(0.025)²) × v²

1040 =  0.9817v²

v² = 1040 / 0.9817

v² = 1059.3867

v = √1059.3867

v = 32.5482 ≈ 32.55 m/s

Therefore the velocity of the flowing water jet is 32.55 m/s  assuming the blade is frictionless

8 0
2 years ago
Other questions:
  • Describe the steps, tools, and technology needed in detail and
    12·1 answer
  • If d=0.25m and D=0.40m. Assume headloss from the contraction to the end of the pipe can be found as hų = 0.9 (V is velocity in t
    8·1 answer
  • From the information generated in Prob. 6.4 (from your previous Aero HW#1), calculate the maximum rate of climb for the single-e
    13·1 answer
  • 29
    6·1 answer
  • A water agency stated that waterlines cannot have water flowing faster than 8 ft/s. What is the minimum standard pipe diameter t
    12·1 answer
  • Write multiple if statements
    5·1 answer
  • Four subjects civil engineers need to study​
    12·1 answer
  • A window‐mounted air‐conditioning unit (AC) removes energy by heat transfer from a room, and rejects energy by heat transfer to
    13·1 answer
  • Were women treated as equals to men in early aviation history?
    14·2 answers
  • Aqueous cleaners are ________ parts cleaning agents.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!