Computer Science, asked by Zerina313121, 16 hours ago

Java program----------​

Attachments:

Answers

Answered by samarthkrv
0

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

 Scanner sc = new Scanner(System.in);

 System.out.println("Enter 2 numbers-");

 int a = sc.nextInt();

 int b = sc.nextInt();

 System.out.print("Choose operation letter:");

 char c = sc.next().charAt(0);

     if(c == 'D' || c == 'd'){

         System.out.println(a + " / " + b + " = " + (a/(float)b));

     }

      else if(c == 'A' || c == 'a'){

         System.out.println(a + " + " + b + " = " + (a+b));

     }

      else if(c == 'M' || c == 'm'){

         System.out.println(a + " * " + b + " = " + (a*b));

     }

      else if(c == 'S' || c == 's'){

         System.out.println(a + " - " + b + " = " + (a-b));

     }

      else if(c == 'R' || c == 'r'){

         System.out.println(a + " % " + b + " = " + (a%b));

     }

      else if(c == 'E' || c == 'e'){

         System.out.println("exiting....");

     }

     else{

         System.out.println("Invalid letter for operation");

     }

}

}

Explanation:

Answered by makhamali2
0

Answer:

Answer:

import java.util.Scanner;

public class Main

{

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.println("Enter 2 numbers-");

int a = sc.nextInt();

int b = sc.nextInt();

System.out.print("Choose operation letter:");

char c = sc.next().charAt(0);

    if(c == 'D' || c == 'd'){

        System.out.println(a + " / " + b + " = " + (a/(float)b));

    }

     else if(c == 'A' || c == 'a'){

        System.out.println(a + " + " + b + " = " + (a+b));

    }

     else if(c == 'M' || c == 'm'){

        System.out.println(a + " * " + b + " = " + (a*b));

    }

     else if(c == 'S' || c == 's'){

        System.out.println(a + " - " + b + " = " + (a-b));

    }

     else if(c == 'R' || c == 'r'){

        System.out.println(a + " % " + b + " = " + (a%b));

    }

     else if(c == 'E' || c == 'e'){

        System.out.println("exiting....");

    }

    else{

        System.out.println("Invalid letter for operation");

    }

}

}

Explanation:

Explanation:

Similar questions