SireChristoff
New member
- Joined
- Jan 13, 2021
- Messages
- 1
- Programming Experience
- Beginner
Hello guys, I've been looking for some help on this matter for quite a while now. I'm fairly new to c# and have thrown together this simple menu system for a bank application.
Now, I'm not 100% on how I'd go about doing this, so was wondering if I could get some heads up or a point in the right direction for both issues.
Now, I'm looking at adding an input before the menu appears that allows the user to input their name first, and adding an overdraft that would take funds from the variable when the value of 'myBalance' would get depleted. I've tried looking around and can't find anything too solid on how to add such. I assume it would fall under another if statement but not too sure.
Apologies if this was posted in the wrong thread, I coulden't find a general assistance thread.
Here's what I have so far.
CodePile | Easily Share Piles of Code
Thanks in advance.
SireChristoff
Now, I'm not 100% on how I'd go about doing this, so was wondering if I could get some heads up or a point in the right direction for both issues.
Now, I'm looking at adding an input before the menu appears that allows the user to input their name first, and adding an overdraft that would take funds from the variable when the value of 'myBalance' would get depleted. I've tried looking around and can't find anything too solid on how to add such. I assume it would fall under another if statement but not too sure.
Apologies if this was posted in the wrong thread, I coulden't find a general assistance thread.
Here's what I have so far.
CodePile | Easily Share Piles of Code
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyBankAccount
{
class BankAccount
{
static void DisplayBankBal(double myBal)
{
Console.WriteLine("Your current bank balance is: £" + myBal); ;
}
static double Deposit(double myBal)
{
Console.WriteLine("How much would you like to deposit?");
double newDepo = Convert.ToDouble(Console.ReadLine());
double newBal = myBal + newDepo;
return (newBal);
}
static double Withdraw(double myBal)
{
Console.WriteLine("How much would you like to withdraw?"); // Ask user for a deposit
double newDepo = Convert.ToDouble(Console.ReadLine()); // Accept input as deposit
double newBal = myBal - newDepo; // add deposit to current balance
return (newBal);
}
static double Overdraft(double myBal)
{
Console.WriteLine("Would you like to withdraw from overdraft?");
double newDepo = Convert.ToDouble(Console.ReadLine());
double newBal = myBal - newDepo;
return (newBal);
}
// ----------------------- Main
public string username { get; set; }
public class BankMenu
{
static void Main(string[] args)
{
double myBalance = 466.55;
int MenuOpt = 0;
string customerName = "User 12345 ";
string accountNumber = "123456";
double myDraft = 50.00;
//Console Options
do
{
Console.WriteLine("Hello " + customerName + "Account-number: " + accountNumber);
Console.WriteLine("1. View Balance");
Console.WriteLine("2. Make a Deposit");
Console.WriteLine("3. Withdraw Money");
Console.WriteLine("4. View Overdraft");
Console.WriteLine("5. Exit Program");
//Menu function here
MenuOpt = Convert.ToInt32(Console.ReadLine());
if (MenuOpt == 1)
{
DisplayBankBal(myBalance);
}
else if (MenuOpt == 2)
{
double newBal = Deposit(myBalance);
Console.WriteLine("Your new balance is " + newBal);
myBalance = newBal;
}
else if (MenuOpt == 3)
{
double newBal = Withdraw(myBalance);
Console.WriteLine("Your new balance is " + newBal);
myBalance = newBal;
}
else if (MenuOpt == 4)
{
Console.WriteLine("Your remaining overdraft is £" + myDraft);
}
else Console.WriteLine("Invalid Option");
} while (MenuOpt != 5);
}
}
}
Thanks in advance.
SireChristoff
Last edited by a moderator: