반응형
package com.company;
public class Main {
public static void main(String[] args) {
int result = 4 % 3; // the remainder of (4%3) = 1
//result = result + 1;
result++; // 1+1 = 2
System.out.println("1+1 = " + result);
// result= result -1
result--; // 2-1 = 1
System.out.println("2-1=" + result);
// result= result + 2
result += 2; // 1+2 = 3
System.out.println("1+2=" + result);
//result= result * 10
result *= 10; // 3 *10 =30
System.out.println("3 * 10 =" + result);
//result = result / 3
result /= 3; // 30 / 3 = 10
System.out.println("30 / 3 = " + result);
//result = result - 2
result -= 2; // 10-8=2
System.out.println("10-8 = " + result);
boolean isAlien = false;
if (isAlien == false) {
System.out.println("It is not an alien!");
System.out.println("And I am scared of aliens");
}
int topScore = 80;
if (topScore == 80) {
System.out.println("You got the high score");
}
int topcore = 80;
if (topcore != 100) {
System.out.println("You got the high score");
}
int topore = 80;
if (topore <= 100) {
System.out.println("You got the high score");
}
int tope = 100;
if (tope == 100) {
System.out.println("You got the high score");
}
int topre = 80;
if (topre > 100) {
System.out.println("You got the high score");
}
int secondTopscore = 60;
if((topScore > secondTopscore) && (topScore <100) ){
System.out.println("Greater than scond top score and less than 100");
}
if( (topScore > 90) || (secondTopscore <= 90) ) {
System.out.println("Either or both of the conditions are ture");
}
int newvalue = 50;
if(newvalue ==50){
System.out.println("This is an true");
}
boolean isCar = false;
if(!isCar){ //isCar가 아니라면 Not operator(!)
System.out.println("isCar is flase");
}
int ageOfClient = 20;
boolean isEightOrOver = (ageOfClient == 20) ? true : false ;
if(isEightOrOver){
System.out.println("isEightOrOver is true");
};
isCar = true;
boolean wasCar = isCar ? true : false;
if(wasCar){
System.out.println("wasCar is true");
}
//Challenge
double myDouble = 20.00d;
double secondDouble = 80.00d;
double result1 = (myDouble + secondDouble) * 100.00d ;
System.out.println("result1 = "+ result1);
double remainder = result1 % 40;
System.out.println("remainder = "+ remainder);
boolean result3 = (remainder == 0) ? true : false ;
System.out.println("result3=" + result3);
if(!result3) { //result3가 ture가 아니면
System.out.println("Got some remainder");
}
}
}
Output
D:\IT\JDK\jdk11.0.6_10\bin\java.exe "-javaagent:D:\IT\IDEA\IntelliJ IDEA Community Edition 2020.1\lib\idea_rt.jar=51414:D:\IT\IDEA\IntelliJ IDEA Community Edition 2020.1\bin" -Dfile.encoding=UTF-8 -classpath D:\IT\NewProject\project\Operators\out\production\Operators com.company.Main
1+1 = 2
2-1=1
1+2=3
3 * 10 =30
30 / 3 = 10
10-8 = 8
It is not an alien!
And I am scared of aliens
You got the high score
You got the high score
You got the high score
You got the high score
Greater than scond top score and less than 100
Either or both of the conditions are ture
This is an true
isCar is flase
isEightOrOver is true
wasCar is true
result1 = 10000.0
remainder = 0.0
result3=true
Process finished with exit code 0
'JavaCode(review)' 카테고리의 다른 글
Generics Challenge - 기본예제에 league 추가 (0) | 2020.06.24 |
---|---|
Naming convention (0) | 2020.06.24 |
FloatingPointNumbers/Double (0) | 2020.06.23 |
CharAndBoolean (0) | 2020.06.23 |
ByteShortIntLong Max/Min (0) | 2020.06.23 |