如果这个问题真的很明显,请原谅我,但我已经尝试了一切。
我正在尝试制作一个计算数字百分比的计算器。
但是当我使用此代码时,它会一直为输出输出 0:
import java.io.*;
class pCalc {
public static void main(String args[])
{
InputStreamReader istream = new InputStreamReader(System.in) ;
BufferedReader bufRead = new BufferedReader(istream) ;
System.out.println("Hello...");
try {
System.out.println("Please Enter In The Percentage You Want To Find (e.g 25): ");
String rpercent = bufRead.readLine();
System.out.println("Please Enter In The Number You Wish To Find The Percentage Of (e.g 200): ");
String rnumber = bufRead.readLine();
int repercent = Integer.parseInt(rpercent);
int number = Integer.parseInt(rnumber);
int percent = repercent / 100;
int awnswer = number * percent ;
System.out.println("Percent is: " + percent);
System.out.println("Awnswer is: " + awnswer);
}
catch (IOException err) {
System.out.println("Error reading line");
}
catch(NumberFormatException err) {
System.out.println("Error Converting Number");
}
}
}