Question

Write a program which asks the user to open a bank account either Current or Savings....

Write a program which asks the user to open a bank account either Current or Savings. Your program will display the following menu at the start: Press 1 for Current Account Press 2 for Savings Account On the selection of account type, the user will open an account by providing an initial amount. In current account the initial amount for opening an account would be 2000 and for savings it would be 5000. After choosing the account type and opening the account with initial amount, your program will display the following menu: Press a for Deposit the money Press b for withdrawing the money 82 In current account the user cannot withdraw more than 10000 rupees. In Savings account the user cannot withdraw more than 25000. When the user withdraws amount make sure that amount should not be more than the balance in account and at the end of withdrawal transaction, there should be minimum of 500 rupees for each account. PLEASE HELP ME SOLVE THIS .

Homework Answers

Answer #1

Hi,

Code has bee written in the C# Console Application and below are the code details with working output screenshots:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BankAccount
{
    class Program
    {
        static void Main(string[] args)
        {
            ProcessInitalProcess();

        }

        public static void ProcessInitalProcess()
        {
            int iAccountType;
            bool bValue;
            long iInnitilAmount = 0;

            try
            {
                Console.WriteLine("Press 1 for Current Account Press 2 for Savings Account");
                bValue = int.TryParse((Console.ReadLine()), out iAccountType);

                if (iAccountType == 1)
                {
                    //Current Account
                    iInnitilAmount = 2000;
                }
                else if (iAccountType == 2)
                {
                    //Savings Account
                    iInnitilAmount = 5000;
                }
                else
                {
                    //Invalid Account Type
                    Console.WriteLine("nvalid Account Type");
                    ProcessInitalProcess();
                }

                //Call trnasaction process
                ProcessTransaction(iAccountType, iInnitilAmount);
            }
            catch (Exception ex) { throw ex; }
        }

        /// <summary>
        /// PRocess Tansaction
        /// </summary>
        /// <param name="iAccountType"></param>
        /// <param name="iInnitilAmount"></param>
        public static void ProcessTransaction(int iAccountType, long iInnitilAmount)
        {
            try
            {
                string strTransType = string.Empty;
                Console.WriteLine("Press a for Deposit the money Press b for withdrawing the money");
                strTransType = Console.ReadLine();

                ///This is for Current Account
                if (iAccountType == 1)
                {
                    long lAmountToWidthdra = 0;
                    long lAmountToDeposite = 0;

                    ///This is for Current Account with Deposite
                    if (strTransType == "a")
                    {
                        Console.WriteLine("Enter Amount to Deposite");
                        lAmountToDeposite = Convert.ToInt64(Console.ReadLine());
                        iInnitilAmount += lAmountToDeposite;
                    }
                    ///This is for Current Account with Withdraw
                    else if (strTransType == "b")
                    {
                        Console.WriteLine("Enter Amount to WithDraw");
                        lAmountToWidthdra = Convert.ToInt64(Console.ReadLine());

                        //Check withdraw value shold not > 10000
                        if (lAmountToWidthdra > 10000)
                        {
                            Console.WriteLine("In Current Account the user cannot withdraw more than 10000 rupees");
                        }
                        //Check withdraw value shold not > current amount and balance should be >= 500
                        else if ((lAmountToWidthdra > iInnitilAmount) || ((iInnitilAmount - lAmountToWidthdra) < 500))
                        {
                            Console.WriteLine("Transaction cannot processed. Minimum Balance Amount should not be less than 500 rupees");
                        }
                        else
                        {
                            //Process the Withdra and updat the current amount
                            iInnitilAmount -= lAmountToWidthdra;
                        }

                    }
                }
                ///This is for Savings Account
                else if (iAccountType == 2)
                {
                    long lAmountToWidthdra = 0;
                    long lAmountToDeposite = 0;

                    ///This is for Savings Account with Deposite
                    if (strTransType == "a")
                    {
                        Console.WriteLine("Enter Amount to Deposite");
                        lAmountToDeposite = Convert.ToInt64(Console.ReadLine());
                        iInnitilAmount += lAmountToDeposite;
                    }
                    ///This is for Savings Account with withdraw
                    else if (strTransType == "b")
                    {
                        //Fetch withdraw value
                        Console.WriteLine("Enter Amount to WithDraw");
                        lAmountToWidthdra = Convert.ToInt64(Console.ReadLine());

                        //Check withdraw value shold not > 25000
                        if (lAmountToWidthdra > 25000)
                        {
                            Console.WriteLine("In Savings Account the user cannot withdraw more than 25000 rupees");
                        }
                        //Check withdraw value shold not > current amount and balance should be >= 500
                        else if ((lAmountToWidthdra > iInnitilAmount) || ((iInnitilAmount - lAmountToWidthdra) < 500))
                        {
                            Console.WriteLine("Transaction cannot processed. Minimum Balance Amount should not be less than 500 rupees");
                        }
                        else
                        {
                            //Process the Withdra and updat the current amount
                            iInnitilAmount -= lAmountToWidthdra;
                        }

                    }
                }

                //Display current balance
                Console.WriteLine("Total Amount in Account is - " + iInnitilAmount);

                //Ask user to process or exit
                Console.WriteLine("Press 1 for Continue and Press 0 for exit");
                int iContinueOrExit = Convert.ToInt32(Console.ReadLine());
                if (iContinueOrExit == 1)
                {
                    //Continue again
                    ProcessTransaction(iAccountType, iInnitilAmount);
                }
                else // exit
                    System.Environment.Exit(0);
            }
            catch (Exception ex) { throw ex; }
        }
    }
}

