MCO1 – ITE 2
Computer Programming 1
SUBMITTED BY
PARAL, DARWIN F.
BSEMC 1 - A
MARTIN CARAUSOS BAZA
SUBJECT INSTRUCTOR
College of Computing Information Sciences
Bachelor of Sciences in Entertainment and Multimedia Computing
MCO1 – ITE 2 Computer Programming 1
Problem
Create a basic calculator in java using the nested if/else statements which can perform
operations like Addition, Subtraction, Multiplication, Division, and Modulo of any two
numbers.
Algorithm
1. The code uses Scanner to take two numbers and an operator as input from the user.
[Link] code uses if/else if/else statements to implement the logic for different operations
based on the entered operator.
3. The double result = 0.0; line initializes a variable to store the answer.
4. [Link]("Result: " + result); prints the result.
OUTPUT:
Let’s see the output of what our calculator will look like –
Enter the two numbers: 4 , 4
Choose and Enter the type of operation you want to perform (+, -, *, /, %) : -
Your Answer is = 0
CODE: