Moha
Moha
CC#
Created by Moha on 3/2/2025 in #help
Bank code
https://paste.mod.gg/jkuiernhqqgp/0 How can I use a while loop here?
170 replies
CC#
Created by Moha on 3/2/2025 in #help
Bank program help
using System;

class Bank
{
static void Main()
{
Console.WriteLine("Welcome to the bank. Please select one of the given options.");
Console.WriteLine("1. Withdraw money");
Console.WriteLine("2. Deposit money");
Console.WriteLine("3. Check balance");
Console.WriteLine("4. Send money");

int balance = 0;
int option = int.Parse(Console.ReadLine());

while (option >= 5)
{
Console.WriteLine("Please choose a valid option.");
option = int.Parse(Console.ReadLine());
}

if (option == 1)
{
Console.WriteLine("Please write the amount of money you are gonna withdraw.");
int amount = int.Parse(Console.ReadLine());
Console.WriteLine("Withdrawing " + amount + "...");

balance -= amount;

Console.WriteLine("Your new balance is " + balance + ".");
}

if (option == 2)
{
Console.WriteLine("Please write the amount of money you are gonna deposit.");
int amount = int.Parse(Console.ReadLine());
Console.WriteLine("Depositing " + amount + "...");

balance += amount;

Console.WriteLine("Your new balance is " + balance + ".");
}




}
}
using System;

class Bank
{
static void Main()
{
Console.WriteLine("Welcome to the bank. Please select one of the given options.");
Console.WriteLine("1. Withdraw money");
Console.WriteLine("2. Deposit money");
Console.WriteLine("3. Check balance");
Console.WriteLine("4. Send money");

int balance = 0;
int option = int.Parse(Console.ReadLine());

while (option >= 5)
{
Console.WriteLine("Please choose a valid option.");
option = int.Parse(Console.ReadLine());
}

if (option == 1)
{
Console.WriteLine("Please write the amount of money you are gonna withdraw.");
int amount = int.Parse(Console.ReadLine());
Console.WriteLine("Withdrawing " + amount + "...");

balance -= amount;

Console.WriteLine("Your new balance is " + balance + ".");
}

if (option == 2)
{
Console.WriteLine("Please write the amount of money you are gonna deposit.");
int amount = int.Parse(Console.ReadLine());
Console.WriteLine("Depositing " + amount + "...");

balance += amount;

Console.WriteLine("Your new balance is " + balance + ".");
}




}
}
Now here what I'm asking is if I want to do an "Would you like to do any other missions?" Would I put it inside the if or outside the if?
29 replies