All pastes #749374 Raw Edit

Miscellany

public text v1 · immutable
#749374 ·published 2007-10-25 17:27 UTC
rendered paste body
package lab6a_exception;

import java.lang.StringBuffer;
import java.io.IOException;

class Lab7app 
{
	public static void main(String[] args)
	{
		System.out.print("Please enter dividend: ");
		String InputString = getConsoleString();
		int NumberOne = Integer.parseInt(InputString);
		System.out.print("Please enter divisor: ");
		InputString = getConsoleString();
		int NumberTwo = Integer.parseInt(InputString);
		try
		{
			int NumberThree = NumberOne / NumberTwo;
			System.out.println("First number divided by the second is: " + NumberThree);
		}
		catch(Exception e)
		{
			System.err.println("General Execption thrown");
		}
		finally
		{
			System.out.print("the end");
		}
	}
	public static String getConsoleString()
	{
		int noMoreInput = -1;
		char enterKeyHit = '\n';
		char enterAlternate = '\r';
		int inputChar;
		StringBuffer InputBuffer = new StringBuffer(30);
		try
		{
			inputChar = System.in.read();
			while(inputChar != noMoreInput)
			{
				if((char)inputChar != enterAlternate)
					InputBuffer.append((char)inputChar);
				else 
				{
					inputChar = System.in.read();
					break;
				}
				inputChar = System.in.read();
			}
		}
		catch(IOException IOX){
			System.err.println(IOX);
		}
		return InputBuffer.toString();
	}
}