U2p3.java

import java.util.*; public class u2p3 { public static void main(String []args) { int val,a,b; Scanner sc=new Scanner(System.in); System.out.println("1.add\n2.sub\n3.div\n4.mod\n5.mul\n"); System.out.println("Enter a choice"); val=sc.nextInt(); switch(val) { case 1: System.out.println("Enter a "); a=sc.nextInt(); System.out.println("Enter b"); b=sc.nextInt(); System.out.println("add is"+(a+b)+"\n"); break; case 2: System.out.println("Enter a "); a=sc.nextInt(); System.out.println("Enter b"); b=sc.nextInt(); System.out.println("sub is"+(a-b)+"\n"); break; case 3: System.out.println("Enter a "); a=sc.nextInt(); System.out.println("Enter b"); b=sc.nextInt(); System.out.println("div is"+(a/b)+"\n"); break; case 4: System.out.println("Enter a "); a=sc.nextInt(); System.out.println("Enter b"); b=sc.nextInt(); System.out.println("mod is"+(a%b)+"\n"); break; case 5: System.out.println("Enter a "); a=sc.nextInt(); System.out.println("Enter b"); b=sc.nextInt(); System.out.println("mul is"+(a*b)+"\n"); break; default: System.out.println("sorry choose right choice"); break; } } }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.