1066 정수 3개 입력받아 짝수만 출력하기
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
if(a % 2 == 0){
System.out.println(a);
}
if(b % 2 == 0){
System.out.println(b);
}
if(c % 2 == 0){
System.out.println(c);
}
}
}
1066 정수 3개 입력받아 짝/홀 출력하기
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
if(a % 2 == 0){
System.out.println("even");
}
else {
System.out.println("odd");
}
if(b % 2 == 0){
System.out.println("even");
}
else {
System.out.println("odd");
}
if(c % 2 == 0){
System.out.println("even");
}
else {
System.out.println("odd");
}
}
}
정수 1개 입력받아 분석하기
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if(a < 0){
System.out.println("minus");
if(a % 2 == 0){
System.out.println("even");
}
else {
System.out.println("odd");
}
}
if(a > 0){
System.out.println("plus");
if(a % 2 == 0){
System.out.println("even");
}
else {
System.out.println("odd");
}
}
}
}
정수 1개 입력받아 평가 출력하기
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int score = scan.nextInt();
if(score >= 90){
System.out.println("A");
}
else if(score >= 70){
System.out.println("B");
}
else if(score >= 40){
System.out.println("C");
}
else {
System.out.println("D");
}
}
}
평가 입력받아 다르게 출력하기
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String a = scan.next();
if(a.equals("A")){
System.out.println("best!!!");
}
else if(a.equals("B")){
System.out.println("good!!");
}
else if(a.equals("C")){
System.out.println("run!");
}
else if(a.equals("D")){
System.out.println("slowly~");
}
else {
System.out.println("what?");
}
}
}
월 입력받아 계절 출력하기
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if(a == 12 || a == 1 || a == 2){
System.out.println("winter");
}
else if(a == 3 || a == 4 || a == 5){
System.out.println("spring");
}
else if(a == 6 || a == 7 || a == 8){
System.out.println("summer");
}
else if(a == 9 || a == 10 || a == 12){
System.out.println("fall");
}
}
}
1151 : 10보다 작은 수
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if(a < 10){
System.out.println("small");
}
}
}
1152 : 10보다 작은 수 (else 버전)
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if(a < 10){
System.out.println("small");
}
else {
System.out.println("big");
}
}
}
1153 : 두 수의 대소 비교
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
if(a > b){
System.out.println(">");
}
else if(a < b){
System.out.println("<");
}
else {
System.out.println("=");
}
}
}
1154 : 큰수 - 작은수
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
if(a > b){
System.out.println(a - b);
}
else {
System.out.println(b - a);
}
}
}
1155 : 7의 배수해결
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if((a%7) == 0){
System.out.println("multiple");
}
else{
System.out.println("not multiple");
}
}
}
1156 : 홀수 짝수 구별
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if((a%2) == 0){
System.out.println("even");
}
else {
System.out.println("odd");
}
}
}
1157 : 특별한 공 던지기 1
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double a = scan.nextDouble();
if(a > 50 && a < 60) {
System.out.println("win");
}
else {
System.out.println("lose");
}
}
}
1158 : 특별한 공 던지기 2
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if(a >= 60 && a <= 70) {
System.out.println("win");
}
else if(a >= 30 && a <= 40) {
System.out.println("win");
}
else {
System.out.println("lose");
}
}
}
1159 : 특별한 공 던지기 3
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if(a >= 50 && a <= 70) {
System.out.println("win");
}
else if((a%6) == 0) {
System.out.println("win");
}
else {
System.out.println("lose");
}
}
}
1160 : 아르바이트 가는 날
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
if((a%2) == 0){
System.out.println("enjoy");
}
else{
System.out.println("oh my god");
}
}
}
1161 : 홀수와 짝수 그리고 더하기
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int a = scan.nextInt();
int b = scan.nextInt();
if((a%2) != 0){
System.out.printf("홀수+");
if((b%2) != 0){
System.out.printf("홀수=짝수");
}
else if((b%2) == 0){
System.out.printf("짝수=홀수");
}
}
else if((a%2) == 0){
System.out.printf("짝수+");
if((b%2) != 0){
System.out.printf("홀수=홀수");
}
if((b%2) == 0){
System.out.printf("짝수=짝수");
}
}
}
}
1162 : 당신의 사주를 봐 드립니다 1
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
System.out.print((a-b+c)%10==0?"대박":"그럭저럭");
}
}
1164 : 터널 통과하기 1
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int i = 170;
int a = scan.nextInt();
int b = scan.nextInt();
int c = scan.nextInt();
if(a <= i){
System.out.println("CRASH");
}
else if(b <= i){
System.out.println("CRASH");
}
else if(c <= i){
System.out.println("CRASH");
}
else{
System.out.println("PASS");
}
}
}