Posts

Showing posts with the label switch-statement

Making a calculator using switch case

Making a calculator using switch case The result i get : Enter a number : 5 Enter another number : 4 What do you want to perform on these numbers? You have entered a wrong action, please try again Where did i go wrong in my code? import java.util.Scanner; public class App { public static void main(String args) { double num1, num2; Scanner sc = new Scanner(System.in); System.out.println("Enter a number : "); num1 = sc.nextDouble(); System.out.println("Enter another number : "); num2 = sc.nextDouble(); System.out.println("What do you want to perform on these numbers? "); String word = sc.nextLine(); sc.close(); double result = 0; switch (word) { case "Addition": result = num1 + num2; System.out.println(num1 + " " + word + " " + num2 + " :...