DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Thread: help javaaaa

  1. #1
    Join Date
    Oct 2002
    Posts
    6

    help javaaaa

    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 WOTE THIS PROGRAM BUT I CANT TERMINATE THE LOOP PLS CAN SOME ONE HELP
    THANX

    HERE IS THE PROGRAM

    public class Calc
    {
    public static void main (String[] args)
    {

    boolean done = false;
    boolean isGood;
    char operand;


    while( true)
    {
    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 = .readChar();
    .println("-");
    int a = println.readInt();
    .println("-");
    int b = .readInt();
    .println("- \n");

    if (operand=='*')
    {
    .println(a*b);
    isGood = true; }
    else if (operand=='+')

    {
    .println(a+b);
    isGood = true;
    }
    else if (operand=='e')
    {
    isGood = false;
    return;
    }
    else
    {
    isGood = false;
    .println("Invalid input!");
    .println("Enter 'e' to quit.");

    char quit = .readChar();

    } }}
    }

  2. #2
    Join Date
    Aug 2002
    Posts
    94
    Hi,
    try this in your code:

    else if (operand=='e')
    {
    isGood = false;
    System.exit(0);
    }

    bye

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links