1.
import java.util.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int com, eng, math, java;
Scanner input = new Scanner(System.in);
System.out.print("점수 : ");
com = input.nextInt();
eng = input.nextInt();
math = input.nextInt();
java = input.nextInt();
int sum = com + eng + math + java;
double avg = (double)sum / 4;
System.out.println("총점 : " + sum);
System.out.println("평균 : " + avg);
}
}
2.
import java.util.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print("정수값 : ");
int num = input.nextInt();
System.out.println("제곱 : " + (num * num));
System.out.println("세제곱 : " + (num * num * num));
}
}
3.
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int pay = 10000;
int price = 3500;
int extra = (int)(price * 0.1);
int cnt = 2;
int total = (price + extra) * 2;
System.out.println("지불한 돈 : " + pay);
System.out.println("까페 모카 단가 : " + price);
System.out.println("수량 : " + cnt);
System.out.println("부가세 : " + extra);
System.out.println("상품 총액 : " + total);
System.out.println("거스름돈 : " + (pay - total));
}
}
4.
import java.util.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print("정수값 : ");
int num = input.nextInt();
System.out.println("천의 자리 : " + (num / 1000));
num %= 1000;
System.out.println("백의 자리 : " + (num / 100));
num %= 100;
System.out.println("십의 자리 : " + (num / 10));
num %= 10;
System.out.println("일의 자리 : " + num);
}
}
5.
import java.util.*;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print("시간(초) : ");
int sec = input.nextInt();
int total = sec;
int hour = sec / 3600;
sec %= 3600;
int min = sec / 60;
sec %= 60;
System.out.println(total + "초는 " + hour + "시간 " + min + "분 " + sec + "초이다.");
}
}
6.
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("\'A\'+1\t\'A\'+2\t\'A\'+3");
System.out.println("---------------------------------------");
System.out.println((char)('A'+1) + "\t" + (char)('A'+2) + "\t" + (char)('A'+3));
}
}
7.
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double r = 5.0;
double v = 3.14 * r * r;
System.out.println("반지름 : " + r);
System.out.println("부피 : " + v);
}
}
8.
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double cm = 162.56;
double inch = cm / 2.54;
double pit = inch / 12;
inch %= 12;
System.out.println(cm + "cm는 " + (int)pit + "피트 " + (int)inch + "인치이다.");
}
}
9.
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
double pit = 5;
double inch = 4;
double tinch = pit * 12 + 4;
double cm = tinch * 2.54;
System.out.println((int)pit + "피트 " + (int)inch + "인치는 "+ cm +"cm");
}
}