07) 와일문 while

hahahoho셍·2021년 4월 24일
0

자바 공부

목록 보기
7/97
package java01;

import java.util.Scanner;

public class J20210414_02_while {

	public static void main(String[] args) {
		//반복문 while
		//원의 넓이를 구하기
		//0을 입력하면 종료
//		Scanner sc = new Scanner(System.in);
//		double r; //반지름
//		while(true) {
//			System.out.print("반지름은?");
//			r = sc.nextDouble();
//			double a = r*r*3.12;
//			if(r==0) {
//				System.out.println("종료"); break; }
//			System.out.println("넓이는 : "+a);
//		}
		
		//2안)
//		Scanner sc = new Scanner(System.in);
//		double r=1; //반지름
//		while(r!=0) {
//			System.out.print("반지름은?");
//			r = sc.nextDouble();
//			double a = r*r*3.12;
//			System.out.println("넓이는 : "+a);
//		}
		
		//3안
//		Scanner sc = new Scanner(System.in);
//		double r; //반지름
//		do {
//			System.out.print("반지름은?");
//			r = sc.nextDouble();
//			double a = r*r*3.12;
//			System.out.println("넓이는 : "+a);
//		}while(r!=0);
		
		
		
		//실습) 1에서 n까지의 수를 더하라
//		Scanner sc = new Scanner(System.in);
//		System.out.print("수는?");
//		int r = sc.nextInt();
//		int a = 0 , s = 0;
//		while(true) {
//			a++;
//			if (a>r) break;
//			s += a;
//		}
//		System.out.println(s);
		
		

		

	}

}
profile
그냥 공부 한거 적는 벨로그 하하하핳ㅎ하하하핳하ㅏ

0개의 댓글

관련 채용 정보