Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help with the below C# code to convert it to Java code console app.Thanks! 1 using System; using System.Collections.Generic; namespace BankProject // class for

Please help with the below C# code to convert it to Java code console app.Thanks!

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

1 using System; using System.Collections.Generic; namespace BankProject // class for Saving account public class SavingsAccount { // members int rate = 1; float balance; bool closed = false; public SavingsAccount(bool closed) this.closed = closed; } int account Number; static int GetAccount Number = 1001; string accountType = "Savings"; // constructor that initialized rate and balance public SavingsAccount(int rt, float balance) rate = rt; this.balance = balance; account Number = GetAccount Number++; } // method to close an account public void closelstring name) { closed = true; Console.WriteLine("Account closed"); Console.WriteLine("Account number:" + account Number); Console.WriteLine("Account holder Name:" + name); Console.WriteLine("Balance:" + balance); Console.WriteLine("Account type:" + accountType); Console.WriteLine("With interest 1 %:"); Console.WriteLine("Interest amount:" +0.01f . balance); } // method to print account informaion public void print(string name) { Console.WriteLine("Account number:" + account Number); Console.WriteLine("Account holder name:" + name); Console.WriteLine("Balance:" + balance); Console.WriteLine("Account type:" + accountType); 2 Console.WriteLine("Interest rate:" + rate: } // getters and setters public int getAccount Number() { return accountNumber; } public string getAccountType() { return accountType; } // method to deposit an amount public void deposit(float amount) { balance += amount; } // method to withdraw an amount public float withdraw(float amount) if (amount > balance) { Console.WriteLine(" Insufficient balance!"); return 0; } return balance -= amount; D // class representing a customer public class Customer { // a list for storing all the accounts List accounts; int numberOfAccount; int ssn; // new member variable name string name; static int uniqueSSN = 1001; // cunstructor public Customer() accounts = new List(); number ofAscount = 0; ssn = unigueSSN++; } //parameterized constructor with name also public Customer(int sen, string name) { accounts = new List(); numberOfAccount = 0; this.ssn = ssn; this.name = name; } // getters and setters public int getSSN() { return ssn; } public string getName() return name; } public void setName(string n) this.name = n; } public ListgetAccounts() [ return accounts; } // method to create saving account public void create Account(int rate, float amount) SavingsAccount account = new SavingsAccount(rate, amount); accounts.Add(account); numberOfAccount += 1; // modified number of accounts incremented by 1 } // method to display account information public void displayAccount() foreach (var account in accounts) 1/pass customer name also to print account information account.print(this.getName()); 3 // class that represents a Bank public class Bank Logic { // list of customers in the bank 4 ListgetCustomers() { return customers; } public void setCustomers(List 7 break; case 6: // withdraw Console.WriteLine("Enter ssn: "); ssn = int.Parse(Console.ReadLine()); customers = Bank.getCustomers(); foreach (var c in customers) { if (c.getSSN() == ssn) { var accounts = c.getAccounts(); Console.WriteLine("Enter account number to withdraw:"); // modified ask for account number in which to withdraw int accNo = int.Parse(Console.ReadLine()); // modified - read the account number Console.WriteLine("Enter withdraw amount: "); float amount = float.Parse(Console.ReadLine()); foreach (var a in accounts) if (a.getAccount Number() == accNo) [ // modified - check if the account number is equal to accNo entered then withdraw a.withdraw(amount); } 3 } break; //to update/change customer's name case 7: Console.Write("Enter customer ssn: "); ssn = int.Parse(Console.ReadLine()); Console.Write("Enter Modified customer name: "); string cname = Console.ReadLine(); List

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Image Databases Towards Advanced Image Retrieval

Authors: Yihong Gong

1st Edition

1461375037, 978-1461375036

More Books

Students also viewed these Databases questions

Question

Discuss consumer-driven health plans.

Answered: 1 week ago