You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Explanation: The fraction 0/5 is a proper fraction because the absolute value of numerator (0) is less than the denominator (5).
76
76
constzeroNumerator=isProperFraction(0,5);
77
77
assertEquals(zeroNumerator,true);
78
+
78
79
// Stretch 3: zero denominator - this is mathematically undefined but we can decide how we want to handle it
80
+
// Input: numerator = 5, denominator = 0
81
+
// target output: false
82
+
// Explanation: The fraction 5/0 is undefined in mathematics. In this implementation, we choose to return false.
79
83
constzeroDenominator=isProperFraction(5,0);
80
84
assertEquals(zeroDenominator,false);
85
+
81
86
// Stretch 4: both zero
87
+
// Input: numerator = 0, denominator = 0
88
+
// target output: false
89
+
// Explanation: The fraction 0/0 is indeterminate in mathematics. In this implementation, we choose to return false.
82
90
constbothZero=isProperFraction(0,0);
83
91
assertEquals(bothZero,false);
92
+
84
93
// Stretch 5: negative numerator and denominator
94
+
// Input: numerator = -3, denominator = -5
95
+
// target output: true
96
+
// Explanation: The fraction -3/-5 is a proper fraction because the absolute value of the numerator (3) is less than the absolute value of the denominator (5). The function should return true.
// Stretch 6: improper negative numerator and denominator
101
+
// Input: numerator = -3, denominator = -2
102
+
// target output: false
103
+
// Explanation: The fraction -3/-2 is an improper fraction because the absolute value of the numerator (3) is greater than the absolute value of the denominator (2). The function should return false.
// Explanation: The fraction 2.5/3.5 is a proper fraction because the absolute value of the numerator (2.5) is less than the absolute value of the denominator (3.5). The function should return true.
91
111
constdecimalValues=isProperFraction(2.5,3.5);
92
112
assertEquals(decimalValues,true);
113
+
93
114
// Stretch 8: improper decimal values
115
+
// Input: numerator = 3.5, denominator = 2.5
116
+
// target output: false
117
+
// Explanation: The fraction 3.5/2.5 is an improper fraction because the absolute value of the numerator (3.5) is greater than the absolute value of the denominator (2.5). The function should return false.
0 commit comments