/*OridinalForm.java
* ----------------
* This program displays the the number with their suffix.
*/
import acm.program.*;
public class OridinalForm extends ConsoleProgram {
private static final long serialVersionUID = 1L;
public void run(){
while(true){
int no=readInt("Please enter the numberand press 0 to stop:");
if(no==0){
break;
}
println(oridinalForm(no));
}
}
private String oridinalForm(int nos){
String result="";
switch(nos){
case '1':result=nos+"1st";
case '2':result=nos+"2nd";
case '3':result=nos+"3rd";
default:
1 if(nos.charAt(nos.length()-1)=1){
result=nos+"1st";
}
2 if(nos.charAt(nos.length()-1)=2){
result=nos+"2nd";
}
3 if(nos.charAt(nos.length()-1)=3){
result=nos+"3rd";
}
else result=nos+"th";
}
return result;
}
}
the code is to explain the result for the no with different conditions. The error is on line:1,2,3. PLease explain me the debugging method. Im little unknown about that method.