Created
October 10, 2015 21:47
-
-
Save tinkerstudent/1a336c388de4f8821b7b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| package com.tinkeracademy.ap; | |
| import java.io.File; | |
| import java.io.FileNotFoundException; | |
| import java.util.Scanner; | |
| // | |
| public class Main { | |
| public static void main(String[] args) throws FileNotFoundException { | |
| Scanner s = new Scanner(new File("input.txt")); | |
| int operand = 0; | |
| String op = ""; | |
| int result = 0; | |
| while (!op.equals("=")) { | |
| operand = s.nextInt(); | |
| if (op.equals("+")) { | |
| result = result + operand; | |
| } else if (op.equals("-")) { | |
| result = result - operand; | |
| } else { | |
| result = operand; | |
| } | |
| op = s.next(); | |
| } | |
| System.out.println("result=" + result); | |
| s.close(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment