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
Quelles sont les types de carburant utilisés en aviation
zhenek [66]

hope it's help you ok have a good day

6 0
2 years ago
With reference to the NSPE Code of Ethics, which one of the following statements is true regarding the ethical obligations of th
34kurt

Answer: c. The VW engineers involved were ethically obligated to hold paramount the health, welfare and safety of the public even if their supervisors directed them to implement software and hardware that enabled cheating on the emissions testing software.

Explanation: The National Society of professional Engineers, NSPE define the code of ethics which must guide engineers in their duty. These codes act as principles of personal conduct, towards the public and their employers.  

One of the areas covered by these codes is overriding importance of the safety and health of the public to any other factor. In addition, engineers are to avoid deception and maintain the reputation of their profession. These cannot be sacrificed for the financial gain of their employers or explained away by saying they are following the direction of their employers. While they have certain responsibilities to their employers, the health welfare and safety of the public is more important.  

4 0
3 years ago
The design specifications of a 1.2-m long solid circular transmission shaft require that the angle of twist of the shaft not exc
Verizon [17]

Answer:

c = 18.0569 mm

Explanation:

Strategy  

We will find required diameter based on angle of twist and based on shearing stress. The larger value will govern.  

Given Data  

Applied Torque

T = 750 N.m

Length of shaft

L = 1.2 m

Modulus of Rigidity

G = 77.2 GPa

Allowable Stress

г = 90 MPa

Maximum Angle of twist  

∅=4°

∅=4*\pi/180

∅=69.813 *10^-3 rad

Required Diameter based on angle of twist  

∅=TL/GJ

∅=TL/G*\pi/2*c^4

∅=2TL/G*\pi*c^4

c=\sqrt[4]{2TL/\pi G }∅

c=18.0869 *10^-3 rad

Required Diameter based on shearing stress

г = T/J*c

г = [T/(J*\pi/2*c^4)]*c

г =[2T/(J*\pi*c^4)]*c

c=17.441*10^-3 rad

Minimum Radius Required  

We will use larger of the two values  

c= 18.0569 x 10^-3 m  

c = 18.0569 mm  

3 0
3 years ago
A 0.40-m3 insulated piston-cylinder device initially contains 1.3 kg of air at 30°C. At this state, the piston is free to move.
Setler79 [48]

Answer:

(a) The Final Temperature is 315.25 K.

(b) The amount of mass that has entered  0.5742 Kg.

(c) The work done is 56.52 kJ.

(d) The entrophy generation is 0.0398 kJ/kgK.

Explanation:

Explanation is in the following attachments.

6 0
3 years ago
Grinding with the portable disc grinder should not be done in an area which​
emmainna [20.7K]
Nothing flammable of explosive type of material is around
7 0
2 years ago
Other questions:
  • Water discharging into a 10-m-wide rectangular horizontal channel from a sluice gate is observed to have undergone a hydraulic j
    12·1 answer
  • The value 100 MW is equivalent to (a) 100×10^6 w (b) 100 x 10^-6 w (c) 100 x 10^-3 w (d) 100 x 10^3 w
    14·1 answer
  • 12. A structural component is fabricated from an alloy that has a plane strain fracture toughness of It has been determined that
    11·1 answer
  • Which of these parts of a cell phone is least likely to be found on the phone's circult board?
    5·1 answer
  • The difference in potential energy between an electron at the negative terminal and one at the positive terminal is called the _
    11·1 answer
  • What are the functions of the peripheral nervous system
    6·2 answers
  • Fluid systems can distribute pressure unequally to all points in a system.<br><br> True<br> False
    15·1 answer
  • Steam enters an adiabatic turbine at 6 MPa, 600°C, and 80 m/s and leaves at 50 kPa, 100°C, and 140 m/s. If the power output of t
    14·1 answer
  • Match the use of the magnetic field to its respective description.​
    6·1 answer
  • What is the primary difference between the process of lost-wax casting as practiced in ancient times and that same process today
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!