+ 4

Using switch statement.

Need help on letter b and letter c? Im thinking about using switch case statement a. Proper Fraction – numerator is less than the denominator b. Improper Fraction – numerator is greater than the denominator, but the quotient is a real number (ex: 3.45) c. Whole Number – numerator is greater than the denominator, but the quotient has no decimal part

28th Feb 2019, 11:25 AM
Jefferson Villanueva
Jefferson Villanueva - avatar
8 Answers
+ 17
●please provide with code & give information about variable b & c. ● still by seeing previous comments, hopefully you have got to know that if else is better way to do it, here is rough code : ● if(num<den){ means proper fraction} else{ if(num%den==0){ means whole number} else{ means improper fraction} }
28th Feb 2019, 7:02 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 15
Switch case is used for one variable which may have different values. The problem that you have mentioned involves evaluating calculation results on two variables, which should be coded with if else statements.
28th Feb 2019, 11:41 AM
Gordon
Gordon - avatar
+ 9
I agree with Gordon and Emma .I think a switch statement is not the most efficient way to code your solution. Try using a series of if else statements.
28th Feb 2019, 12:01 PM
Sonic
Sonic - avatar
+ 8
The switch statement gives an alternative to a cascade of if-else constructs: https://code.sololearn.com/ciAHNcOTEBAq/?ref=app https://www.sololearn.com/learn/Java/2145/
1st Mar 2019, 11:43 AM
Danijel Ivanović
Danijel Ivanović - avatar
+ 2
Thanks, guys for the help appreciate it. :)
3rd Mar 2019, 11:04 AM
Jefferson Villanueva
Jefferson Villanueva - avatar
0
Dd
1st Mar 2019, 6:12 AM
Dato Cxovrebadze
Dato Cxovrebadze - avatar
0
Dd
1st Mar 2019, 6:12 AM
Dato Cxovrebadze
Dato Cxovrebadze - avatar
0
Try to fix your code using if else statement.
26th Apr 2019, 10:00 AM
Jaliya Roshen
Jaliya Roshen - avatar