I'm looking to clean up some already-functioning code I have. First of all, this is for an assignment and the assignment specifies ints must be taken as ints, doubles as doubles, etc, otherwise I might just take the input as a double and cast as an int `if(number%1==0)`.

I've trimmed the code down to just handling the input (with an output statement to verify it's working properly).

```
int wholePart=0;
double decimalPart=0;
cout << "Input a number: ";
cin >> wholePart;
if(cin.peek() != '\n')
    cin >> decimalPart;

cout << "wholePart = " << wholePart << endl << "decimalPart = " << decimalPart << endl;

```

Now... this works as is, and after I add the code to handle combining the integer and decimal if the decimalPart isn't 0, then I've already done more than the assignment calls for, but I'm looking to learn, and I want to clean this code up as much as possible.

I can wrap the whole input section with other input validation to be sure the user is actually entering numbers and not characters. But my primary concern here is that `if(cin.peek() != '\n')` isn't good enough. Perhaps `if(cin.peek() == '.')` is a better option, but I'm curious what would be the best way of going about accomplishing what I'm trying to accomplish here. Any ideas?

And please don't just turn this down as "oh it's homework." I want to emphasize that my program already goes above and beyond what even the extra credit part of the homework asks for. I'm just trying to learn more about the language and what the best way for handling this sort of input might be.