In: Computer Science
Make a Program in Visual Studio / Console App (.NET
Framework)
# language 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
input code:
output:
code:
Imports System.Console
Module VBModule
Sub Main()
' initialize the variables
Dim ch1 as Integer
Dim ch2 as Integer
Dim amount as Integer
ch1=0
ch2=1
amount=1000
do
'print menu
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")
'take user input
ch1=Console.ReadLine()
select case ch1
case 1
'for Deposit
'take amount input
Console.WriteLine("Enter the amount to Deposit")
Dim deposit as Integer
deposit=Console.ReadLine()
if deposit>2000 then
'print this if amount >2000
Console.WriteLine("Deposit More than $2000 is not allowed")
else
'else update amount and print successful
amount=amount+deposit
Console.WriteLine("Deposit Transaction successful")
end if
case 2
'for Withdraw
'take user input
Console.WriteLine("Enter the amount to Withdraw")
Dim Withdraw as Integer
withdraw=Console.ReadLine()
if withdraw>200 then
'print this is greater than >200
Console.WriteLine("Withdrawing More than $200 is not
allowed")
else
'else print this
if amount-withdraw>0 then
'if Withdraw don't go amount<0 than print this
amount=amount-withdraw
Console.WriteLine("Withdraw Transaction successful")
else
Console.WriteLine("Not Enough Money for Withdraw")
end if
end if
case 3
'print Balance
Console.WriteLine("Your Current Balance ={0}",amount)
case 4
'terinate the program
System. Environment. Exit(0)
case else
'print Invalid Transaction
Console.WriteLine("Invalid Transaction Requested")
end select
'print sub menu
Console.WriteLine("Enter 1 for Main Menu")
Console.WriteLine("Enter 2 for Quit")
'take user input
ch2=Console.ReadLine()
loop while ch2=1
End Sub
End Module