일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 자바연산
- 맥 sql설치
- java
- 맥북 데이터베이스 설치
- 자바 공부
- 맥 데이터베이스
- 자바복습
- 맥os 데이터베이스
- 자바연산자사용
- Mac Sqlplus
- 자바거스름돈
- 맥북 개발
- 자바 커피
- 자바 복습
- 맥북 데이터베이스
- 자바공부
- mac oracle
- Mac db
- 자바변수
- java거스름돈구하기
- javareview
- 자바실수
- 자바계산
- 자바 거스름돈구하기
- 맥 오라클
- 자바
- 자바연산자
- Today
- Total
목록Java (11)
DevTagebuch

키보드로 원하는 커피의 값과 투입하려는 금액을 입력하고 거스름돈 구하기. import java.util.Scanner; public class Problem04_03 { public static void main(String[] args) { Scanner s=new Scanner(System.in); int coffee, money, change; System.out.print("얼마짜리 커피를 드시겠어요? ==>"); coffee=s.nextInt(); System.out.print("금액을 투입해주세요. ==>"); money=s.nextInt(); change=money-coffee; System.out.printf("거스름 돈은 %d원 입니다.",change); int c500,c100,c50;..

방법 1 Scanner에 입력한 값을 500, 100, 50, 10 원짜리로 어떻게 바꿀 수 있는지 계산. import java.util.Scanner; public class Problem04_02 { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.print("## 교환할 돈은?"); int money=s.nextInt(); int c500, c100, c50, c10; c500=money/500; System.out.printf("500원짜리 ==> %d개\n",c500); money=money%500; //1380을 500으로 나눴을때 나머지 값은 380. c100=money/100; //38..

import java.util.Scanner; public class Problem04_01 { public static void main(String[] args) { Scanner s=new Scanner (System.in); System.out.print("첫번째 계산할 값을 입력하세요 ==>"); double a=s.nextDouble(); //실수니까 double 변수 사용 System.out.print("두번째 계산할 값을 입력하세요 ==>"); double b=s.nextDouble(); System.out.printf("%.2f + %.2f = %.2f\n",a,b,a+b); //.2는 소수점 2번째 자리까지만 나타냄을 의미 System.out.printf("%.2f - %.2f = %...

기본 연산자 = 대입 + 더하기 - 빼기 * 곱하기 / 나누기 % 나머지 값 대입 연산자 (기본연산자 먼저 쓰고 = 작성) += a+=3 ==> a=a+3 -= a-=3 ==> a=a-3 *= a*=3 ==> a=a*3 /= a/=3 ==> a=a/3 %= a%=3 ==> a=a%3 증감 연산자 ++ a++ / ++a ==> a=a+1 (a+=1) -- a-- / --a ==> a=a-1 (a-=1) ※ a++ 와 ++a 의 차이점 a++ (후치 증가연산자) : a가 있고, a값을 1 증가시킴 ++a (전치 증가연산자) : a값을 1증가 시키고, a가 있음 관계 연산자 : 두 값을 비교하는 관계 연산자는 항상 결과는 참 혹은 거짓으로 표현. == 같다 != 같지 않다 크다 = 크거나 같다 논..
public static void main(String[] args) { Scanner s=new Scanner(System.in); int i; System.out.print("Input Words"); String str=s.nextLine(); for(i=str.length()-1;i>=0;i--) { System.out.printf("%c",str.charAt(i)); } } 입력된 문자열을 받기 위해 String 타입 변수 선언 필요. 출력은 맨 뒤에서 부터 하는 것이기 때문에 for문의 시작점은 입력한 문자의 맨 마지막 글자. .length() 는 입력된 문자열의 길이를 구하는 메소드. .charAt(i) 는 입력된 문자열에서 i번째에 있는 문자를 구하는 메소드. 자바에서 문자열이 입력되면 1..