what is the solution for this Java project? DDLS4UDavpid-14446687-dt-content-rid
ID: 3750185 • Letter: W
Question
what is the solution for this Java project?
DDLS4UDavpid-14446687-dt-content-rid-119240044 1/cours Create a project named FA2018 LAB3PART1 yourLastName - add a data type class named Account yourLastName, CheckingAccount_yourLastName and SavingAccount yourlastName (you can re- use the classes from lab2) -add data structure class named Account_UnsortedOptimizedArray -add driver class named Demo_UnsortedOptimizedArray_yourLastName Provide the application that allows users can do the following tasks: 1. Insert One Account 2. Verify uncapsulation of Unsorted Optimized Array 3. Update an account 4. Remove an account 5. Show all accounts 0. Exit TASK1: INSERT -Ask for information of one account. It could be checking account or saving account; insert to the data structure, then check if insert successfully display message box: "Insert Account success" Otherwise display message box "Insert Account failed"Explanation / Answer
package FA2018_LAB3PART2_yourlastname; import java.util.Scanner; public class account_unsortedoptimizedarray { public static void main(String args[]){ Scanner s = new Scanner(System.in); /* Prompting user to input values */ System.out.println("1. insert one account "); System.out.println("2. Verify encapsulation of unsorted optimized array "); System.out.println("3. Update an account "); System.out.println("4. Remove an account"); System.out.println("5. Show all accounts"); System.out.println("6. Exit"); System.out.println("Please select your choice and input your number"); int choice = s.nextInt(); Demo_unsortedoptimizedarray_yourlastname array = new Demo_unsortedoptimizedarray_yourlastname(); switch (choice) { case 1: System.out.println("1. Insert one account "); String account = s.nextLine(); array.insertaccount(account); break; case 2: System.out.println("2. Verify encapsulation of unsorted optimized array "); System.out.println("1. Insert one account "); String account1 = s.nextLine(); array.insertaccount(account1); array.checkencapsulation(123,account1); break; case 3: System.out.println("3. Update an account"); System.out.println("Give index and update value separated by lines"); int index = s.nextInt(); String account2 = s.nextLine(); array.update(index,account2); break; case 4: System.out.println("4. Remove an account"); System.out.println("Give index of the position element to be removed"); int index1 = s.nextInt(); array.remove(index1); break; case 5: System.out.println("5. Show all accounts"); array.showall(); break; case 6: System.out.println("You have entered 6 which is to exit "); System.exit(0); } } } package FA2018_LAB3PART2_yourlastname; public class DataType { private String account_yourlastname; private String checkingaccount_yourlastname; private String savingsaccount_yourlastname; public String getAccount_yourlastname() { return account_yourlastname; } public void setAccount_yourlastname(String account_yourlastname) { this.account_yourlastname = account_yourlastname; } public String getCheckingaccount_yourlastname() { return checkingaccount_yourlastname; } public void setCheckingaccount_yourlastname(String checkingaccount_yourlastname) { this.checkingaccount_yourlastname = checkingaccount_yourlastname; } public String getSavingsaccount_yourlastname() { return savingsaccount_yourlastname; } public void setSavingsaccount_yourlastname(String savingsaccount_yourlastname) { this.savingsaccount_yourlastname = savingsaccount_yourlastname; } } package FA2018_LAB3PART2_yourlastname; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import static javafx.scene.input.KeyCode.T; public class Demo_unsortedoptimizedarray_yourlastname { public static final List arraystructure= new ArrayList(); public void insertaccount(String account){ if(account != null || !account.isEmpty()){ arraystructure.add(account); System.out.println("insert account success"); }else{ System.out.println("insert account failed"); } } public void checkencapsulation(int index,String account){ String fromarray = (String)arraystructure.get(index); if(account instanceof String && fromarray instanceof String){ System.out.println("Unsorted optimized array is not encapsulated"); }else{ System.out.println("Unsorted optimized array is encapsulated"); } } public void update(int index,String servicefee){ int servicefe = (int)arraystructure.get(index); servicefe =servicefe+100; arraystructure.add(index,servicefe+""); } public void showall(){ for(Object s : arraystructure){ System.out.println("The value of the arraylist is " + arraystructure.get(s)); } } public void remove(int index){ arraystructure.remove(index); showall(); } }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.