the bottom line is really what I am needing help with I thought that I could use a wildcard to make the program recognize that any number with a decimal (.1 through .9 is not a whole number). Any help is much appreciated.
Thanks aruawons. I just switched my couts and voila. Would you mind explaining what exactly that predicate does (break it down for me) please. Much appreciated!
Since i is originally a double, (int)i (called "type casting") converts it to an int by truncating all the decimal part. If a number retains its value after such a truncation, it gotta be a whole number.
I think it just clicked by putting i == (int)i is sort of "redeclaring" i as an integer and the == is telling the program that double i is the same as int i. ok thanks again aruawons.
I think it just clicked by putting i == (int)i is sort of "redeclaring" i as an integer and the == is telling the program that double i is the same as int i.
No, not at all. That's a complete misunderstanding.
(int)i gives an int value. Not i. It does not give you i. i is some other variable. (int)i gives you a temporary variable, which will be an integer - it will be whatever integer you would get if you converted the double i into an int, because that's exactly what it does. Takes the double value i and creates a new int based on that value.
== is telling the program that double i is the same as int i.
No, it is not.
== asks the program if the value on the left is identical to the value on the right. It in no way tells the program that something is the same as something else. That is the complete opposite; it asks if something is the same as something else.