public static void main(String[] args) {
		for (int i = 2; i <= 9; i++) {
			//i는 앞의 숫자, j는 뒤의 숫자, i*j는 결과값
			for (int j = 1; j <= 9; j++) {
				System.out.printf("%dx%d=%d\t", i, j, i * j);
			}
			System.out.printf("\n");
		}
	}

 

'java > java exercise' 카테고리의 다른 글

It will thank you until you're satisfied.  (0) 2020.01.25
Calculate and display Student Grades  (0) 2020.01.25
Dice Game  (0) 2020.01.25
Changing Letter case  (0) 2020.01.25
Game 369  (0) 2020.01.25
public class DiceGame {
	public static void main(String[] args) {
		System.out.println("type number between 1 to 6");
		Scanner sc = new Scanner (System.in);
		int userNum = sc.nextInt();
		
		Random rd = new Random();
							//0~5까지 이지만 +1해서 6까지 나옴
		int num = rd.nextInt(6)+1;
		System.out.println(num);
		

		String result =
		userNum > num ? "user win" : 
		(userNum <num ? "ai win" : "Draw") ;
		System.out.println("user: " + userNum + " ai: "+ num);
		System.out.println(result);
		
		sc.close();
	}
}

'java > java exercise' 카테고리의 다른 글

Calculate and display Student Grades  (0) 2020.01.25
Print multiplication table  (0) 2020.01.25
Changing Letter case  (0) 2020.01.25
Game 369  (0) 2020.01.25
Count Number of Notes  (0) 2020.01.25

ex1

Scanner sc = new Scanner(System.in);
		System.out.println("Type One Alphabet");
		char a = sc.next().charAt(0);
		
		
		char result=
 		(a>=65 && a<=90) ? ((char)(a + 32)) : ((char)(a - 32));
			System.out.println(result);
		
		
	sc.close();

ex2

Scanner sc = new Scanner(System.in);
		System.out.println("Type One Alphabet");
		char a = sc.next().charAt(0);
		
		String result = 
		(a>=65 && a<=90) ?  "Upper Case" : "Lower Case";
		System.out.println(result);
		
	sc.close();

'java > java exercise' 카테고리의 다른 글

Calculate and display Student Grades  (0) 2020.01.25
Print multiplication table  (0) 2020.01.25
Dice Game  (0) 2020.01.25
Game 369  (0) 2020.01.25
Count Number of Notes  (0) 2020.01.25

 

Scanner sc = new Scanner(System.in);
		System.out.println("1부터 99중에서 하나의 수를 입력해주세요");
		int num = sc.nextInt();

		
			int tenth = num / 10;
			int first = num - (tenth * 10);
			
			/*num    6    13   69
			  tenth  0    1    6
			  		  ㄴ0.6 / 1.3 / 6.9 이지만 실수만 표시
			  first  6    3    9
			*/

			
			
			if (num < 10) {
				if (first % 3 == 0)//나누기 3했을떄 남는 수가 0과 같다
					System.out.println("박수짝");
			}

			else if (num > 10) {
				if (tenth % 3 == 0) {
					if (first % 3 != 0)
						System.out.println("박수짝");
					if (first % 3 == 0)
						System.out.println("박수짝짝");
				}

				else if (first % 3 == 0)
					System.out.println("박수짝");
			}

			sc.close();

'java > java exercise' 카테고리의 다른 글

Calculate and display Student Grades  (0) 2020.01.25
Print multiplication table  (0) 2020.01.25
Dice Game  (0) 2020.01.25
Changing Letter case  (0) 2020.01.25
Count Number of Notes  (0) 2020.01.25

 

	System.out.println("금액을 입력해주세요.");
		Scanner sc =  new Scanner (System.in);
		int money=sc.nextInt();
		
		int a = money/50000;//몫이 a 오만원권 장수가 됨. 
		money = money%50000;//<- 오만원권을 뺸 나머지 머니
		System.out.println("오만원권 " + a + "매");
		
		int b = money/10000;//<-위에서 내려온 나머지머니를 나눠서 몫이 b 만원권 장수가 됨.
		money = money%10000;
		System.out.println("만원권 " + b + "매");
		
		int c = money/5000;
		money = money%5000;
		System.out.println("오천원권 " + c +"매");
		
		int d = money/1000;
		money = money%1000;
		System.out.println("천원권 " + d +"매");
		
		int e = money/500;
		money = money%500;
		System.out.println("오백원 " + e +"개");
		
		int f = money/100;
		money = money%100;
		System.out.println("백원 " + f +"개");
		
		int g = money/50;
		money = money%50;
		System.out.println("오십원 " + g + "개");
		
		int h = money/10;
		money = money%10;
		System.out.println("십원 " + h + "개");
		
		
		sc.close();

'java > java exercise' 카테고리의 다른 글

Calculate and display Student Grades  (0) 2020.01.25
Print multiplication table  (0) 2020.01.25
Dice Game  (0) 2020.01.25
Changing Letter case  (0) 2020.01.25
Game 369  (0) 2020.01.25