Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

I am supposed to be making a program to help divers calculate things. I have made methods to calculate a few different equations (I have only really just started) but i can't figure out how to call them to print the answer and things. here's my code I don't know what i'ev done wrong i've looked up a bunch of different things and this is what i've found but it isn't compiling.

Code:
```import java.util.*;

public class Program
{

double percentage;
double pressure;
double standard = 1.4;
double depth;
String input;

public Program()
{
Scanner scan = new Scanner (System.in);

System.out.println ("Which calculation do you wish to perform (Help/MOD/SMOD/BM/PP/EAD)? ");
input = scan.nextLine();
if (input == "mod" || input == "MOD") {
System.out.println("Calculating the MOD");
System.out.println("Enter the percentage of Oxygen: ");
percentage = scan.nextDouble();
System.out.println("Enter the partial pressure of Oxygen (between 1.1 and 1.6 inclusive): ");
pressure = scan.nextDouble();
System.out.println("Maximum Operation Depth for a dive with " + percentage + " with a partial pressure of " + pressure + " is " + printMOD() + " metres.");
} else if (input == "smod" || "SMOD") {
System.out.println("Calculating the SMOD");
System.out.println("Calculating the MOD for the standard 1.4 partial pressure");
System.out.println("Enter the percentage of Oxygen: ");
percentage = scan.nextDouble();
int result = printSMOD();
System.out.println("Maximum Operation Depth for a dive with " + percentage + " with a partial pressure of " + pressure + " is " + result + " metres.");
}

}

public static void printMOD() {
int mod;
mod = ((pressure/percentage)-1)*10;
return mod;
}

public static void printSMOD (double percentage, double standard) {
double smod;
smod = ((1.4/percentage)-1)*10;
return smod;
}
public static void printBM (double pressure, int depth) {
double bm;
bm = (pressure/depth)*100;
return bm;
}
}```

• Strings cannot be compared like this: `if (input == "mod" || input == "MOD") {`. This (and a similar one further down) must be written as `if (input.equals("mod") || input.equals("MOD")){`.

•