Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Lab09avstHW
- {
- 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);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement