// 초기화를 따로 빼본적이 없어서 처음앎
int i = 1;
for(; i<=100; i++) {
}
for(int i = 0, j = 100; i <= 50 && j >= 50; i++, j--) {
}
Label: for() {
for() {
break Label;
}
}
public class chap4 {
public static void main(String[] args) {
while(true) {
int dice1 = (int)(Math.random() * 6) + 1;
int dice2 = (int)(Math.random() * 6) + 1;
System.out.println(dice1 + ", " + dice2);
if (dice1 + dice2 == 5) {
break;
}
}
}
}
public class chap4 {
public static void main(String[] args) {
for(int x = 1; x <= 10; x++) {
for(int y = 1; y <= 10; y++){
if(4 * x + 5 * y == 60) {
System.out.println(x + ", " + y);
}
}
}
}
}
public class chap4 {
public static void main(String[] args) {
for (int i = 1; i < 5; i++) {
for (int j = 4; j > 0; j--) {
if (i < j) {
System.out.print(" ");
} else {
System.out.print("*");
}
}
System.out.println("");
}
}
}
//책에서는 nextLine()을 사용하라 했지만 간단한 코드를 위해 nextInt()를 사용했다.
import java.util.Scanner;
public class chap4 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean run = true;
int balance = 0;
while (run) {
System.out.println("1. 예금, 2. 출금, 3. 잔고, 4. 종료");
System.out.print("선택 > ");
int str = sc.nextInt();
switch (str) {
case 1:
System.out.print("예금액 > ");
balance += sc.nextInt();
break;
case 2:
System.out.print("출금액 > ");
balance -= sc.nextInt();
break;
case 3:
System.out.println("잔고 > " + balance);
break;
case 4:
run = false;
break;
}
}
System.out.println("프로그램 종료");
}
}
항해99 Pre-Onboarding 4일차!
오늘 스터디 시간에는 혼공자 책으로 4챕터 조건문과 반복문을 배웠다! 오랜만에 별찍기를 시도해봤는데 헷갈려서 당황했답ㅋㅋㅋ 확실히 자바가 파이썬보다는 신경쓸게 많아보이지만 직관적이여서 덜 헷갈린다고 생각한다. 빨리 본과정에 들어가서 더 자바에 익숙해지고 싶다~.~ 💪