In: Computer Science
The purpose of this assignment is to reinforce Ada concepts.
Note: do not include ‘hard-coded’ input data in the Ada source code
Please give positive ratings for my effort. Thanks.
PROGRAM
import java.util.Scanner;
public class Main
{
public static int add(int a, int b)
{
return a+b;
}
public static int subtract(int a, int b)
{
return a-b;
}
public static double multiply(int a, int b)
{
return a*b;
}
public static double divide(int a, int b)
{
return (double)((double)(a)/(double)(b));
}
public static void main(String[] args)
{
System.out.print("Enter two numbers
: ");
int a,b;
Scanner sc = new
Scanner(System.in);
a = sc.nextInt();
b = sc.nextInt();
System.out.println("\n1. Addtion");
System.out.println("2.
Subtraction");
System.out.println("3.
Multiplication");
System.out.println("4.
Division");
System.out.println("5. Exit");
while(true)
{
System.out.print("\nChoose a operation : ");
int n = sc.nextInt();
switch(n)
{
case 1:{
int result = add(a,b);
System.out.println("\nResult = " +
result);
break;
}
case 2:{
int result = subtract(a,b);
System.out.println("\nResult = " +
result);
break;
}
case 3:{
double result =
multiply(a,b);
System.out.println("\nResult = " +
result);
break;
}
case 4:{
double result = divide(a,b);
System.out.println("\nResult = " +
result);
break;
}
case 5:{
System.exit(0);
break;
}
default:
System.out.println("\nInvalid
Input");
break;
}
}
}
}
IMAGE OF PROGRAM
IMAGE OF OUTPUT
THANK YOU!!