Advertisement
wadkat

Fraction

Jun 3rd, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1.  
  2. package Week3;
  3. import java.util.Scanner;
  4. /**
  5. *
  6. * @author wei96
  7. */
  8. public class Fraction {
  9. private int numerator;
  10. private int denominator;
  11. Scanner kb = new Scanner (System.in);
  12. public void inputValues()
  13. {
  14. System.out.println("Enter Numerator");
  15. numerator=kb.nextInt();
  16. System.out.println("Enter Denominator");
  17. denominator=kb.nextInt();
  18. }
  19.  
  20. public void outputValues()
  21. {
  22. System.out.println(numerator+"/"+denominator);
  23. }
  24.  
  25. public int getNumerator ()
  26. {
  27. return numerator;
  28. }
  29.  
  30. public int getDenominator ()
  31. {
  32. return denominator;
  33. }
  34.  
  35. public int setNumerator (int n)
  36. {
  37. numerator = n;
  38. }
  39.  
  40. public int setDenominator (int d)
  41. {
  42. if (d!=0)
  43. denominator = d;
  44. }
  45.  
  46. public boolean isZero ()
  47. {
  48. return (numerator==0);
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement