본문 바로가기

프로그래밍/자바

[자바] 정올 129 : 반복제어문1 - 형성평가5

728x90
반응형
SMALL
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int base, height;
        char contin = 'y';
        while(contin == 'y' || contin == 'Y'){
            System.out.print("Base = ");
            base = sc.nextInt();
            System.out.print("Height = ");
            height = sc.nextInt();
            System.out.printf("Triangle width = %.1f\n", (double)(base*height)/2);
            sc.nextLine();
            System.out.print("Continue? ");
            contin = sc.next().charAt(0);
        }
    }
}
728x90
반응형
LIST