MapleStory Finger Point Cute Line Smiley Blinking Hello Kitty Angel MapleStory Finger Point

๐Ÿ’Ž JAVA/๐Ÿ“š๋ช…ํ’ˆ JAVA_ESSENTIAL

หšโ‚Šโœฉโ€งโ‚Š [ๅฎŒ][๋ช…ํ’ˆ JAVA ESSENTIAL] CH3 ์‹ค์Šต๋ฌธ์ œ หšโ‚Šโœฉโ€งโ‚Š

HYEJU01 2021. 9. 30. 00:08
"๊ฐœ์ •ํŒ: ๋ช…ํ’ˆ JAVAESSENTIAL(ํ™ฉ๊ธฐํƒœ)"๊ต์žฌ์— ์ˆ˜๋ก๋œ ๋ฌธ์ œ๋“ค์„ ํ’€์–ด์„œ ์˜ฌ๋ฆฝ๋‹ˆ๋‹ค.
๋ฌธ์ œ์˜ ๋ฒˆํ˜ธ๋งŒ ํ‘œ๊ธฐํ•˜๊ณ  ๋‹ต์•ˆ๋งŒ ์ ๋Š” ํ˜•ํƒœ๋กœ ์—…๋กœ๋“œ ํ•˜๊ณ ์žˆ์Šต๋‹ˆ๋‹ค.
๊ฐœ์ธ ํ’€์ด์ด๋ฏ€๋กœ ์˜ค๋‹ต์ด ์žˆ์„ ์ˆ˜ ์žˆ์œผ๋ฉฐ ์˜ค๋‹ต ๋ฐœ๊ฒฌ ์‹œ ๋Œ“๊ธ€ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค๐Ÿ˜Š
-
#์ด ํ‘œ์‹œ๋œ ๊ฑด ์•„์ง ํ’€์ง€ ๋ชปํ•œ ๋ฌธ์ œ or ํ—ท๊ฐˆ๋ฆฌ๋Š” ๋ฌธ์ œ์ž…๋‹ˆ๋‹ค!
์ถ”ํ›„์— ๋‹ค์‹œ ํ’€์–ด์„œ ์˜ฌ๋ฆด ์˜ˆ์ •์ด์—์š”!

-ujeyhx-

 

 

๐Ÿ”Ž์‹ค์Šต๋ฌธ์ œ

 

 

1)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		System.out.print("์•ŒํŒŒ๋ฒณ ํ•œ ๋ฌธ์ž๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” >>");
		String s = sc.next(); //๋ฌธ์ž์—ด๋กœ ์ฝ์Œ
		char c = s.charAt(0); // ๋ฌธ์ž์—ด์˜ ์ฒซ ๋ฒˆ์งธ ๋ฌธ์ž

		for (int i='a'; i<=c; i++) { // a๋ถ€ํ„ฐ c๊นŒ์ง€ ๊ฐ’ ์ฆ๊ฐ€
			for (int k=i; k<=c; k++) { // i๋ถ€ํ„ฐ c๊นŒ์ง€ 
				System.out.print((char)(k)); //์ถœ๋ ฅ i๊ฐ€ ์ฆ๊ฐ€ํ•˜๋ฏ€๋กœ ๋งˆ์ง€๋ง‰์œผ๋กœ c์ถœ๋ ฅ ํ›„ ๋งˆ๋ฌด๋ฆฌ
			}
			System.out.println();
		}
		sc.close();
		
	}
}

 


2)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int num[] = new int[10];
		System.out.print("์ •์ˆ˜ 10๊ฐœ ์ž…๋ ฅ >>");
		
		for (int i=0; i<num.length; i++) {
			num[i] = sc.nextInt();
		
		}
		
		for (int i=0; i<num.length; i++) {
			if (num[i] % 3 == 0 ) {
				System.out.print(num[i]+" ");
			}
			
		}
		
		sc.close();
	
	}

}

 

 


3)

import java.util.InputMismatchException;
import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		System.out.print("์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” >>");
		int num;
		
		try {
			num = sc.nextInt();
				
				if (num % 2 == 0) {
					System.out.print("์ง์ˆ˜");
				}
				else {
					System.out.print("ํ™€์ˆ˜");
				}
				
		}
		
		catch(InputMismatchException e) {
			System.out.println("์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์ง€ ์•Š์•„ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค.");
		}
		
		sc.close();
	
	}

}

 


4)

import java.util.InputMismatchException;
import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		char day[] = {'์ผ','์›”','ํ™”','์ˆ˜','๋ชฉ','๊ธˆ','ํ† '};//0~6
		int num,index=0;
		
		while (true) {
			System.out.print("์ •์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” >>");
		try {
		num = sc.nextInt();
		
		if (num < 0) {
			System.out.print("ํ”„๋กœ๊ทธ๋žจ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค...");
			break;
		}
		
		index = num%7;
		System.out.println(day[index]);		
		}
		
		catch(InputMismatchException e) {
			System.out.println("๊ฒฝ๊ณ ! ์ˆ˜๋ฅผ ์ž…๋ ฅํ•˜์ง€ ์•Š์•˜์Šต๋‹ˆ๋‹ค.");
			sc.nextLine();
		}
		
		}
		sc.close();
	
	}

}

 

 


# 5)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int array[] = new int[10]; //0~9
		int temp=0;
		System.out.print("์ •์ˆ˜ 10๊ฐœ ์ž…๋ ฅ>>");
		for (int i=0; i<array.length; i++) {
			array[i] = sc.nextInt();
		}
		
		for (int i=0; i<array.length; i++) {
			for(int j = 0; j < array.length-i-1; j++) {
				if(array[j] > array[j+1]) {
					temp = array[j];
					array[j] = array[j+1];
					array[j+1] = temp;
				}
			}
		}
		for (int i=0; i<array.length; i++) {
			System.out.print(array[i]+ " ");
		}
		sc.close();
	
	}

}

 


