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
Which of the followong parts does not rotate during starter operation? A. Commutator segments B. Armature windings c. Field wind
photoshop1234 [79]

Answer: B

Explanation: unless newer models added wingding to code inside fused computer...wingdings on a window ...not a motor

8 0
2 years ago
Consider a simply supported rectangular beam with a span length of 10 ft, a width of 8 in, and an effective depth of 20 in. Norm
yulyashka [42]

Answer:

beam with a span length of 10 ft, a width of 8 in, and an effective depth of 20 in. Normal weight concrete is used for the beam. This beam carries a total factored load of 9.4 kips. The beam is reinforced with tensile steel, which continues uninterrupted into the support. The concrete has a strength of 4000 psi, and the yield strength of the steel is 60,000 psi. Using No. 3 bars and 60,000 psi steel for stirrups, do the followings:

8 0
2 years ago
Each of the following activities are commonly performed during the implementation of the Database Life Cycle (DBLC). Fill in the
kicyunya [14]
Yessiree I agree with yu cause yu are right
4 0
3 years ago
A three-point bending test is performed on a glass specimen having a rectangular cross section of height d 5 mm (0.2 in.) and wi
Anon25 [30]

Answer:

The flexural strength of a specimen is = 78.3 M pa

Explanation:

Given data

Height = depth = 5 mm

Width = 10 mm

Length L = 45 mm

Load = 290 N

The flexural strength of a specimen is given by

\sigma = \frac{3 F L}{2 bd^{2} }

\sigma = \frac{3(290)(45)}{2 (10)(5)^{2} }

\sigma = 78.3 M pa

Therefore the flexural strength of a specimen is = 78.3 M pa

4 0
2 years ago
Choose two consumer services careers and research online to determine what kinds of professional organizations exist for these p
Tom [10]

Answer:

Market Researcher

The Marketing Research Association (MRA) is a professional organization for market researchers. It provides information to its members on how to improve marketing research for businesses and individuals. The MRA gives its members important industry news and information through their website. Their code for marketing research standards also protects members from bad actors and improves the public perception of marketing research. The association also has a full time lobbyist representing the market research industry before government officials. The MRA has various membership categories as well. The membership fee differs for each category.  

Credit Analyst

A credit analyst is a person that reviews consumer or business financial profiles in order to give a loan or credit to them. When a business or individual applies for a credit card, loan, trade account, or another type of financial product whereby a company allows them the use of their money, a credit analyst’s job is to ensure that the consumer or business is willing and able to pay it back in the future. Credit analysts use tools such as credit reports, FICO scores, Dun & Bradstreet ratings, financial statement analyses, and personal references to perform their job. A credit analyst should have a bachelor’s degree with a major in business. Finance and economics majors are particularly suited to a credit analyst position. Certifications are not required, but some credit analysts pursue CPA or CFA (Certified Financial Analyst) designations.

Explanation:

5 0
3 years ago
Other questions:
  • A room is cooled by circulating chilled water through a heat exchanger located in the room. The air is circulated through the he
    15·1 answer
  • A heavy ball with a weight of 110 N is hung from the ceiling of a lecture hall on a 4.9-m-long rope. The ball is pulled to one s
    6·1 answer
  • The solid cylinders AB and BC are bonded together at B and are attached to fixed supports at A and C. The modulus of rigidity is
    6·1 answer
  • The grade is a measure of quality and it captures concentration levels (i.e., how pure a certain fraction is). If grade captures
    13·1 answer
  • 4. Two technicians are discussing the evaporative emission monitor. Technician A says that serious monitor faults cause a blinki
    14·1 answer
  • Why is oil black and why does oil look black
    10·1 answer
  • Which statement describes the relay between minerals and rocks ?
    15·1 answer
  • Who was the American founder and leader of the Shakers in the 1770’s who advocated equality, individual responsibility, and peac
    11·2 answers
  • 7 to 1 inch above the stock
    5·1 answer
  • Which symbol should be used for the given scenario?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!