public class MySeventh
{
static void odd_or_even(int d)
{
if(d%2==0)
System.out.println("Numebr " + d + " is oven");
else
System.out.println("Numebr " + d + " is odd");
}
static void add(int a,int b)
{
int c = a+b;
System.out.println("Addition result is = " + c);
odd_or_even(c);
}
static void sub(int a,int b)
{
int c = a-b;
System.out.println("Subtractio
odd_or_even(c);
}
static void mul(int a,int b)
{
int c = a*b;
System.out.println("Multipy result is = " + c);
odd_or_even(c);
}
static void div(int a,int b)
{
int c = a/b;
System.out.println("Divided result is = " + c);
odd_or_even(c);
}
public static void main(String args[])
{
System.out.println("Enter two number");
Scanner scan = new Scanner (System.in);
int k = scan.nextInt();
int l = scan.nextInt();
System.out.println("What do you want with this numbers ? 1-Add 2-Subtract 3-Multipy 4-Divide");
int fun = scan.nextInt();
switch (fun)
{
case 1:
add(k,l);
break;
case 2:
sub(k,l);
break;
case 3:
mul(k,l);
case 4:
div(k,l);
}
}
}
沒有留言:
張貼留言