본문 바로가기
728x90

비트 장기/JAVA33

7/12 복습 package practice1; import java.util.Scanner; public class practice1 { public static void main(String[] args) {System.out.println("비밀번호 4자리를 입력하시오"); int num=0;while(true) {int input = new Scanner(System.in).nextInt();if(input !=1234) {num++;if(num==3) {System.out.println("비밀번호 3회 오류");break;}System.out.println("비밀번호가 틀렸습니다.");continue;}else {System.out.println("게임을 실행합니다.");break;}} }} //switch .. 2018. 7. 13.
7/12 배움 (switch문,while문, ) switch문 //case 뒤에 변수가 들어갈수없다. 동일한 숫자를 중복해서 쓸수없다. break를 만나야 빠져나간다.//default 는 생략가능하지만 가급적 적어주자.default도 break와 한쌍이다.//case에서 실행할 문장이 한 줄 이상일 경우 스코프를 사용한다.//case와 브레이크 사이에는 한칸 띄워준다.//else if 문이 switch로 바꿀수만있다면 선택은 switch다. //else if 는 10,20,조건을 만족할떄까지 뒤져야되지만//switch는 한방에 바로간다. 효율이 좋다.//변경될수 있다고 판단되면 switch로 변경 대소는 안됨. //보통 안씀??//끝에는 : ; 구분떄문에 에러가많이뜬다. System.out.println("숫자를 입력하시오");int input = (.. 2018. 7. 12.
7/11 비트컴퓨터 자바 복습 과제 주사위 package practice1; import java.util.Random; public class practice1 { public static void main(String[] args) {int num = (new Random().nextInt(6));switch(num) {case 1:System.out.println("1나왔다.");break;case 2:System.out.println("2나왔다.");break;case 3:System.out.println("3나왔다.");break;case 4:System.out.println("4나왔다.");break;case 5:System.out.println("5나왔다.");break;default:System.out.println("6나왔.. 2018. 7. 11.
문제저장 1 5단을 출력하세요 문제 밑에다가 해답을 적으시오2 0부터100까지 더하는 합산 프로그램을 출력하세요 50503-1 0부터 100사이의 숫자중에서 랜덤한 숫자 하나를 출력하세요3-2 0부터 100사이의 숫자 10개를 출력하시오3-3 0부터 10사이의 숫자를 랜덤하게 5개 출력하고 그합까지 출력하시오4 0부터의 100사이의 숫자를 랜덤하게 10개 출력하고 출력된 숫자의 합까지 나타내는 프로그램ex) 38 3 + 8 = 115 컴퓨터에게 메모리를 요구할 수 있는 명령(type)을 모두 적으세요.6 대문자 A부터 대문자 Z까지 출력하시오.7 숫자하나를 입력받으세요.8-1 키보드로부터 입력된 숫자의 구구단8-2 키보드로부터 입력된 숫자의 합8-3 아스키코드를 입력하세요 0~1279 a와 b의 값을 교환하는 스.. 2018. 7. 11.