Assignment 1 - Semester Fall 2020: COMSATS University Islamabad, Lahore Campus Department of Electrical Engineering
Assignment 1 - Semester Fall 2020: COMSATS University Islamabad, Lahore Campus Department of Electrical Engineering
Assignment 1 - Semester Fall 2020: COMSATS University Islamabad, Lahore Campus Department of Electrical Engineering
Q1: Rewrite the given code into object-oriented java code. Estimate mathematical operations and write a
separate class method for each operation. Extend your code by adding a separate function for user input.
Make sure that program satisfies input and output validations. [CLO 1, PLO1 C2]
switch (operation) {
case "*":
System.out.println(eo + "* \n Your Result: "+ ( firstNumber * secondNumber ));
break;
case "/":
System.out.println(eo +"/ \n Your Result: "+ ( firstNumber / secondNumber ));
break;
case "+":
System.out.println(eo + "+ \n Your Result: "+ ( firstNumber + secondNumber ));
break;
case "-":
System.out.println(eo + "- \n Your Result: "+ ( firstNumber - secondNumber ));
break;
default: System.out.println("\n Please select a valid character");
}
scanner.close();
System.out.println(" Closing Application ");
}
Page 1 of 1