So I am trying to pass in one variable, the money variable, and break it into two variables. I am stuck and trying to figure out how to pass back two values when I only passed in one. I am supposed to get a double value of money from the user and split it into two int values. So for example I get a value like 3.45 and split it up and print out the message, "There is 3 dollars and 45 cents in $3.45". I understand pass by reference, but I am just trying to figure out like I said how to get two variables back. And I can ONLY pass in the money variable to the method I know my program is not right. Just looking for some ideas and explanations on how to do this. Thanks
using System;
static class Program
{
//Declare any constansts
const int ONE_HUNDRED = 100;
static void Main()
{
//Declare local variables
double money = 0;
//Ask the user to input a money value
Console.WriteLine("Please enter a money value. (ex. 2.95)");
//Store the value in a variable
money = double.Parse(Console.ReadLine());
//Take the variable and call the SplitMoney method
SplitMoney(ref money);
//Display the message
Console.WriteLine("There are {0:d} and {1:d} cents in ${0:f2}", money, dollars cents);
Console.ReadLine();
}//End Main()
//Split Money Method
//Purpose: To split the money into dollars and cents
//Parameters: One double passed by reference
//Returns: Nothing
static void SplitMoney(ref double money)
{
money = (int)(money * ONE_HUNDRED);
int dollars = (int)(money / ONE_HUNDRED);
int cents = (int)(money % ONE_HUNDRED);
}
}//End class Program