All pastes #330499 Raw Edit

Miscellany

public text v1 · immutable
#330499 ·published 2007-01-27 23:27 UTC
rendered paste body
import java.io.IOException;
public class mycalculator {

	// requests two numbers and adds them together


	public static void main(String[] args) {
		int firstnum = 0;
		int secondnm = 0;
		int result = 0;
		
	/////
	///// ASK FOR THE FIRST NUMBER AND PRINT IT
	/////
		
		System.out.println("Enter the first number to be added:");
		try{
			firstnum = System.in.read();
		}
		catch (IOException e) {
			return;
		}
		firstnum = firstnum - 48;
		System.out.println("You entered " +firstnum);
		
	//////
	////// ASK FOR THE SECOND NUMBER AND PRINT IT
	//////
		
		System.out.println("Enter the 2nd number to be added:");
		try{
			secondnm = System.in.read();
		}
		catch (IOException e) {
			return;
		}
		System.out.println("What is second number " + secondnm);
		secondnm = secondnm - 48;
		System.out.println("You entered " +secondnm);
		
		//// ADD THE NUMBERS TOGETHER
		
		result = firstnum + secondnm;
		System.out.println("Your result is "+result);
		
	}

}