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
What is the saturation pressure, Vf, and Vg for saturated water at a temperature of 287 °C?
Dvinal [7]

Answer:

Vf = specific volume of saturated liquid  = 0.0217158 ft^3/lb

Vg = specific volume of saturated steam = 0.430129 ft^3/lb

Explanation:

Given data:

water temperature is given as 287-degree Celcius

we have to find Vf and Vg

Vf = specific volume of saturated liquid  

Vg = specific volume of saturated steam

we know that from the saturated steam table we can find these value

therefore for temperature 287-degree Celcius

Vf = specific volume of saturated liquid  = 0.0217158 ft^3/lb

Vg = specific volume of saturated steam = 0.430129 ft^3/lb

6 0
3 years ago
A spur gearset has a module of 6 mm and a velocity ratio of 4. The pinion has 16 teeth. Find the number of teeth on the driven g
levacccp [35]

Answer:

NG=64 teeth

dG=384mm

dP=96mm

C=240mm

Explanation:

step one:

given data

module m=6mm

velocity ratio VR=4

number of teeth of pinion Np=16

<u>Step two:</u>

<u>Required</u>

1. Number of teeth on the driven gear

N_G=N_P*V_R\\\\N_G=16*4\\\\N_G=64

<em>The driven gear has 64 teeth</em>

2.  The pitch diameters

The driven gear diameter

d_G=N_G*m\\\\d_G=64*6\\\\d_G=384

<em>The driven gear diameter is 384mm</em>

The pinion diameter

<em />d_P=N_P*m\\\\d_P=16*6\\\\d_P=96<em />

Pinion diameter is 96mm

3. Theoretical center-to-center distance

C=\frac{d_G+d_P}{2} \\\\C=\frac{384+96}{2} \\\\C=\frac{480}{2}\\\\C=240

The theoretical center-to-center distance is 240mm

5 0
3 years ago
A divided multilane highway in a recreational area has four lanes (two lanes in each direction) and is on rolling terrain. The h
sertanlavr [38]

Answer:

Explanation:

Before: PT= 0.10, PB= 0.03 (given) ET = 2.5 ER = 2.0 (Table 6.5)

fHV= 0.847 (Eq. 6.5) PHF = 0.95, fp= 0.90, N=2, V = 2200 (given)

vp= V/[PHF⋅fHVTB⋅fp⋅N] = 1518.9 (Eq. 6.3)

BFFS = 50+5, BFFS =55 (given) fLW= 6.6

TLC=6+3=9 fLC= 0.65

fM= 0.0

fA= 1.0

FFS = BFFS −fLW−fLC–fM–fA= 46.75 (Eq. 6.7)

Use FFS=45 D= vp/S = 33.75pc/mi/ln Eq (6.6)

After: fA= 3.0

FFS = BFFS −fLW−fLC–fM–fA= 44.75 (Eq. 6.7)

Use FFS=45 Vnew= 2600 Vp= Va/[PHF⋅fHB⋅fp⋅N] = 1795 (Eq. 6.3) D= vp/S = 39.89pc/mi/ln

8 0
3 years ago
Si la demanda por un bien final es elástica, entonces la demanda de trabajo correspondiente también es elástica
shusha [124]

Answer:

You can speak English to help you

4 0
3 years ago
An experiment compares the initial speed of bullets fired from two handguns: a 9 mm and a 0.44 caliber. The guns are fired into
olasank [31]

Answer:

1.176

Explanation:

When the bullets impact the mass they become embedded on it, it is a plastic collision, therefore momentum is conserved.

v2 * (M + mb) = v1 * mb

Where

v1: muzzle velocity of the bullet

M: mass of the bob

mb: mass of the bullet

v2: mass of the bob with the bullet after being hit

v2 = v1 * mb / (M + mb)

Upon being impacted the bob will acquire speed v2, this implies a kinetic energy. The bob will then move and raise a height h. Upon acheiving the maximum height it will have a speed of zero. At that point all kinetic energy will be converted into potential energy.

Ek = 1/2 (M + mb) * v2^2

Ep = (M + mb) * g * h

Ek = Ep

1/2 (M + mb) * v2^2 = (M + mb) * g * h

1/2 * (v1 * mb / (M + mb))^2 = g * h

1/2 * v1^2 * mb^2 / (M + mb)^2 = g * h

v1^2 = g *h * (M+ mb)^2 / (1/2 * mb^2)

v2 = \sqrt{\frac{g *h * (M+ mb)^2}{\frac{1}{2} * mb^2}}

The height h that it reaches is related to the length L of the pendulum arm and the angle it forms with the vertical.

h = L * (1 - cos(a))

v2 = \sqrt{\frac{g * L * (1 - cos(a)) * (M+ mb)^2}{\frac{1}{2} * mb^2}}

For the 9 mm:

v2 = \sqrt{\frac{9.81 * L * (1 - cos(4.3)) * (10+ 0.006)^2}{\frac{1}{2} * 0.006^2}} = \sqrt{L} * 391

For the 0.44 caliber:

v2 = \sqrt{\frac{9.81 * L * (1 - cos(10.1)) * (10+ 0.012)^2}{\frac{1}{2} * 0.012^2}} = \sqrt{L} * 460

The ratio is 460 / 391 = 1.176

6 0
3 years ago
Other questions:
  • How much to build a barber clipper?
    10·1 answer
  • Which factor that affects income is out of a worker's personal control?
    13·1 answer
  • In an experiment, one selected two samples of copper-silver alloy. One sample has 40 wt% of silver and 60wt% of copper and the o
    13·1 answer
  • Dampers dampers springs are used inside some valve spring to
    10·1 answer
  • What is the approximate theoretical maximum efficiency of a heat engine receiving heat at 627°C and rejecting heat to 27°c? a)-2
    5·1 answer
  • A flat, circular hydrostatic air bearing has an outer diameter of 160 mm and a 5-mm-deep recess from the 50-mm diameter to the b
    6·1 answer
  • Lana is attending the University of Georgia. Her school network is not accessible to any users outside of the school. This type
    13·2 answers
  • While discussing PCM monitor tests: Technician A says that some monitors only run after another monitor completes. Technician B
    10·1 answer
  • What is your fav movie? mine is truth or dare.
    10·2 answers
  • Why is it important to push a dolly instead of pulling it?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!