6)

import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String eng[] = {"student","love","java","happy","future"};
		String kor[] = {"ํ•™์ƒ","์‚ฌ๋ž‘","์ž๋ฐ”","ํ–‰๋ณตํ•œ","๋ฏธ๋ž˜"};
		String input;
		
		while (true) {
			System.out.print("์˜์–ด๋‹จ์–ด๋ฅผ ์ž…๋ ฅํ•˜์„ธ์š” >>");
			
				input = sc.nextLine();
				
				for (int i=0; i<eng.length; i++) {
					if (eng[i].equals(input)) {
						System.out.println(kor[i]);
						break;
					}
					else if(!eng[i].equals(input)&&i==eng.length-1) {
						System.out.println("๊ทธ๋Ÿฐ ์˜์–ด๋‹จ์–ด ์—†์–ด์œ ");
						break;
					}
				}
									
				if(input.equals("exit")) {
					System.out.print("์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค...");
					break;
					}

		}
		
		sc.close();
		
	}
}

 


7)


public class TEST {
	public static void main(String[] args) {
	
	int i;
	for (i=1; i<100; i++) {
		
		int first = i/10;
		int second = i%10;
		int clap = 0;
		
		if (first != 0 && first % 3 == 0)
			clap =1;
		
		if (second != 0 && second % 3 == 0)
			clap =1;
		
		if (first == 3 && second  == 3)
			clap =2;
		

		if (clap == 1)
			System.out.println(i + " ๋ฐ•์ˆ˜ ํ•œ๋ฒˆ");
		else if (clap == 2)
			System.out.println(i + " ๋ฐ•์ˆ˜ ๋‘๋ฒˆ");
			
		}
	}
}

 


8)

import java.util.InputMismatchException;
import java.util.Scanner;

public class TEST {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String str[] = {"๊ฐ€์œ„","๋ฐ”์œ„","๋ณด"};

			while (true) {
				System.out.println("** ์ปดํ“จํ„ฐ์™€ ๊ฐ€์œ„ ๋ฐ”์œ„ ๋ณด ๊ฒŒ์ž„์„ ์‹œ์ž‘ํ• ๊ฒŒ์š” **");
				System.out.print("๊ฐ€์œ„ ๋ฐ”์œ„ ๋ณด !>>");
				String input = sc.nextLine();
				int n = (int)(Math.random()*3);
				
				
			
				
				if(input.equals("๊ทธ๋งŒ")) {
					System.out.print("๊ฒŒ์ž„์„ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค...");
					break;
					}
				
				System.out.print("์‚ฌ์šฉ์ž=>" + input);
				System.out.print(" ์ปดํ“จํ„ฐ=>" + str[n]);
	
				if(str[n].equals("๊ฐ€์œ„")) {
					if(input.equals("๊ฐ€์œ„"))
						System.out.println("/ ๋น„๊ฒผ์Šต๋‹ˆ๋‹ค");
					if(input.equals("๋ฐ”์œ„"))
						System.out.println("/ ์‚ฌ์šฉ์ž๊ฐ€ ์ด๊ฒผ์Šต๋‹ˆ๋‹ค");
					if(input.equals("๋ณด"))
						System.out.println("/ ์ปดํ“จํ„ฐ๊ฐ€ ์ด๊ฒผ์Šต๋‹ˆ๋‹ค");
				}
				if(str[n].equals("๋ฐ”์œ„")) {
					if(input.equals("๊ฐ€์œ„"))
						System.out.println("/ ์ปดํ“จํ„ฐ๊ฐ€ ์ด๊ฒผ์Šต๋‹ˆ๋‹ค");
					if(input.equals("๋ฐ”์œ„"))
						System.out.println("/ ๋น„๊ฒผ์Šต๋‹ˆ๋‹ค");
					if(input.equals("๋ณด"))
						System.out.println("/ ์‚ฌ์šฉ์ž๊ฐ€ ์ด๊ฒผ์Šต๋‹ˆ๋‹ค");
				}
				if(str[n].equals("๋ณด")) {
					if(input.equals("๊ฐ€์œ„"))
						System.out.println("/ ์‚ฌ์šฉ์ž๊ฐ€ ์ด๊ฒผ์Šต๋‹ˆ๋‹ค");
					if(input.equals("๋ฐ”์œ„"))
						System.out.println("/ ์ปดํ“จํ„ฐ๊ฐ€ ์ด๊ฒผ์Šต๋‹ˆ๋‹ค");
					if(input.equals("๋ณด"))
						System.out.println("/ ๋น„๊ฒผ์Šต๋‹ˆ๋‹ค");
				}
	
		}
		
		sc.close();
		
	}
}

 

 


Bonus 1)

public class TEST {

	public static void main(String[] args) {
		
		int intArray[][];
		intArray = new int[3][4];

		
		for(int i=0; i<3; i++) {
			for(int j=0; j<4; j++) {
				intArray[i][j] = (int)(Math.random()*10);
			}
		}
	
		for(int i=0; i<intArray.length; i++) {
			for(int j=0; j<intArray[i].length; j++) {
				System.out.print(intArray[i][j]+ "    ");
			}
			System.out.println();
		}
			
		int i=0, sum=0;

			for(i=0; i<intArray.length; i++) { //3
				for(int j=0; j<intArray[i].length; j++) { //4
					sum += intArray[i][j];
				}
			}

		
		System.out.println("ํ•ฉ์€ " + sum);
		
	}
}