Eclipse keeps giving me the following error:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
input cannot be resolved
The method If(boolean) is undefined for the type bai1DinhLuatCuLong
Syntax error, insert ";" to complete Statement
F cannot be resolved to a variable
I do not understand this. What do I need to fix? Why can't I use the If()
function?
I've tried looking through Google and Bing, and I've double checked my Java examples book, but I could not work this out.
import java.util.Scanner;
public class bai1DinhLuatCuLong
{
public static void main(String[] args)
{
System.out.print("Giá trì c?n tìm (F // q // r) : ");
char cantim = input.nextChar();
// HERE THIS IS WHERE I PUT THE IF STATEMENT !!!
If (cantim == 'F') {
Scanner input = new Scanner(System.in);
System.out.print("?? l?n c?a ?i?n tích th? nh?t : ");
double q1 = input.nextDouble();
System.out.print("?? l?n c?a ?i?n tích th? hai : ");
double q2 = input.nextDouble();
System.out.print("Kho?ng cách gi?a 2 ?i?n tích : ");
double r = input.nextDouble();
System.out.print("H? s? k s? t? ??ng ???c ??t là 9*10^9 nh? trong h? SI");
double F = 9 * Math.pow(10,9) * Math.abs(q1) * Math.abs(q2) / Math.pow(r,2);
}
System.out.print("?? l?n l?c t??ng tác gi?a 2 ?i?n tích ?i?m : " + "
L?u y E là *10");
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…