网络编程实验报告(9)

2019-08-03 14:54

op1 = textField.getText(); inputState3(s); } if ( s.equals(\ { state = 3; op1 = textField.getText(); } if ( s.equals(\ textField.setText(\ if ( s.equals(\ { String text = textField.getText(); if ( text.length() == 1 ) textField.setText(\ else textField.setText( text.substring(0, text.length()-1) ); } } //state 3 op1 read only, only op1 was input ,op2 = operator = null private void inputState3( String s ) { if ( isDigit(s)||s.equals(\ { op1 = \ textField.setText(\ state = 2; inputState2(s); } if ( s.equals(\ { state = 2; op1 = \ inputState2(s); } if ( isOperator(s) ) { operator = s; state = 4; if (operator.equals(\

||operator.equals(\

||operator.equals(\ {

inputState6(s); } }

if ( s.equals(\ {

Float fOp1 = new Float(op1); if ( fOp1.floatValue() ==0.0 ) {

state = 1; //error

textField.setText(errMsg); } else {

float f = 1.0f/fOp1.floatValue(); op1 = String.valueOf(f); textField.setText(op1); } }

if ( s.equals(\ {

state = 0;

textField.setText(\ } }

//state 2, op1 and operator are read, op2 = null private void inputState4( String s ) {

if ( isDigit(s)||s.equals(\ {

textField.setText(\ state = 5;

inputState5(s); }

if ( isOperator(s)) operator = s; if ( s.equals(\ {

state = 3;

operator = \ inputState3(s); }

if ( s.equals(\ {

state = 0;

textField.setText(\ } }

//state5,op2 reading,in reading of op2 private void inputState5( String s ) {

if ( isDigit(s) ) {

String text = textField.getText(); if ( text.equals(\ text = s; else

text = text + s; textField.setText(text); }

if ( s.equals(\ {

String text = textField.getText(); if ( !text.contains(\ {

text = text + s;

textField.setText(text); } }

if ( s.equals(\ {

String text = textField.getText(); if (text.charAt(0) == '-' )

text = text.substring(1); else

text = '-' + text; textField.setText(text); }

if ( isOperator(s) ) {

op2 = textField.getText();

Float f1, f2;

f1 = new Float(op1); f2 = new Float(op2); float fop1, fop2;

fop1 = f1.floatValue(); fop2 = f2.floatValue(); if ( operator.equals(\ fop1 = fop1 + fop2;

else if ( operator.equals(\ fop1 = fop1 - fop2;

else if ( operator.equals(\ fop1 = fop1 * fop2;

else if ( operator.equals(\ {

if ( fop2 != 0.0f )

fop1 = fop1 / fop2; else {

state = 1;

textField.setText(errMsg); return; } } else {

System.out.println(\ state = 1;

textField.setText(errMsg); return; }

//here we got good calculating result op1 = String.valueOf(fop1); textField.setText(op1); operator = s; state = 4; }

if ( s.equals(\ {

op1 = textField.getText(); state = 3;

inputState3(s); }

if ( s.equals(\

{

op2 = textField.getText(); Float f1, f2;

f1 = new Float(op1); f2 = new Float(op2); float fop1, fop2;

fop1 = f1.floatValue(); fop2 = f2.floatValue(); if ( operator.equals(\ fop1 = fop1 + fop2;

else if ( operator.equals(\ fop1 = fop1 - fop2;

else if ( operator.equals(\ fop1 = fop1 * fop2;

else if ( operator.equals(\ {

if ( fop2 != 0.0f )

fop1 = fop1 / fop2; else {

state = 1;

textField.setText(errMsg); return; } }

else if ( operator.equals(\

fop1 = (float) Math.pow( fop1, fop2 ); else {

System.out.println(\ state = 1;

textField.setText(errMsg); return; }

//here we got good calculating result op1 = String.valueOf(fop1); textField.setText(op1); state = 3; }

if ( s.equals(\ {

state = 0;

textField.setText(\


网络编程实验报告(9).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:建筑工程施工技术与管理复习题答案

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: