我正在找不到符號錯誤。我正在製作一個可以執行各種數學運算的程序。在這裏,我得到的錯誤:獲取'找不到符號'錯誤
a=Double.parseDouble(in.readLine());
的錯誤是:
cannot find symbol- method readLine()
我給我的整個程序:
// I(Rachit Bhargava) am writing my first program that includes almost every feature of Mathematical Operations.
import java.io.*;
import java.lang.*;
import java.lang.Math;
public class All_In_One
{
public static void main(String args[])throws IOException
{
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader read = new BufferedReader(read);
double a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, r, s, t, u, v, w, x, y, z, i1, a1, i2, a2;
char ch1, ch2;
System.out.println("To which topic is your question based upon?");
System.out.println("Enter 'm' for Mathematics and 'g' for Geometry");
System.out.println("Please enter your choice.");
ch1= (char)(in.read());
switch (ch1)
{
case 'm':
System.out.println("What operation do you want to do?");
System.out.println("Enter 'a' for addtion, 's' for subtraction, 'm' for multiplication, 'd' for division, 't' for finding out simple interest(with amount), 'c' for finding out compound interest(with amount) and 'b' for finding out both(with amount) and their difference");
System.out.println("Please enter your choice.");
ch2= (char)(in.read());
switch (ch2)
{
case 'a':
System.out.println("Please enter first number.");
a=Double.parseDouble(in.readLine());
System.out.println("Please enter second number.");
b=Double.parseDouble(in.readLine());
c = a+b;
System.out.println("Sum = "+c);
break;
case 's':
System.out.println("Please enter first number.");
a=Double.parseDouble(in.readLine());
System.out.println("Please enter second number.");
b=Double.parseDouble(in.readLine());
c = a-b;
System.out.println("Difference = "+c);
break;
case 'm':
System.out.println("Please enter first number.");
a=Double.parseDouble(in.readLine());
System.out.println("Please enter second number.");
b=Double.parseDouble(in.readLine());
c = a*b;
System.out.println("Answer = "+c);
break;
case 'd':
System.out.println("Please enter first number.");
a=Double.parseDouble(in.readLine());
System.out.println("Please enter second number.");
b=Double.parseDouble(in.readLine());
c = (a>b)? (a/b):(b/a);
System.out.println("Answer = "+c);
break;
case 't':
System.out.println("Please enter principal");
p=Double.parseDouble(in.readLine());
System.out.println("Please enter rate of interest.");
r=Double.parseDouble(in.readLine());
System.out.println("Please enter time(in years)");
t=Double.parseDouble(in.readLine());
i = p*r*t/100;
a = p+i;
System.out.println("Simple interest = "+i);
System.out.println("Amount = "+a);
break;
case 'c':
System.out.println("Please enter principal");
p=Double.parseDouble(in.readLine());
System.out.println("Please enter rate of interest.");
r=Double.parseDouble(in.readLine());
System.out.println("Please enter time(in years)");
t=Double.parseDouble(in.readLine());
a = p*(Math.pow(((100+r)/100), t));
i = a-p;
System.out.println("Compound Interest = "+i);
System.out.println("Amount = "+a);
break;
case 'b':
System.out.println("Please enter principal");
p=Double.parseDouble(in.readLine());
System.out.println("Please enter rate of interest.");
r=Double.parseDouble(in.readLine());
System.out.println("Please enter time(in years)");
t=Double.parseDouble(in.readLine());
i1 = p*r*t/100;
a1 = p+i1;
a2 = p*(Math.pow(((100+r)/100), t));
i2 = a-p;
d = a2-a1;
System.out.println("Simple interest = "+i1);
System.out.println("Amount(as by simple interest) = "+a1);
System.out.println("Compound Interest = "+i2);
System.out.println("Amount(as by compound interest) = "+a2);
System.out.println("Difference in interests and amount = "+d);
break;
default:
System.out.println("Invalid input :(");
}
break;
case 'g':
System.out.println("Work In Progress!");
break;
default:
System.out.println("Invalid Input :(");
}
System.out.println("Thank you for using my program");
System.out.println("All credits goes to Rachit Bhargava");
}
}
請幫我解決這個問題!