I have just started learning C# so am pretty new… I am trying to write the method for Check balance but keep getting the error i said in the title… i know the code is not finished but just wanted to be able to return the Account Types menu for the moment??
Also is someone able to explain the line “static void start(ref bool dimensionsUpdated)” I don’t really know what this does. Thankyou!!
class Program
{
static void start(ref bool dimensionsUpdated){
int userOption = 0;
//Repeats the loop until the user wishes to exit
do
{
Console.WriteLine("Welcome to EziTeller ATM Machine\n\n");
Console.WriteLine("Transaction Menu"
+ "\n================\n"
+ "\n1) Check Balance"
+ "\n2) Withdraw"
+ "\n3) Transfer");
Console.WriteLine("\n\nPlease Enter Your Option: 1, 2, 3 or 0 to exit: ");
//Read in the users choice
userOption = int.Parse(Console.ReadLine());
Console.ReadKey();
//Run a series of checks to see what the user chose.
//Open the desired method, otherwise show error message
//Asking the user to input a VALID option.
if (userOption == 0)
{
Console.WriteLine("Thank you for using EziTeller!");
Environment.Exit(0);
}
else if (userOption == 1){
checkBalance(ref dimensionsUpdated);
}
else if (userOption == 2){
withdrawMoney(ref dimensionsUpdated);
}
else if (userOption == 3){
transferMoney(ref dimensionsUpdated);
}
else Console.WriteLine("\n\nPlease enter a valid option, either 1, 2, 3, or 0 to exit\n\n");
} while (userOption != 0);
}
public static double checkBalance(ref bool dimensionsUpdated){
Console.WriteLine("Account Types"
+ "\n============\n"
+ "\n1) Savings Account"
+ "\n2) Debit Card"
+ "\n3) Credit Card"
+ "\n4) Line of Credit");
Console.WriteLine("\n\nPlease Enter Your Option: 1...4 or 0 to exit: ");
That is because your method is returning a
doublevalue and you are not returning anything from your method.Since the complete code is not present in the question, you may post complete code.
May be you are returning a
doublevalues inside anif statement, if so, you need to make sure that any of your method path should return a double value.Or if that is the complete code of your
checkBalancemethod and you are not returning anything from it then you may change the method signature to returnvoid