Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.*;
- public class Main {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int choice;
- int a, b;
- do {
- System.out.println("Select an operation: \n1. Addition\n2. Subtraction" +
- "\n3. Multiplication\n4. Division \n5. Exit");
- System.out.print("Choice: ");
- choice = input.nextInt();
- if(choice == 1){
- System.out.print("First number: ");
- a = input.nextInt();
- System.out.print("Second number: ");
- b = input.nextInt();
- System.out.println("Sum: " + (a+b));
- }
- if(choice == 2){
- System.out.print("First number: ");
- a = input.nextInt();
- System.out.print("Second number: ");
- b = input.nextInt();
- System.out.println("Sum: " + (a-b));
- }
- if(choice == 3){
- System.out.print("First number: ");
- a = input.nextInt();
- System.out.print("Second number: ");
- b = input.nextInt();
- System.out.println("Sum: " + (a*b));
- }
- if(choice == 4){
- System.out.print("First number: ");
- a = input.nextInt();
- System.out.print("Second number: ");
- b = input.nextInt();
- System.out.println("Sum: " + (a/b));
- }
- if(choice == 5){
- System.out.println("Program will terminate.");
- System.exit(0);
- }
- }while(true);*/
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement