Created
March 24, 2015 13:40
-
-
Save ragmha/b127abb75085d52c48ae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this license header, choose License Headers in Project Properties. | |
* To change this template file, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package homework; | |
import java.util.Scanner; | |
/** | |
* | |
* @author Marwa | |
*/ | |
public class Homework { | |
private static Object Kbinput; | |
/** | |
* @param args the command line arguments | |
*/ | |
public static void main(String[] args) { | |
// TODO code application logic here | |
Scanner s=new Scanner(System.in); | |
System.out.println("YOU HAVE FOLLOWING CHOICES : "); | |
System.out.println("1. ADDITION"); | |
System.out.println("2. SUBTRACTION "); | |
System.out.println("3. MULTIPLICATION "); | |
System.out.println("4. DIVISION"); | |
System.out.println("ENTER YOUR CHOICE : "); | |
int i=s.nextInt(); | |
System.out.println("ENTER FIRST NUMBER "); | |
int a=s.nextInt(); | |
System.out.println("ENTER SECOND NUMBER "); | |
int b=s.nextInt(); | |
if ( a > 5 ) | |
if ( a < 1 ) | |
if ( b < 5 ) | |
if ( b < 1) { | |
System.out.println( "INVALID CHOICE" ) ; | |
} | |
double result=0; | |
switch(i) | |
{ | |
case 1: | |
result=a+b; | |
break; | |
case 2: | |
result=a-b; | |
break; | |
case 3: | |
result=a*b; | |
break; | |
case 4: | |
if(b==0)//when denominator becomes zero | |
{ | |
System.out.println("DIVISION NOT POSSIBLE"); | |
break; | |
} | |
else | |
result=a/b; | |
default: | |
System.out.println("YOU HAVE ENTERED A WRONG CHOICE"); | |
} | |
System.out.println("RESULT = "+result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment