资源简介
RPN计算器
Program Input
Each line of the input file (prob12.in) contains a series of numbers and operators. The program must evaluate these lines as RPN expressions. All tokens are separated by one or more spaces. Numbers may be negative. Valid operators are +(addition), -(subtraction), *(multiplication) and /(division). The last line of the file contains only the word END:
16 3 7 + *
4 32.125 13 – * 20 +
5 –3 * 4 2 / 6 3 1 – / + +
END
Program Output
The program will print the computed result of each RPN expression on a separate line.
160
96.5
-10
代码片段和文件信息
import java.io.*;
import java.util.*;
public class RPNcalculator {
public static void main(String[] args) {
String fileName=“RPNInput.txt“;
String fileName2=“RPNOutput.txt“;
Scanner inputStream = null;
PrintWriter outputStream = null;
//read
try{
inputStream = new Scanner(new File(fileName)); //try to open the file
}
catch(Exception e){
System.out.println(“Could not open the file named “+ fileName); // if it doesn‘t find it tell them
System.exit(0); // and then exit.
}
//write
try{
outputStream = new PrintWriter(new FileOutputStream(fileName2true)); //try to create the file
}
catch(Exception e){
System.out.println(“Could not open the file named “+ fileName2); // if it doesn‘t find it tell them
System.exit(0); // and then exit.
}
while(inputStream.hasNextLine()){
String equation = inputStream.nextLine();
if (equation==null) break;
Stack tks = new Stack 相关资源
- Java综合程序设计——计算器(实现运
- JAVA计算器实验报告与源码
- 自己用java写的计算器源代码(代码注
- 使用java语言编译一个计算器
- java课程设计保存计算过程的计算器
- java大作业,科学计算器
- android:简单计算器+源码+注释
- java编写的汇率计算器
- Android 课设 简单计算器源码(含apk)
- Java swing 计算器。
- 安卓 仿iphone计算器
- 身体质量指数计算器BMI
- WEB实现的计算器
- Android 计算器可货币换算
- android简单计算器的实现
- Android语音计算器 支持括号 可处理异
- android 计算器GridView实现
- android计算器源码压缩包
- 计算器(android)
- android eclipse 编写的简易计算器
- Android仿IOS计算器源码
- Java源码 吃豆豆 俄罗斯方块 扫雷 计算
- 基于Android Studio 开发计算器代码
- Java版计算器源代码带括号
- Java多功能计算器+设计模式+开发文档
- Android 计算器源码
- 用Android studio写的一个四则运算计算器
- 简单的Android计算器,支持科学计算
- Android开发支持连算计算器
- android 数学表达式计算器
川公网安备 51152502000135号
评论
共有 条评论