try this... Keep in mind that you will need to check for bad entries etc... but I got what you had to compile and run with some changes... you can't assign a string to a double, you had extra + chars in the print lines... to name a few...
Code:
import java.io.*;
import java.lang.Double.*;
public class Phyiscs
{
static double current;
static double power;
static double voltage;
static double resistance;
public static void main(String args[])
{
System.out.println("This program will help you find the current and power if you have the reistance and voltage. OR It will find the voltage and power if you have the current and reistance.");
System.out.println("Please type 0 if you have the resistance and voltage, or type 1 if you have the current and resistance");
BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
try{
String inputLine = keyboard.readLine();
if ( Double.parseDouble(inputLine) == 0 ) {
System.out.println(" Please enter the Resistance: ");
resistance = Double.parseDouble(keyboard.readLine());
System.out.println(" Please enter the voltage: ");
voltage = Double.parseDouble(keyboard.readLine());
current=voltage/resistance;
System.out.println( " The current is:"+current);
power=current*voltage;
System.out.println( "The power is:"+power);
}
else
{
System.out.println(" Please enter the current: ");
current = Double.parseDouble(keyboard.readLine());
System.out.println(" Please enter the resistance: ");
resistance = Double.parseDouble(keyboard.readLine());
voltage=current*resistance;
System.out.println("The voltage is: " +voltage);
power=current*voltage;
System.out.println("The Power is:" +power);
}
} catch(Exception e){
System.out.println("error");
}
}
}