0

I'm aware that a good portion of the code needs fine-tuning however, I'd appreciate if your focus was towards #1. Which is the first if statement. For whatever reason, I can't seem to get the 2 variables + the answer to appear.

import java.util.Scanner;

public class Calculators {

    public static void menudisplayer()


    {

        Scanner myObj = new Scanner(System.in); // Create a Scanner object

        System.out.println("1 - Add" + "\n" + "2  - Subtract" + "\n" + "3 - Divide " + "\n" + "4 - Multiply" + "\n" + "5 - Average" + "\n" + "6 - Maximum" + "\n"); //printing menu

        System.out.println("Please type in the operation that you would like to use");
        String operations = myObj.nextLine(); // Read user input
        System.out.println("You Entered: " + operations + "\n"); // Output user input  

        double value1, value2, answer;
        Scanner scanvalues = new Scanner(System.in);

        System.out.print("Enter any two Double Values" + "\n");
        value1 = scanvalues.nextDouble();
        value2 = scanvalues.nextDouble();




        if (operations == "1") {
            System.out.println(answer = value1 + value2);
            System.out.println("value1="+value1+"\nvalue2="+value2+"\nAnswer="+answer);


        } else if (operations == "2") {
            System.out.println(value1 + value2);
        } else if (operations == "3") {
            System.out.println(value1 + value2);
        }



    }




    public static void main(String[] args) {
        menudisplayer();

    }
}
seenukarthi
  • 8,241
  • 10
  • 47
  • 68
Auriph
  • 7
  • 1
  • 3

0 Answers0