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
marshall27 [118]
3 years ago
14

Design a program that will receive a valid time in the 24-hour format (e.g. 2305) and convert to its equivalent 12-hour format (

e.g. 11:05 PM). Assume 0000 in 24-hour format is 12:00AM in 12-hour format. The program should continue accepting inputs until a sentinel value of 9999 is entered. Hint: Use System.out.printf statements with "d" (Links to an external site.) to match output format. Ex: If the input is: g
Computers and Technology
1 answer:
coldgirl [10]3 years ago
8 0

Answer:

import java.io.*;

public class Main

{

  public static void main(String[] args) throws IOException {

      BufferedReader bufferObject=new BufferedReader(new InputStreamReader(System.in));

      String stringObject=bufferObject.readLine();

      while(!stringObject.equals("99:99AM")){

      System.out.println(convertedTime(stringObject));

      stringObject=bufferObject.readLine();

      }

  }

  public static String convertedTime(String stringObject){

  String s=stringObject.substring(stringObject.length()-2);

  String[] timeObject=stringObject.substring(0,5).split(":");

  if(s.equals("AM")){

  if(timeObject[0].equals("12")) return "00"+timeObject[1];

  else return timeObject[0]+timeObject[1];

  }

  else{

  if(timeObject[0].equals("12")) return "12"+timeObject[1];

  else{

  int hours=Integer.valueOf(timeObject[0]);

  timeObject[0]=String.valueOf(12+hours);

  return timeObject[0]+timeObject[1];

  }

  }

 

  }

}

Explanation:

  • Inside the main method run a while loop until stringObject is not equal to the string "99:99AM".
  • Call the convertedTime method and display the results.
  • Use the same hours and minutes except for 12th hour If the time is in AM.
  • Use "00" instead of 12, if it is 12th hour.
  • Add hours to 12, if the time is in PM and don't change anything in case of 12.
You might be interested in
How to answer others questions on Brainly but on a website.
aniked [119]

Answer:

searching do brainly website

3 0
1 year ago
your manager has asked you to implement a network infrastructure that will accommodate failed connections. which of the followin
Softa [21]

The <u>Mesh</u> network topologies provides redundancy for a failed link.

What are network topologies?

A communication network's topology refers to <u>how its components are organized.</u> Command and control radio networks, industrial fieldbuses, and computer networks are just a <u>few examples of the several types of telecommunication </u><u>networks </u><u>that can be defined or described using </u><u>network topology</u><u>.</u>

There are eight fundamental topologies that can be identified by studying network topology: <u>point-to-point, bus, star, ring or circular, mesh, tree, hybrid, or daisy chain.</u>

Examples of physical network topologies include star, mesh, tree, ring, point-to-point, circular, hybrid, and bus topologies. <u>Each of these </u><u>networks </u><u>consists of a unique arrangement of nodes and links.</u>

To learn more about network topologies, use the link given
brainly.com/question/13818848
#SPJ4

4 0
1 year ago
An expansion ____ is a long-narrow socket on the motherboard into which you can plug an expansion card.
Valentin [98]
The answer is
An expansion Slot
7 0
3 years ago
What can make an online interface difficult to use?​
Natalija [7]

Answer:

their is a lot miscomsuptions

Explanation:

8 0
3 years ago
Networks that are designed to connect similar computers that share data and software with each other are called:_______
sergij07 [2.7K]

Networks that are designed to connect similar computers that share data and software with each other are called: Peer to Peer (P2P) Networks.

<h3>What is a networking software?</h3>

A networking software can be defined as a set of executable instructions (codes) that is typically designed and developed to instruct a networking device on how to perform a specific task or transmit data from one location to another.

<h3>The types of networking software.</h3>

Generally, there are three main types of networking software and these include the following:

  • Security software
  • Connection software
  • Transport software

In Computer networking, Peer to Peer (P2P) Networks can be defined as a type of network that are designed and developed to connect similar computers that share data and software with each other.

Read more on Peer to Peer Networks here: brainly.com/question/1932654

#SPJ1

7 0
2 years ago
Other questions:
  • What’s of the following can be used to visually represent information similar to diagrams format painter Helens smart are a clip
    8·1 answer
  • The Active Directory Users and Computers tool can be used to:______.
    11·1 answer
  • What important practice can help prevent hardware trouble?
    6·1 answer
  • What is the extension of Excel worksheet?
    8·1 answer
  • Advancements in nuclear science have led to technological advances which are both harmful and beneficial. Which would be conside
    15·1 answer
  • Name the written test a potential driver must pass and list the minimum required score to earn a learner’s license.
    8·2 answers
  • The following are part of characteristics of a software requirement specification.
    6·1 answer
  • How to get free PS5?
    8·2 answers
  • with the aid of your own example explain how memory,registers and secondary storage all work together​
    8·1 answer
  • Can computers be opened from the All programs submenu
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!