Notice
Recent Posts
Recent Comments
Link
«   2024/11   »
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 29 30
Tags
more
Archives
Today
Total
관리 메뉴

main

[백준-5355번/Java] 화성수학 본문

Algorithm

[백준-5355번/Java] 화성수학

1984 2022. 11. 9. 20:17

* double 소수점

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int num = Integer.parseInt(sc.nextLine());

		for (int i = 0; i < num; i++) {
			String str = sc.nextLine();
			String[] strs = str.split(" ");
			double answer = -1;

			for (int j = 0; j < strs.length; j++) {
				if (j == 0) {
					answer = Double.parseDouble(strs[0]);
				} else {
					switch (strs[j]) {
					case "@":
						answer *= 3;
						break;
					case "%":
						answer += 5;
						break;
					case "#":
						answer -= 7;
						break;
					default:
						break;
					}
				}
				if (j == strs.length - 1)
					System.out.printf("%.2f%n", answer);
			}

		}
	}

}
728x90

'Algorithm' 카테고리의 다른 글

[백준-2935번/Java] 소음  (0) 2022.11.09
[백준-2675번/Java] 문자열 반복  (0) 2022.11.09
[백준-2914번/Java] 저작권  (0) 2022.11.09
[백준-2530번/Java] 인공지능 시계  (0) 2022.11.09
[백준-2525번/Java] 오븐 시계  (0) 2022.11.09
Comments