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.
Answer:
The correct answer to this question is given below in the explanation section.
Explanation:
The question is about Moore's Law.
The given options in this question are:
- states that storage capabilities will triple every two years
-
is a purely abstract concept that does not clearly apply to the computing industry
-
was described by Gordon Moore in the early 2000s to predict growth in the fiber optic industry
-
relates to increases in processing power of computers and has been quite accurate since it was introduced in 1965
The correct option to this question is 4. i.e:
Moore's Law related to increases in the processing power of computers and has been quite accurate since it was introduced in 1965. This law was based on a prediction and made by American engineer Gordon Moore in 1965. And it states that the number of transistors per silicon chip doubles every year.
While the other options are not correct because:
It does not state the storage capabilities that will triple every two years, but this law state that computing power and transistors on chips become double every year. It is not a purely abstract concept but it is applied in computing and this law become more famous due to its value. This law was presented in 1965.
Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter the number of bottles and cans:");
int numberOfbottles = in.nextInt();
int numberOfcans = in.nextInt();
System.out.printf("Bottles: %8d\n", numberOfbottles);
System.out.printf("Cans: %8d\n", numberOfcans);
}
}
Explanation:
Ask user to input the number of bottles and cans using Scanner class
Print the results so that the numbers to the right line up (Since we know that the numbers have at most 8 digits, we can use %8d in printf. Also, be aware that how printf statements are written so that the numbers line up)
Software that interprets commands from the keyboard and mouse is also known as the operating system.. Hope this helped