All pastes #758635 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-11-02 12:50 UTC
rendered paste body
import java.util.Scanner;
public class flowChart
{
    public static void main(String [] args)
    {
        Scanner sc = new Scanner( System.in );
        int x;
        int num=0;
        String exitPrompt="";
        System.out.println("You may exit the program by typing 'end' at any time."
                           + "\nPlease enter a number: ");
           while (num==0)
           {
               if (sc.hasNextInt())
                {
                    num = sc.nextInt();
                }else{
                    if (sc.next().equalsIgnoreCase("end"))
                        {
                            System.exit ( 0 );
                        }else{
                            System.out.println("Not a valid input.  Please try again.");
                        }
                    
                }
           }
           
            x = num;
            while (!exitPrompt.equalsIgnoreCase("end"))
            {
                System.out.println("Please enter another number: ");
                if (sc.hasNextInt())
                {
                    num=sc.nextInt();
                }else{
                    if (sc.next().equalsIgnoreCase("end"))
                        {
                            System.out.print("Your largest number was: " + x );
                            System.exit ( 0 );
                        }else{                            
                            System.out.println("Not a valid input.  Please try again.");
                        }
                }
                    if (num>x)
                    {
                        x=num;
                    }
            }
           
     }
}