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
Which allows a user to run applications on a computing device? Group of answer choices Application software CSS Operating system
sveticcg [70]

Answer:

The operating system

Explanation:

The job of the operating system is to manage system resources allowing the abstraction of the hardware, providing a simple user interface for the user.  The operating system is also responsible for handling application's access to system resources.

For this purpose, the operating system allows a user to run applications on their computing device.

Cheers.

4 0
3 years ago
What’s the answer please help
irina1246 [14]

Answer:

It B

Explanation:

4 0
3 years ago
A person holds her hand out of an open car window while the car drives through still air at 65 mph. Under standard atmospheric c
Paraphin [41]

Answer:

10.8\ \text{lb/ft^2}

101.96\ \text{lb/ft}^2

Explanation:

v_1 = Velocity of car = 65 mph = 65\times \dfrac{5280}{3600}=95.33\ \text{ft/s}

\rho = Density of air = 0.00237\ \text{slug/ft}^3

v_2=0

P_1=0

h_1=h_2

From Bernoulli's law we have

P_1+\dfrac{1}{2}\rho v_1^2+h_1=P_2+\dfrac{1}{2}\rho v_2^2+h_2\\\Rightarrow P_2=\dfrac{1}{2}\rho v_1^2\\\Rightarrow P_2=\dfrac{1}{2}\times 0.00237\times 95.33^2\\\Rightarrow P_2=10.8\ \text{lb/ft^2}

The maximum pressure on the girl's hand is 10.8\ \text{lb/ft^2}

Now v_1 = 200 mph = 200\times \dfrac{5280}{3600}=293.33\ \text{ft/s}

P_2=\dfrac{1}{2}\rho v_1^2\\\Rightarrow P_2=\dfrac{1}{2}\times 0.00237\times 293.33^2\\\Rightarrow P_2=101.96\ \text{lb/ft}^2

The maximum pressure on the girl's hand is 101.96\ \text{lb/ft}^2

5 0
3 years ago
Assume that television broadcasts are nonrival and nonexcludable (some TV stations, such as those on cable TV, are excludable, b
ryzh [129]

Answer: Advertising acts in a method similar to a fee. People who watch TV broadcasts must watch ADs. TV stations turn this into money by selling airtime to advertisers.

Explanation:

A non-rival good is a good whose consumption by one person does not reduce the remaining quantity available. An example is a street light.

For non-excludable goods, it is impossible to prevent everyone from enjoying the benefits of the good. An example is a lighthouse. This is where the free rider problem comes in.

A free rider is someone enjoying the benefits of a good without paying for it.  When a good is both non-rival and non-excludable, it is convenient for consumers to enjoy the benefit without paying for it.

If TV broadcasts are both non-rival and non-excludable, everybody can choose to become a free rider. Advertising can solve this problem by converting free riders to potential buyers of goods or services advertised during broadcasts. This way, stations can generate revenue by selling airtime.

3 0
4 years ago
Read 2 more answers
18
svp [43]

Answer:

серйозних порушень точності,

∵∴⊕∴∵

5 0
3 years ago
Other questions:
  • 1 2 3 4 5 6 7 8 9 10
    14·1 answer
  • During an office party, an office worker claims that a can of cold beer on his table warmed up to 20oC by picking up energy from
    13·1 answer
  • What does CADCAM stand for ?
    10·2 answers
  • A mass of 5 kg of saturated water vapor at 100 kPa is heated at constant pressure until the temperature reaches 200°C.
    6·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
  • A cylindrical specimen of some metal alloy having an elastic modulus of 124 GPa and an original cross-sectional diameter of 4.2
    13·1 answer
  • In a hydraulic system, a 100.-newton force is applied to a small piston with an area of 0.0020 m2. What pressure, in pascals, wi
    13·1 answer
  • What are the advantages to a quality<br> saw?
    6·1 answer
  • You may have to_______
    14·1 answer
  • A manufacturer has been asked to produce 100 customized metal discs with a particular pattern engraved on them. Which production
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!