Question

In: Computer Science

Make a Console application Language should be Visual Basic You will be simulating an ATM machine...

Make a Console application

Language should be Visual Basic

You will be simulating an ATM machine as much as possible

Pretend you have an initial deposit of 1000.00. You will

Prompt the user with a Main menu:

Enter 1 to deposit

Enter 2 to Withdraw

Enter 3 to Print Balance

Enter 4 to quit

When the user enters 1 in the main menu, your program will prompt the user to enter the deposit amount.

If the user enter more than 2000, Print "Deposit of more than $2000 is not allowed" and

Prompt the user with a SubMenu:

Enter 1 for the Main Menu. If user enters 1, display the main menu

Enter 0 to quit. If user enter 0, exit the application

if the user enters less than 2000,

Print "Deposit Transaction Successful" and

Add the amount to the Balance

Prompt the user with a SubMenu:

Enter 1 for the Main Menu. If user enters 1, display the main menu

Enter 0 to quit. If user enter 0, exit the application

When the user enters 2 in the main menu, your program will prompt the user to enter a withdraw amount.

If the user enter more than 200, Print "Withdrawing more than $200 is not allowed

Prompt the user with a SubMenu:

Enter 1 for the Main Menu. If user enters 1, display the main menu

Enter 0 to quit. If user enter 0, exit the application

If the user enter less than 200, Print "Withdraw Transaction Successful."

deduct the amount from the Balance

Prompt the user with a SubMenu:

Enter 1 for the Main Menu. If user enters 1, display the main menu

Enter 0 to quit. If user enter 0, exit the application

When the user enters 3 in the main menu, print the balance as "Your Current Balance = "

Prompt the user with a SubMenu:

Enter 1 for the Main Menu. If user enters 1, display the main menu

Enter 0 to quit. If user enter 0, exit the application

When the user enters 4 in the main menu, exit the application

When the user enters other than 1-4, print "Invalid Transaction Requested"

Here is the output of my program, with user entered numbers highlighted in yellow

Enter 1 for Deposit
Enter 2 for Withdraw
Enter 3 for Print Balance
Enter 4 for Quit
1
Enter the amount to Deposit
3000
Deposit More than $2000 is not allowed
Enter 1 to Main Menu
Enter 2 to Quit
1
Enter 1 for Deposit
Enter 2 for Withdraw
Enter 3 for Print Balance
Enter 4 for Quit
1
Enter the amount to Deposit
1999
Deposit Transaction successful
Enter 1 to Main Menu
Enter 2 to Quit
1
Enter 1 for Deposit
Enter 2 for Withdraw
Enter 3 for Print Balance
Enter 4 for Quit

3
Your Current Balance =2999
Enter 1 to Main Menu
Enter 2 to Quit
1
Enter 1 for Deposit
Enter 2 for Withdraw
Enter 3 for Print Balance
Enter 4 for Quit
2
Enter the amount to Withdraw
250
Withdrawing More than $200 is not allowed
Enter 1 to Main Menu
Enter 2 to Quit
1
Enter 1 for Deposit
Enter 2 for Withdraw
Enter 3 for Print Balance
Enter 4 for Quit
2
Enter the amount to Withdraw
150
Withdraw Transaction successful
Enter 1 to Main Menu
Enter 2 to Quit

1
Enter 1 for Deposit
Enter 2 for Withdraw
Enter 3 for Print Balance
Enter 4 for Quit
3
Your Current Balance =2849
Enter 1 to Main Menu
Enter 2 to Quit
1
Enter 1 for Deposit
Enter 2 for Withdraw
Enter 3 for Print Balance
Enter 4 for Quit

5
Invalid Transaction requested
Enter 1 to Main Menu
Enter 2 to Quit
1
Enter 1 for Deposit
Enter 2 for Withdraw
Enter 3 for Print Balance
Enter 4 for Quit

4

You should test for the same output as mine. Upload the VB script and screenshot of your application.

Solutions

Expert Solution

Short Summary:

  • Created a console application using VB and shown you the required output.
  • Created a class called ATM which handles deposit and withdraw methods
  • The test driver interacts with user and gets user’s input.
  • Provided inline comments appropriately to explain the program flow

**************Please upvote the answer and appreciate our time.************

**************************************************************************************************************

Source Code:

ATM.vb File:

Public Class ATM

    ' Private attribute

    Private balance As Double

    Private Const MAX_DEPOSIT As Integer = 2000

    Private Const MAX_WITHDRAW As Integer = 200

    ' Constructor

    Public Sub New(initialbalance As Double)

        Me.balance = initialbalance

    End Sub

    ' Reuturns current balance

    Public Function GetBalance() As Double

        Return balance

    End Function

    ' Depost amount to account, if amount is valid

    Public Sub Deposit(amount As Double)

        ' Validate if valid amount

        If amount <= 0 Then

            Console.WriteLine("Invalid amount, should be greater than 0")

        ElseIf amount > MAX_DEPOSIT Then

            Console.WriteLine("Deposit of more than " + MAX_DEPOSIT.ToString("c") + " is not allowed")

        Else

            balance += amount

            Console.WriteLine("Deposit Transaction successful")

        End If

    End Sub

    ' Withdraw amount from account, if amount is valid

    Public Sub Withdraw(amount As Double)

        ' Validate if valid amount

        If amount <= 0 Then

            Console.WriteLine("Invalid amount, should be greater than 0")

        ElseIf amount > MAX_WITHDRAW Then

            Console.WriteLine("Withdrawing more than " + MAX_WITHDRAW.ToString("c") + " is not allowed")

        ElseIf amount > balance Then

            Console.WriteLine("Insufficient balance!")

        Else

            balance -= amount

            Console.WriteLine("Withdraw Transaction Successful.")

        End If

    End Sub

