Skip to content

Gift Emmanuel U23PE2035 #461

@Gift-Emmanuel

Description

@Gift-Emmanuel

import java.util.Scanner;

public class Main{
public static void main (String []args){
int Operator,n1,n2;
System.out.println("1-Add\n2-Subtract\n3-Multiply\n4-Divide\n5-Modulus");
System.out.print("Choose the operator: ");

Scanner sc=new Scanner(System.in);
Operator=sc.nextInt();

    System.out.print("Enter the first number: ");
      n1=sc.nextInt();
    System.out.print("Enter the second number: ");
    n2=sc.nextInt();
    
   int Result=0;
    switch(Operator){
        case 1:
        Result=n1+n2;
        break;
        
        case 2:
        Result=n1-n2;
        break;
        
        case 3:
        Result=n1*n2;
        break;
        
        case 4:
        Result=n1/n2;
        break;
        
        case 5:
        Result=n1%n2;
        break;
        
        default:
        System.out.println("Entered value is invalid");
        
        
    }System.out.println("The result is " + Result);
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions