import java.io.*;
class empl
{
int p, n, r, i;
void accept()
{
try
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Principal amount");
int p = Integer.parseInt(br.readLine());
System.out.println("Enter no of years");
int n = Integer.parseInt(br.readLine());
System.out.println("Enter rate");
int r = Integer.parseInt(br.readLine());
} catch(Exception e)
{
System.out.println("" + e);
}
}
int calculate()
{
i = (p * n * r) / 100;
return (i);
}
}
class bank
{
public static void main(String args[])
{
empl e = new empl();
e.accept();
int a = e.calculate();
System.out.println("i=" + a);
}
}
我是java初学者。上面的程序总是给我结果为0。我也尝试了许多不同的输入值,但结果保持不变。我确信公式没有问题。请帮帮我。谢谢提前。