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
an attacker is attempting to crack a system's password by matching the password hash to a hash in a large table of hashes he or
disa [49]

The type of attack is the attacker using Rainbow attack

  • Rainbow attack is a type of system attack where the password is gotten from the hash. It often contains large databases of pre-computed hashes.

Conclusively we can therefore say that the type of attack is the attacker using Rainbow attack

Learn more

brainly.com/question/4100402

8 0
3 years ago
_ is the use of a collection of computers, often owned by many people or different organizations, to work in a coordinated manne
ddd [48]

Answer:

"Grid computing" is the correct answer for the above question.

Explanation:

  • Grid computing is a process in which many computers are participating to solve a single problem. This type of process is distributed multiple computers to perform a different type of task.
  • If there is large problem and if many computers solve that problem, then that problem is solved easily within a few minutes.
  • This is because many computers are working for that problem.
  • The above question asked about that process in which many computers are working to solve a single problem. This processor is known as "Grid Computing".
8 0
3 years ago
Select the correct answer from each drop-down menu.
DerKrebs [107]

Answer:

?

Explanation:

?!?!

3 0
3 years ago
URGENTE DOY 60 PUNTOS. Porfavor alguien sabe como se llama el juego de mesa que consiste en adivinar la palabra con audifonos qu
Anastasy [175]

Answer:

retro del susurro

Explanation:

el reto del susurro es el juego divertido donde alguien tiene que adivinar que le están diciendo cuando están escuchando música

3 0
3 years ago
The domain name is passed to a domain name server, which maps it to the correct IP address, and then the code behind the page is
maxonik [38]
It's an incomplete, therefore wrong, description of "<span>B. Browser using a URL to access a web page"

After the nameserver returns the IP address of the domain, the client machine makes the page request from the IP address. The client's browser parses (reads) the HTML code, makes calls to the server for any other files (href, img and media) and displays the HTML content according to visual specifications in the CSS (Cascading Style Sheet).
</span>
6 0
3 years ago
Other questions:
  • The default primary key for an access database is the id field true or falser
    7·1 answer
  • How can employees advance their current skills or expertise in a particular occupation?
    13·1 answer
  • Write a function with two parameters, prefix (a string, using the string class from ) and levels (an unsigned integer). The func
    14·1 answer
  • Usually, the same software that is used to construct and populate the database, that is, the DBMS, is also used to present ____.
    11·1 answer
  • During a network evaluation an administrator discovers excessive cable between a transmitter and its antenna. To clean up the lo
    9·1 answer
  • What is the main purpose of dtp software?
    10·1 answer
  • A network administrator has configured a router for stateless DHCPv6 operation. However, users report that workstations are not
    13·1 answer
  • An example of a _________________ impact is when a consumer wants to buy a product on the internet but is afraid the company won
    8·2 answers
  • List 5 uses of computer​
    9·1 answer
  • Big data are _____. Select 2 options. (please help!)
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!