import java.util.*; //This is used to import the Scanner
class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
Scanner ValCents = new Scanner (System.in);
System.out.println("Enter Number:");
int user_input = ValCents.nextInt();
int result = user_input/100; // This one will solve for the one dollar bills.
int remain = user_input % 100; // This one will get the remainder of cents.
System.out.println(result + " One Dollar Bills");
System.out.println(remain + " Cents");
}
}
Remember that you need to get the amount of dollar bills separately from the number of cents. This is because the int variable will always return the whole value of the number. The modulo is used to get the variable of the cents as the whole number is already taken by the "result".
Answer:
public class SwitchCase {
public static void main(String[] args) {
int num = 0;
int a = 10, b = 20, c = 20, d = 30, x = 40;
switch (num){
case 102: a += 1;
case 103: a += 1;
case 104: a += 1;
case 105: a += 1;
break;
case 208: b += 1; x = 8;
break;
case 209: c = c * 3;
case 210: c = c * 3;
break;
default: d += 1004;
}
}
}
Explanation:
- Given above is the equivalent code using Switch case in Java
- The switch case test multiple levels of conditions and can easily replace the uses of several if....elseif.....else statements.
- When using a switch, each condition is treated as a separate case followed by a full colon and the the statement to execute if the case is true.
- The default statement handles the final else when all the other coditions are false
The answer would be A because grit means to fight hard to get what you want. Submission would be to give in to pressure and give up. Self-importance would be to only focus on yourself and no one else. A short attention span would not work out for you because you get distracted easily.
Answer:
Option 3 is the correct answer.
Explanation:
- In c, c++ or Java programming language, The for loop takes three parameters in which first is an initialization, second is condition check and the third is an increment. None of the other loop (except for loop) takes three parameters. The other loop takes only one parameter and that is the condition check.
- So when a user knows about the times of iteration then it is a good choice to use the for loop but when the person does not know about the times of iteration if the loop. It means the iteration of the loop is based on the condition then it is a good choice to chose while or Do-while loop.
- The above question wants to ask which loop for a user can best if he familiar with the iteration of the loop then the answer is for loop which is started from option 3. Hence Option 3 is the correct answer while the other is not because--
- Option 1 states about the do-while loop which takes condition only.
- Option 2 states about the while loop which also takes condition only.
- Option 4 states about the infinite loop which is not any loop.
- Option 5 states about none of these which is not correct because option 3 is the correct answer.