ITGenerations
자바과제 본문
2018. 05.02 까지 프린트 후 제출.
과제1.
import java.util.Scanner;
/*
과제1.별찍기
*/
public class Homework_01 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("별찍기 몇단?");
int num = sc.nextInt();
int i,j;
for(i=0; i<num;i++){
for(j=i; j>=0; j--){
System.out.print("*");
}
System.out.println();
}
}
}
과제2.
import java.util.Scanner;
public class Homework_02 {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("입장료: 님몇 살?");
int age=sc.nextInt();
if(age>=65){
System.out.println("10,000won");
}else if(age>=13){
System.out.println("20,000won");
}else if(age>=6){
System.out.println("8,000won");
}else{
System.out.println("5,000won");
}
}
}
과제3.
import java.util.Scanner;
public class Homework_03 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int tot=0;
do{
int pay =sc.nextInt();
tot+=pay;
}while(tot<=100000);
if(tot>100000)
System.out.println("100,000 초과 "+tot);
sc.close();
}
}
과제4.
import java.util.Scanner;
public class Homework_04 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("영어 대소문자 입력후 변환");
String ch = sc.nextLine();
for(int i=0; i<ch.length();i++){
char cha=ch.charAt(i);
if(cha>='a' && cha<='z'){
cha=(char)(cha-32);
System.out.println(cha);
} else if(cha>='A' && cha<='Z'){
cha=(char)(cha+32);
System.out.println(cha);
}
}
}
}
'자바공부 > 자바' 카테고리의 다른 글
프론트엔드/백엔드 공부 과정 간략화 (0) | 2018.05.10 |
---|---|
객체 공부 (0) | 2018.05.05 |
자바 개발자 면접시 키워드 (0) | 2018.05.01 |
String 메소드 (0) | 2018.04.28 |
배열 메소드 (0) | 2018.04.27 |