Thanks.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write most basic C++ program possible that calculates monthly savings account balance. Program will prompt user...
Write most basic C++ program possible that calculates monthly savings account balance. Program will prompt user to enter initial account balance, annual percentage rate, amount deposited each month, and total number of months. Validate user inputs allowing only positive numbers. B = initial account balance A = amount deposited each month R = annual percentage rate Total Balance = (R/12+1)B+A
Write a program to simulate a bank transaction. There are two bank accounts: checking and savings....
Write a program to simulate a bank transaction. There are two bank accounts: checking and savings. First, ask for the initial balances of the bank accounts; reject negative balances. Then ask for the transactions; options are deposit, withdrawal, and transfer. Then ask for the account; options are checking and savings. Then ask for the amount; reject transactions that overdraw an account. At the end, print the balances of both accounts.
Create a Software Application for XYZ Bank that allows its members to access their bank account...
Create a Software Application for XYZ Bank that allows its members to access their bank account information through an “ATM like” interface. The Menu Options should include: checking the account balance, debiting the account and crediting the account, along with an option to exit the program. Create an Account Class to represent the customers’ bank accounts. Include a data member of type float to represent the account balance. Provide a constructor that receives an initial balance and uses it to...
In .java Write a program that simulates 2 bank transactions. The user will enter: the original...
In .java Write a program that simulates 2 bank transactions. The user will enter: the original amount in the bank, the money for transaction 1 and the money for transaction. If a transaction has a negative number it means that money was removed from bank (an withdrawal). If a transaction has a positive number it means that money was deposited in the bank. Hint: if you add a negative number you are effectively subtracting. E.g. 100 + (-10) = 90....
Java Programing 1 - 24206-CSC325-0 Project 3 Date Due: 2/28/2020 Bank Account – Part 2 Modify...
Java Programing 1 - 24206-CSC325-0 Project 3 Date Due: 2/28/2020 Bank Account – Part 2 Modify the Bank Account class you created to have the following additional functionality When the object is created, it should create two types of account Checking and Saving ( you can user Boolean variables to identify between these accounts) Initialize balance on both accounts to $0 The constructor calls a method called setAccountPassWord() setAccountPassWord () This method asks the user to enter a pin number....
You will write a program that loops until the user selects 0 to exit. In the...
You will write a program that loops until the user selects 0 to exit. In the loop the user interactively selects a menu choice to compress or decompress a file. There are three menu options: Option 0: allows the user to exit the program. Option 1: allows the user to compress the specified input file and store the result in an output file. Option 2: allows the user to decompress the specified input file and store the result in an...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that...
a. Define the class bankAccount to store a bank customer’s account number and balance. Suppose that account number is of type int, and balance is of type double. Your class should, at least, provide the following operations: set the account number, retrieve the account number, retrieve the balance, deposit and withdraw money, and print account information. Add appropriate constructors. b. Every bank offers a checking account. Derive the class checkingAccount from the class bankAccount (designed in part (a)). This class...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
C# Step 1: Create a Windows Forms Application. Step 2: Create a BankAccount class. Include: Private...
C# Step 1: Create a Windows Forms Application. Step 2: Create a BankAccount class. Include: Private data fields to store the account holder's name and the account balance A constructor with 0 arguments A constructor with 1 argument (account holder's name) A constructor with 2 arguments(account holder's name and account balance) Public properties for the account holder's name and the account balance. Do not use auto-implemented properties. A method to increase the balance (deposit) A method to decrease the balance...
Write a program reverse-order.cpp which asks the user to input two dates (earlier date then later...
Write a program reverse-order.cpp which asks the user to input two dates (earlier date then later date). The program should report the West basin elevationfor all days in the interval in the reverse chronological order (from the later date to the earlier). Example: $ ./reverse-order Enter earlier date: 05/29/2018 Enter later date: 06/02/2018 06/02/2018 590.22 ft 06/01/2018 590.23 ft 05/31/2018 590.24 ft 05/30/2018 590.26 ft 05/29/2018 590.32 ft Hint: If for the previous tasks you did not use arrays, here...