Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Lab09avstHW
  4. {
  5. static int num, den; // numerator and denominator of the rational number
  6. public static void main (String[] args)
  7. {
  8. enterData();
  9. Rational r = new Rational(num,den);
  10. r.displayData();
  11. }
  12.  
  13. public static void enterData()
  14. {
  15. Scanner input = new Scanner(System.in);
  16. System.out.print("\nEnter the numerator -----> ");
  17. num = input.nextInt();
  18. System.out.print("\nEnter the denominator ----> ");
  19. den = input.nextInt();
  20. }
  21. }
  22.  
  23. class Rational
  24. {
  25. public void displayData()
  26. {
  27. System.out.println();
  28. System.out.println(getNum() + "/" + getDen() + " equals " + getDecimal());
  29. System.out.println();
  30. }
  31.  
  32. private void getGCF(int n1, int n2)
  33. {
  34. int rem = 0;
  35. do
  36. {
  37. rem = n1 % n2;
  38. if (rem == 0)
  39. gcf = n2;
  40. else
  41. {
  42. n1 = n2;
  43. n2 = rem;
  44. }
  45. }
  46. while (rem != 0);
  47. }
  48.  
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement