Exception Handling in Java 2011View more random threads:
- Request for Guidance in java 20111
- What is Apache server and mysql
- Signing Java Applets
- What is OPERATOR OVERLOADING?
- Java 6 update 26 - incompatible! Bis
- little error in java code
- JSP came when the Servlets , Need for JSP With servlets,SF...
- What is perl and What is a "sandbox
- Excpetions , Multiple Exceptions , how ??
- Explict Destructor. in java 2011
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)