UGH IKR, LIKE JUST ANSWER THE FRICKIN QUESTION
Answer:
Check the explanation
Explanation:
Keep two iterators, i (for nuts array) and j (for bolts array).
while(i < n and j < n) {
if nuts[i] == bolts[j] {
We have a case where sizes match, output/return
}
else if nuts[i] < bolts[j] {
what this means is that the size of nut is lesser than that of bolt and we should go to the next bigger nut, i.e., i+=1
}
else {
what this means is that the size of bolt is lesser than that of nut and we should go to the next bigger bolt, i.e., j+=1
}
}
Since we go to each index in both the array only once, the algorithm take O(n) time.
Answer:
The solution code is written in Java
- import java.util.Scanner;
-
- public class Main {
- public static void main (String [] args) {
-
- Scanner inStream = new Scanner(System.in);
- System.out.print("Please input a number (1 - 10): ");
- int num = inStream.nextInt();
-
- if(num < 1 || num > 10){
- System.out.println("The input must be between 1 - 10");
- }else{
- switch(num){
- case 1:
- System.out.println("I");
- break;
- case 2:
- System.out.println("II");
- break;
- case 3:
- System.out.println("III");
- break;
- case 4:
- System.out.println("IV");
- break;
- case 5:
- System.out.println("V");
- break;
- case 6:
- System.out.println("VI");
- break;
- case 7:
- System.out.println("VII");
- break;
- case 8:
- System.out.println("VIII");
- break;
- case 9:
- System.out.println("IX");
- break;
- case 10:
- System.out.println("X");
- break;
- }
- }
- }
- }
Explanation:
The first part of this program (Line 6 - 8) is to get input number from user using Scanner object. Input validation has been done to check if the input number is in the acceptable range (Line 10). If not, an error message will be displayed (Line 11).
If the input number is in the range of 1 - 10, the number will go through a series of switch statements checking. If the number meet the condition in one of the switch cases, it will print the corresponding roman numeral specified in the case block (Line 13 - 44). For example, if input number is 9, the case 9 condition is met and "IX" will be printed.
Answer:
Change the screen resolution to the native resolution of the monitor
Explanation:
Every monitor has a native resolution that shows pixels and colors best. Modern monitors are usually 1920x1080 or higher. If the resolution given to the monitor is not native to the monitor, then the pixels on the screen will appear pixelated or distorted.