End Class

**************************************************************************************************************

TestDriver

Module Module1

    Sub Main()

        'Pretend you have an initial deposit of 1000.00. You will

        Dim atm As ATM = New ATM(1000)

        'Prompt the user with a Main menu

        Dim displayMenu As Boolean = True

        Dim choice As Integer

        Dim amount As Double

        Do While displayMenu

            ' get user choice

            choice = GetUserMainChoice()

            Select Case choice

                ' Deposit

                Case 1

                    Console.WriteLine("Enter the amount to Deposit")

                    amount = GetAmount()

                    ' Call deposit method

                    atm.Deposit(amount)

                    displayMenu = GetSubMenuChoice()

                ' withdraw

                Case 2

                    Console.WriteLine("Enter the amount to Withdraw")

                    amount = GetAmount()

                    atm.Withdraw(amount)

                    displayMenu = GetSubMenuChoice()

                ' Display balanace

                Case 3

                    Console.WriteLine("Your Current Balance = " + atm.GetBalance().ToString("c"))

                    displayMenu = GetSubMenuChoice()

                ' quit

                Case 4

                    displayMenu = False

                    ' for invalid choice

                Case Else

                    Console.WriteLine("Invalid Transaction Requested")

                    displayMenu = GetSubMenuChoice()

            End Select

        Loop

        Console.ReadKey()

    End Sub

    Public Function GetUserMainChoice() As Integer

        ' Display menu items

        Console.WriteLine("Enter 1 To deposit")

        Console.WriteLine("Enter 2 to Withdraw")

        Console.WriteLine("Enter 3 to Print Balance")

        Console.WriteLine("Enter 4 to quit")

        ' Get user choice

        Dim choice As Integer

        Integer.TryParse(Console.ReadLine(), choice)

        Return choice

    End Function

    Public Function GetSubMenuChoice() As Boolean

        Dim validInput As Boolean = True

        Dim choice As Integer

        Do While validInput

            Console.WriteLine("Enter 1 to Main Menu")

            Console.WriteLine("Enter 2 to Quit")

            ' verify if valid value is entered

            If (Integer.TryParse(Console.ReadLine(), choice) = False Or choice <= 0 Or choice > 2) Then

                Console.WriteLine("Invalid Transaction Requested")

            Else

                ' if valid choice

                Return choice = 1

            End If

        Loop

    End Function

    Public Function GetAmount() As Double

        ' Get user choice

        Dim choice As Double

        Double.TryParse(Console.ReadLine(), choice)

        Return choice

    End Function

End Module

**************************************************************************************************************

Sample Run:

**************************************************************************************

Feel free to rate the answer and comment your questions, if you have any.

Please upvote the answer and appreciate our time.

Happy Studying!!!

**************************************************************************************


Related Solutions

Make a Console application Language should be Visual Basic In this assignment, you will be calculating...
Make a Console application Language should be Visual Basic In this assignment, you will be calculating the two parts for each month. you calculate the interest to pay each month and principal you pay every month. The interest you pay every month = loan * monthlyInterest The principal you pay every month = monthlyMortgage -  interest you pay every month ' what is my remaining loan loan = loan - principal you pay every month Problem 1 : Using While Loop,...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
Use Visual Basic Language In this assignment you will need to create a program that will...
Use Visual Basic Language In this assignment you will need to create a program that will have both a “for statement” and an “if statement”. Your program will read 2 numbers from the input screen and it will determine which is the larger of the 2 numbers. It will do this 10 times. It will also keep track of both the largest and smallest numbers throughout the entire 10 times through the loop. An example of the program would be...
What factors should you consider when choosing between a console application and a GUI application?
What factors should you consider when choosing between a console application and a GUI application?
write a small visual basic console program to output the ages of three students
write a small visual basic console program to output the ages of three students
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax...
windows forms Application using Visual Basic use visual basic 2012 Part 1: Programming – Income Tax Application 1.1 Problem Statement Due to upcoming end of financial year, you are being called in to write a program which will read in a file and produce reports as outlined. Inputs: The input file called IncomeRecord.txt contains a list of Annual income records of employees in a firm. Each record is on a single line and the fields are separated by spaces. The...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that serves as a healthcare billing management system. This application is a multiform project (Chapter 9) with three buttons. The "All Accounts" button allows the user to see all the account information for each patient which is stored in an array of class type objects (Chapter 9, section 9.4).The "Charge Service" button calls the Debit method which charges the selected service to the patient's account...
Use Visual Basic Language In this assignment,you will create the following data file in Notepad: 25...
Use Visual Basic Language In this assignment,you will create the following data file in Notepad: 25 5 1 7 10 21 34 67 29 30 You will call it assignment4.dat and save it in c:\data\lastname\assignment4\. Where lastname is your last name. The assignment will be a console application that will prompt the user for a number. Ex. Console.Write(“Enter a number: ”) And then read in the number Ex. Number = Console.ReadLine() You will then read the data file using a...
Language: c++ using visual basic Write a program to open a text file that you created,...
Language: c++ using visual basic Write a program to open a text file that you created, read the file into arrays, sort the data by price (low to high), by box number (low to high), search for a price of a specific box number and create a reorder report. The reorder report should alert purchasing to order boxes whose inventory falls below 100. Sort the reorder report from high to low. Inventory data to input. Box number Number boxes in...
Write a java console application,. It simulates the vending machine and ask two questions. When you...
Write a java console application,. It simulates the vending machine and ask two questions. When you run your code, it will do following: Computer output: What item you want? User input: Soda If user input is Soda Computer output: How many cans do you want? User input:            3 Computer output: Please pay $3.00. END The vending machine has 3 items for sale: Soda the price is $1.50/can. Computer should ask “How many cans do you want?” Chips, the price is $1.20/bag....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT