Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Tags
- 알고리즘
- #완전수구하기
- #이차원배열
- switch문
- for문 369게임
- #Java
- 증감연산자
- else if문
- plusgame
- switch-case문
- 소인수분해
- 별찍기
- 로또 프로그램
- 삼항 연산자
- java
- 논리연산자
- 비교연산자
- if문
- java조건문
- 이진수
- #알고리즘
- 데이터타입
- 피보나치수열
- 2차원배열
- 변수의특징
- 팩토리얼
- 연산자
- #java_festival
- JAVA기초
- 복합대입연산자
Archives
- Today
- Total
숭어 개발 블로그
[JAVA]do-while문 본문
do-while : 무조건 한번은 실행하고 반복조건을 살펴본다
do-while문 구조
do{ 반복 조건식
}while( t/f );
- while 선조건 반복
- do-while 선실행 후조건
import java.util.Scanner;
public class Exam03 {
public static void main(String[] args) {
String id = "admin";
String pw = "1234";
String input1 = "";
String input2 = "";
Scanner sc = new Scanner(System.in);
do {
System.out.print("아이디를 입력해주세요 >>");
input1 = sc.next();
System.out.print("비밀번호를 입력해주세요 >>");
input2 = sc.next();
if(input1.equals(id) && input2.equals(pw)) {
System.out.println("로그인 성공!");
break;
}else{
System.out.println("아이디와 비밀번호가 잘못되었습니다.");
}
}while(!(input1.equals(id) && input2.equals(pw)));
sc.close();
// System.out.println("로그인 성공!");
//
}//
}//
'JAVA > 반복문' 카테고리의 다른 글
[JAVA] for문 예제_(별찍기) (0) | 2022.09.19 |
---|---|
[JAVA] for문 예제_( 구구단 ) (0) | 2022.09.19 |
[JAVA] for문 예제_ ( 369게임) (0) | 2022.09.19 |
[JAVA] 반복문_( for 문 ) (0) | 2022.09.19 |
[JAVA] 반복문_( while 문 ) (0) | 2022.09.19 |
Comments