Exception Handling in Java 2011View more random threads:
- program does not enter for loop in Java 2011
- NetBeans IDE 7.0 Download Started in 2011 for beginners
- Proplem in code .help please
- Difference between Java and Netbeans 2011
- what is difference between PhP and java
- How to run a java file that creaded in Ntebeans in console
- what is main difference between "javac" and...
- Java working High-performance for all platforms
- execution of programms in java
- try, catch and finally block?
Sponsored Links
Code:import java.util.Scanner; public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner( System.in); int Num1, Num2=1, sum, product, difference; float division; try { while(Num2 !=0) { System.out.print("Enter first Number: "); Num1 = input.nextInt(); System.out.print(" Enter Second Number: "); Num2 = input.nextInt(); sum = Num1 + Num2; product = Num1 * Num2; difference = Num1 - Num2; division = (float)Num1/(float)Num2; System.out.printf("Sum =%d\n", sum); System.out.printf("Product =%d\n", product); System.out.printf("The difference =%d\n", difference); System.out.printf("Divion is %.3f\n ", division); } } catch(Exception e) { System.err.println("Error " + e.getMessage()); } } }
There are currently 1 users browsing this thread. (0 members and 1 guests)