Don Hill
Posts: 70
Nickname: ssswdon
Registered: Jul, 2002
|
|
Re: need help please
|
Posted: Oct 11, 2002 7:14 AM
|
|
why not this,
else if (operand=='e') { //some cose to exit without errors break; // or done = true; }
> hi > im trying to write a java program that produce > results like this > c:\> java Calc > > * > 8 > 9 > > 72 > > % > 5 > 8 > > 5 > > \ > 99 > 8 > > Unknown operation: \ > Enter 'e' to quit. > > / > 99 > 8 > > 12 > > e > > c:\> > > ------ > NOW I WrOTE THIS PROGRAM BUT I CANT TERMINATE THE > LOOP PLS CAN SOME ONE HELP > THANX > > HERE IS THE PROGRAM > > > code: > import printer.*; //this is java package i am using > public class Calc > { > public static void main (String[] args) > { > boolean done = false; > char operand; > > while(!done) > { > System.out.println("Please enter the operation you > wish to perform:"); > System.out.println(" (+) for Addition"); > System.out.println(" (-) for Subtraction"); > System.out.println(" (*) for Multiplication"); > System.out.println(" (/) for Division"); > > operand = printer.readChar(); > printer.println("-"); > int a = printer.println.readInt(); > printer.println("-"); > int b = printer.readInt(); > printer.println("- \n"); > > if (operand=='*') > { > printer.println(a*b); > > else if (operand=='+') > { > printer.println(a+b); > } > else if (operand=='e') > { > //some cose to exit without errors > } > else > { > printer.println("Invalid input!"); > printer.println("Enter 'e' to quit."); > } > } > } > > > i need to exit from the loop without errors im trying > but i have no luck, i need to enter e in order to end > the program.
|
|