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
A cooling system load is 96,000 BTUh sensible. How much chilled air is required to satisfy the load if the system is designed fo
Natalija [7]

Answer:

For 20^{\circ} - 5.556 lb/s

For 15^{\circ} - 7.4047 lb/s

Solution:

As per the question:

System Load = 96000 Btuh

Temperature, T = 20^{\circ}

Temperature rise, T' = 15^{\circ}

Now,

The system load is taken to be at constant pressure, then:

Specific heat of air, C_{p} = 0.24 btu/lb ^{\circ}F

Now, for a rise of 20^{\circ} in temeprature:

\dot{m}C_{p}\Delta T = 96000

\dot{m} = \frac{96000}{C_{p}\Delta T} = \frac{96000}{0.24\times 20} = 20000 lb/h = \frac{20000}{3600} = 5.556 lb/s

Now, for 15^{\circ}:

\dot{m}C_{p}\Delta T = 96000

\dot{m} = \frac{96000}{C_{p}\Delta T} = \frac{96000}{0.24\times 15} = 26666.667 lb/h = \frac{26666.667}{3600} = 7.4074 lb/s

4 0
3 years ago
What is NOT an example of professional networking?
gogolik [260]

Answer:

funfairs etc

Explanation:

6 0
4 years ago
What does this work for
Anastaziya [24]

Answer:

it allows your dash board to light up you MPH RPM and all the other numbers on the spadomter

Explanat

8 0
3 years ago
How does warming up the tires on a car increase grip with the pavement?
ICE Princess25 [194]

Answer:

because burning rubber increases the grip power

8 0
3 years ago
Using the results of the Arrhenius analysis (Ea=93.1kJ/molEa=93.1kJ/mol and A=4.36×1011M⋅s−1A=4.36×1011M⋅s−1), predict the rate
uysha [10]

Answer:

k = 4.21 * 10⁻³(L/(mol.s))

Explanation:

We know that

k = Ae^{-E/RT} ------------------- euqation (1)

K= rate constant;

A = frequency factor = 4.36 10^11 M⁻¹s⁻¹;

E = activation energy = 93.1kJ/mol;

R= ideal gas constant = 8.314 J/mol.K;

T= temperature = 332 K;

Put values in equation 1.

k = 4.36*10¹¹(M⁻¹s⁻¹)e^{[(-93.1*10^3)(J/mol)]/[(8.314)(J/mol.K)(332K)}

k = 4.2154 * 10⁻³(M⁻¹s⁻¹)

here M =mol/L

k = 4.21 * 10⁻³((mol/L)⁻¹s⁻¹)

 or

k = 4.21 * 10⁻³((L/mol)s⁻¹)

or

k = 4.21 * 10⁻³(L/(mol.s))

3 0
3 years ago
Other questions:
  • What is the primary water source for a water cooled recovery unit's condensing coll?
    8·1 answer
  • What are factor of safety for brittle and ductile material
    5·1 answer
  • A mercury thermometer has a cylindrical capillary tube with an internal diameter of 0.2 mm. If the volume of the thermometer and
    10·1 answer
  • What are the units or dimensions of the shear rate dv/dy (English units)? Then, what are the dimensions of the shear stress τ= μ
    14·1 answer
  • 1. How does manufacturing help strengthen<br> the economy?
    15·1 answer
  • Explain why veracity, value, and visualization can also be said to apply to relational databases as well as Big Data.
    6·1 answer
  • Which of the following identifies one factor that causes conventional tillage to actually be good for the environment?
    7·1 answer
  • Which of the following can cause a flopping sound at the front of the engine
    14·1 answer
  • While recharging a refrigerant system, the charging stops before the required amount of refrigerant has been inserted. What shou
    8·1 answer
  • Which option identifies the free resource Judi can use in the following scenario?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!