Results 1 to 2 of 2
  1. #1
    denisdoherty is offline Member
    Join Date
    Apr 2008
    Rep Power

    Default Printing total out

    When i enter in numbers into the client side of the application I want to have them appear on the server side as i enter them and then when i enter in "End" i want the program to tell me on the client and the server side what the total is. The code that i have at the minute is

    Java Code:
             System.out.println("Enter a Number: "+i);
                      number= br.readLine( );
             if (number.equalsIgnoreCase("End"))
             System.out.println("TOTAL " + numberBack);
             System.out.println("Session Over ");
            }//end if
            numberBack = helper.getnumber(number);
            while (!number.equalsIgnoreCase("End"));
          } // end try  
          catch (Exception ex) {
          } //end catch
    Does anyone know how to do this. I can do it for a specific number of numbers but i want to be able to do it for any amount of numbers

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Colombo, Sri Lanka
    Blog Entries
    Rep Power


    I'm not exactly clear what you expecting. Can't figure out some variables, methods and so. But the logic you are expecting is this.

    Java Code:
    import java.util.Scanner;
    public class denisdoherty {
        public static void main(String[] args) {
            Scanner input = new Scanner(;
            int i = 1;
            int total = 0;
            boolean stat = true;
            do {
                System.out.println("Enter the number " + i + " ");
                String str = input.nextLine();
                if(!str.equalsIgnoreCase("End")) {
                        int value = Integer.parseInt(str);
                        total += value;
                else {
                        stat = false;
                        System.out.println("TOTAL " + total);
                        System.out.println("Session Over ");                

Similar Threads

  1. Problem after Printing GUI.
    By coldblood22 in forum AWT / Swing
    Replies: 1
    Last Post: 04-05-2008, 02:43 PM
  2. Printing (no dialog)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-04-2008, 10:36 AM
  3. Printing using java
    By ramachandran in forum Advanced Java
    Replies: 1
    Last Post: 01-05-2008, 11:16 AM
  4. printing problem
    By ntpl in forum AWT / Swing
    Replies: 0
    Last Post: 11-27-2007, 12:20 PM
  5. [Java Printing]
    By remnahush in forum Advanced Java
    Replies: 1
    Last Post: 11-08-2007, 04:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts