a 를 2b배 만큼 곱한 값을 출력한다. import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); int pow = (int) Math.pow(2, b); System.out.println(a*pow); } }
합과 평균을 줄을 바꿔 출력한다. 평균은 소수점 이하 둘째 자리에서 반올림해서 소수점 이하 첫째 자리까지 출력한다. import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); int c = scan.nextInt(); int total = a+b+c; System.out.println(total); System.out.println( String.format("%.1f", ..
- 첫줄에 합 - 둘째줄에 차 - 셋째줄에 곱 - 넷째줄에 몫 - 다섯째 줄에 나머지 - 여섯째 줄에 나눈 값을 순서대로 출력한다. (실수, 소수점 이하 셋째 자리에서 반올림해 둘째 자리까지 출력) import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); int b = scan.nextInt(); System.out.println(a+b); System.out.println(a-b); System.out.print..
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); char a = scan.nextLine().charAt(0); System.out.printf("%c", a+1); } }
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); int a = scan.nextInt(); //양수 -> 음수, 음수 -> 양수 System.out.println(a * -1 ); } }
영문자 입력받아 아스키코드 출력 import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner scan = new Scanner(System.in); char a = scan.nextLine().charAt(0); int result = (int) a; System.out.println(result); } } 정수 입력받아 아스키코드 출력 import java.io.IOException; import java.util.Scanner; public class Main { public static void main(St..