Okay, so our professor gave us a homework about switches and hinted us to use modulus "%". So I came up with the following formula, I checked it and it works but I noticed that I'm lacking the formula for the 11-19 digits. I'm having a hard time thinking for the formula or did I do something wrong on some part? Thanks!
EDIT: Also, it exceeds 3000 (ex: 3001) which isn't supposed to be.
Yes, because I'm currently trying out something when I posted it.. I'm confused with what to do. XD
EDIT: I'm thinking that it should read the last two digits for the numbers 10-19.
Because currently, it reads one by one digits. If another switch can read the last two digits and have cases for it then it should be fixed. The problem is how do I get it read the last two digits?
Tried something like this but doesn't work properly.
1 2 3 4
switch ((tens)&&(ones)){
case ((1)&&(1)):
cout<<"Eleven ";
break;
I remembered our prof told us that possible minimum switches would be 5.
So I guest that I'm on the right way and just lacking the switch for the cases of 10-19.
Correct me if I'm wrong but I thought that putting:
1 2 3
default:
// .. do normal tens and ones here
}
Wouldn't help, why? because it still reads only ONE digit: 1211
What I need is to make a new switch that will read the last two digits: 1211
So it would be able to sort it if it's in the range of 10-19
Finally our prof allows us to use if/else. I managed to solve the 11-19 problem but if I input a digit like 2345, the output is only "Two Thousand Three Hundred".
It doesn't read the last two digits for some cases