Machine Problem
Create and design a program that simulates an Automatic Teller Machine. The money bill to be used in the program will be 1000,500,200 and 100 money bill denomination.
I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me at the following email address for further details. If you want to advertise on my website kindly contact me also in my email address also. Thank you.
My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.
My mobile number here in the Philippines is 09173084360.
Please subscribe to my channel https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg
=================================================
Want to support my channel?
GCash Account
Jake Pomperada
09173084360
Paypal
https://paypal.me/jakerpomperada
Patreon
https://www.patreon.com/jakerpomperada
Thank you very much for your support.
Program Listing
/* atm.scala
Prof. Jake Rodriguez Pomperada, MAED-IT, MIT
www.jakerpomperada.blogspot.com and www.jakerpomperada.com
jakerpomperada@gmail.com
January 8, 2022 7:58 PM Saturday
Bacolod City, Negros Occidental
*/
import java.util.Scanner;
object atm {
def main(args: Array[String]) : Unit = {
var scanner = new Scanner(System.in);
var bill1000=0; var bill500=0; var bill200=0; var bill100=0;
var total_balance=0; var withdraw=0; var money_left=0;
var receive1000=0; var receive500=0; var receive200=0; var receive100=0;
var withdraw_again='n';
do
{
print("\n");
print("\tAutomatic Teller Machine Simulation in Scala");
print("\n\n");
print("\tHow many P1000 bills: ");
bill1000 = scanner.nextInt();
print("\tHow many P500 bills: ");
bill500 = scanner.nextInt();
print("\tHow many PHP 200 bills: ");
bill200 = scanner.nextInt();
print("\tHow many PHP 100 bills: ");
bill100 = scanner.nextInt();
total_balance = (bill1000 * 1000)+(bill500 * 500) + (bill200 * 200) + (bill100 * 100) ;
print("\n\n");
print("\tTotal Balance: PHP " + total_balance);
print("\n\n");
print("\tEnter amount to withdraw: PHP ");
withdraw = scanner.nextInt();
money_left = withdraw ;
if (withdraw > total_balance)
{
print("\tWithdraw amount greater than total balance. ");
print("\n");
}
if (withdraw < total_balance)
{
if (money_left >= 1000 )
{
receive1000 = (money_left / 1000);
if (receive1000 > bill1000 ) receive1000 = bill1000;
money_left = money_left - (receive1000 * 1000);
bill1000 = bill1000 - receive1000;
}
if (money_left >= 500 )
{
receive500 = (money_left / 500);
if (receive500 > bill500 ) receive500 = bill500;
money_left = money_left - (receive500 * 500);
bill500 = bill500 - receive500;
}
if (money_left >= 200 )
{
receive200 = (money_left / 200);
if (receive200 > bill200 ) receive200 = bill200;
money_left = money_left - (receive200 * 200);
bill200 = bill200 - receive200;
}
if (money_left >= 100 )
{
receive100 =(money_left / 100);
if (receive100 > bill100 ) receive100 = bill100;
money_left = money_left - (receive100 * 100);
bill100 = bill100 - receive100;
}
print("\n\n");
print("\tYou will receive:");
print("\n\n");
print("\tPHP 1000 bill :=> " + receive1000);
print("\n");
print("\tPHP 500 bill :=> " + receive500);
print("\n");
print("\tPHP 200 bill :=> " + receive200);
print("\n");
print("\tPHP 100 bill :=> " + receive100);
print("\n\n");
total_balance = total_balance - withdraw;
print("\tYour current balance is: PHP " + total_balance);
print("\n\n");
print("\tYou only have balance of:");
print("\n\n");
print("\tPHP 1000 bill :=> " + bill1000);
print("\n");
print("\tPHP 500 bill :=> " + bill500);
print("\n");
print("\tPHP 200 bill :=> " + bill200);
print("\n");
print("\tPHP 100 bill :=> " + bill100)
print("\n\n");
printf("\tAnother Withdraw Again ? Y/N : ");
withdraw_again = scala.io.StdIn.readChar()
}
} while (withdraw_again.toUpper == 'Y');
print("\n");
print("\tEnd of Program");
print("\n\n");
}
}