Homework solution (2)

Page 1

Homework(2) Solution Java Lab Cs602_Gs311 Ms Halima atiya package switchop; import java.util.Scanner; public class SwitchOp { public static void main(String[] args) { // TODO code application logic here Scanner input = new Scanner (System.in); System.out.println("Enter the first number :"); double no1 = input.nextDouble(); System.out.println("Enter the Second number :"); double no2 = input.nextDouble(); double result = 0; System.out.println("Enter the Operation: "); char Op = input.next().charAt(0); switch(Op) { case'+': result =no1 + no2; break;


case '-': result = no1 - no2; break; case '/': result = no1/no2; break; case '*': result = no1*no2; break; default : System.out.print("you entered non of them");

} System.out.println("Result of Operation :"+ result); }


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.