Write a program which adds or subtract two number
here are condition:-
1. make a method which will add two no.
2. make a method which subtract the two no.
3. ask user if they wanna add or subtract and then call the method needed as per need
i am deeply confused and will really appreciate anyone who will make this basic script from which i can observe my mistake
here is my code for reference if you need but it is not working
import java.util.Scanner; public class sum { static Scanner input = new Scanner(System.in); public static double addition(double s1 ,double s2 ) { double sum1 = s1 + s2; return sum1; } public static double subtraction(double s1, double s2) { double sum1 = s1-s2; return sum1; } public static void main(String args[]) { double n1, n2, sum; System.out.println("welcome do you want to add or divide"); String s = input.next(); if (s.equalsIgnoreCase("add") || (s.equalsIgnoreCase("addition"))) { System.out.println("enter the two numbers"); n1 = input.nextDouble(); n2 = input.nextDouble(); sum = addition(n1, n2); System.out.println(sum); } else if (s.equalsIgnoreCase("minus") || (s.equalsIgnoreCase("subtraction"))) { System.out.println("enter the two numbers"); n1 = input.nextDouble(); n2 = input.nextDouble(); sum = subtraction(n1, n2); System.out.println(sum); } } }