我正在尝试完成我的 java 理性课程,而我希望完成的所有地方都没有它几乎相同。我知道我可以使用其他程序,但我见过的程序在运行程序时没有用于输入输入的位置。这是我到目前为止的代码
import java.util.Scanner;
public class Lab09ast
{
private static int num, den; // numerator and denominator of the rational number
public static void main (String[] args)
{
enterData();
Rational r = new Rational(num,den);
r.displayData();
}
public static void enterData()
{
Scanner input = new Scanner(System.in);
System.out.print("\nEnter the numerator ----> ");
num = input.nextInt();
System.out.print("\nEnter the denominator --> ");
den = input.nextInt();
}
}
class Rational
{
public void displayData()
{
System.out.println();
System.out.println(getNum() + "/" + getDen() + " equals " + getDecimal());
System.out.println();
}
private void getGCF(int n1,int n2)
{
int rem = 0;
do
{
rem = n1 % n2;
if (rem == 0)
gcf = n2;
else
{
n1 = n2;
n2 = rem;
}
}
while (rem != 0);
}
}