Last active
October 28, 2015 04:47
-
-
Save tanakaedu/2164a3933e62f525b60e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.InputStreamReader; | |
public class Main { | |
public static void main(String[] args) throws Exception { | |
// 変数の定義 | |
int atai1=0; | |
int atai2=0; | |
int kotae=0; | |
// Here your code ! | |
java.util.Scanner br = new java.util.Scanner(System.in); | |
// 値1の入力 | |
atai1 = br.nextInt(); | |
br.nextLine(); // 改行を飛ばす | |
// 計算記号の入力 | |
String line = br.nextLine(); | |
// 値2の入力 | |
atai2 = br.nextInt(); | |
// 計算記号に応じて分岐 | |
if(line.equals("+")) { | |
kotae=atai1+atai2; | |
} | |
if(line.equals("-")) { | |
kotae=atai1-atai2; | |
} | |
// 結果の出力 「値1 計算記号 値2 = 答え」と表示されるようにする | |
System.out.println(atai1+line+atai2+"="+kotae); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment