1.
import java.util.*;
public class Test
{
public static void main(String[] args){
int x, y, z, min;
Scanner scan = new Scanner(System.in);
System.out.print("정수를 입력하세요");
x = scan.nextInt();
System.out.print("정수를 입력하세요");
y = scan.nextInt();
System.out.print("정수를 입력하세요");
z = scan.nextInt();
if( x < y ){
if( x < z ){
if( y < z )
System.out.println(x+" "+y+" "+z);
else
System.out.println(x+" "+z+" "+y);
}
else {
if( y < x )
System.out.println(z+" "+y+" "+x);
else
System.out.println(z+" "+x+" "+y);
}
}
else {
if( y < z ){
if( x < z )
System.out.println(y+" "+x+" "+z);
else
System.out.println(y+" "+z+" "+x);
}
else {
if( y < x )
System.out.println(z+" "+y+" "+x);
else
System.out.println(z+" "+x+" "+y);
}
}
}
}
2.
import java.util.*;
public class Test
{
public static void main(String[] args){
String s;
Scanner scan = new Scanner(System.in);
System.out.print("문자를 입력하세요");
s = scan.next();
char c = s.charAt(0);
switch(c){
case 'a':
case 'i':
case 'o':
case 'u':
case 'e':
System.out.println("모음입니다.");
break;
default:
System.out.println("자음입니다.");
}
}
}
3.
import java.util.*;
public class Weight {
public static void main(String[] args){
double weight, stWeight, height;
Scanner scan = new Scanner(System.in);
System.out.println("키를 입력하세요");
height = scan.nextDouble();
System.out.println("몸무게를 입력하세요");
weight = scan.nextDouble();
stWeight = (height-100) * 0.9;
if(weight < stWeight)
System.out.println("저체중입니다.");
else if(weight == stWeight)
System.out.println("표준입니다.");
else
System.out.println("과체중입니다.");
}
}
4.
import java.util.*;
public class Test
{
public static void main(String[] args){
int x, y, z, min;
Scanner scan = new Scanner(System.in);
System.out.print("정수를 입력하세요");
x = scan.nextInt();
System.out.print("정수를 입력하세요");
y = scan.nextInt();
System.out.print("정수를 입력하세요");
z = scan.nextInt();
if( x < y ){
if( z < x )
min = z;
else
min = x;
}
else {
if( z < y )
min = z;
else
min = y;
}
System.out.printf("제일 작은 정수는 %d입니다. \n", min);
}
}
5.
import java.util.*;
public class Function {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
double x;
x = scan.nextDouble();
if(x <= 0)
System.out.println("함수값은 " + ((x*x*x) - (9*x) + 2) + "입니다.");
else
System.out.println("함수값은 " + ((7*x) + 2) + "입니다.");
}
}
6.
public class PrimeNumber {
public static void main(String[] args){
int count2 = 0;
System.out.print("2부터 100사이 모든 소수 : ");
for(int i = 2; i <= 100; i++){
count2 = 0;
for(int k = 2; k < i; k++){
if((i%k) == 0){
count2++;
break;
}
}
if(count2 == 0)
System.out.print(" " + i);
}
}
}
7.
import java.util.*;
public class Test
{
public static void main(String[] args){
int a, b, c;
for(a=1; a<=100; a++)
{
for(b=1; b<=100; b++)
{
for(c=1; c<=100; c++)
{
if( (a*a+b*b)==c*c )
System.out.printf("%d %d %d\n", a, b, c);
}
}
}
}
}
8.
import java.util.*;
public class Test
{
public static void main(String[] args){
int a, b;
for(a=1; a<=10; a++)
{
for(b=1; b<=10; b++)
{
System.out.printf("%d ", a*b);
}
System.out.println("");
}
}
}
9.
import java.util.*;
public class Cal {
public static void main(String[] args){
String a;
double num1, num2;
Scanner s = new Scanner(System.in);
System.out.println("문자를 입력하세요:");
a = s.nextLine();
System.out.println("숫자 2개를입력하세요:");
num1 = s.nextDouble();
num2 = s.nextDouble();
if(a.equals("+")){
System.out.println(num1 + "+" + num2 + " = "+(num1 + num2));
}
else if(a.equals("-")){
System.out.println(num1 + "-" + num2 + " = "+(num1 - num2));
}
else if(a.equals("*")){
System.out.println(num1+ "*" +num2 + " = "+(num1 * num2));
}
else{
if(num2 != 0)
System.out.println(num1 + "/" + num2 + " = "+(num1 / num2));
else
System.out.println("0으로 나눌수 없습니다.");
}
}
}
10.
import java.util.*;
public class Fibo {
public static void main(String[] args){
int n;
int f0 = 0, f1 = 1, f2;
Scanner s = new Scanner(System.in);
System.out.println("출력할 숫자 개수");
n = s.nextInt();
System.out.print("0 1");
for(int i = 3; i <= n; i++){
f2 = f1 + f0;
f0 = f1;
f1 = f2;
System.out.print(" " +f2);
}
}
}
'솔루션모음 > 파워자바 프로그래밍' 카테고리의 다른 글
[파워자바] 9장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
---|---|
[파워자바] 8장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
[파워자바] 7장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
[파워자바] 5장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
[파워자바] 4장 프로그래밍 솔루션 답지 (0) | 2023.02.15 |
댓글