So I'am making a basic banking program in c++ and have a deposit function that accepts a double, so i want to handle input from the user for a double that is valid as money so to 2 decimal places and not less than 0.
What is the best way to go about this? I have this so far, is there anything else I need to check for money validation or anything that can be done in less lines of code? thanks
// allow user to deposit funds into an account
            try{
                double amount = std::stoi(userInput); // userInput is a string
                if (amount < 0)
                {
                    throw std::invalid_argument("Amount cannot be negative");
                }
                // call function to deposit
                std::cout << "You have deposited " << amount << " into your account." << std::endl;
            }
            catch(std::invalid_argument){
                std::cout << "Invalid input." << std::endl;
            }
 
     
    