1. 별찍기

public class star{
	public static void main(String[] args){
    	int line = 6;
         for(int i=0; i<line; i++){
         	for (int j=0; j<i; j++){
            	System.out.print("");
            }
            for(int j=0; j<line-i; j++){
            	System.out.print("*");
            }
            System.out.println();
     }
     for(int i=0; i<line; i++){
     	for(int j=0; j<line; j++){
        	if(j<line-i-1)
            	System.out.print("");
            else
            	System.out.print("*");
         }
         System.out.println();
         
     }
   }
}

2. 구구단 출력

public class m1 {
	public static void main(String[] args) {
		for(int i=2; i<10; i=i+2) {
			for(int j=1; j<10; j++) {
				for(int k=i; k<i+2; k++) {
					System.out.print(k+"x"+j+"="+k*j+"\t");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}

 

3. 화폐단위 계산

public class cash2{
	public static void main(String[] args){
    	int chage = 100000;
        int money = 0;
        int i = 0;
        int total = 345780;
        
        while(true){
        	money = total / change;
            System.out.println(change + "원권 : " + money + "장");
            
            if(chage <= 10){
            	break;
            }
            total = total - change * money;
            
            if(i == 0){
            	change = change / 2;
                i = 1;
                
            }else{
            	change = change / 5;
                i = 0;
            }
        }
    }
}

'JAVA' 카테고리의 다른 글

반복문  (1) 2020.04.29
제어문(feat. 삼항연산자)  (1) 2020.04.28
메모리구조 용어정리  (1) 2020.04.28
연산자 사용 및 프레임워크, tools, IDE 의 차이점  (1) 2020.04.28
빌드(Build)  (1) 2020.04.28

+ Recent posts