hi danpost,
how do i fix this error. have been having this error.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | package ATM; import java.text.DecimalFormat; import java.util.Scanner; public class ATM { static Account[] acc = new Account[ 10 ]; static Scanner input = new Scanner(System.in); static DecimalFormat df = new DecimalFormat( "#.00" ); public static void main(String[] args) { createAccount(); //create an account mainMenu(acc); //the main mean created } public static void createAccount() { //instantiates the variables int i; double bal= 50.0 ; Clients[] client = new Clients[ 10 ]; for (i= 0 ; i<acc.length; i++) { //asking for the user information System.out.println( "Enter first name" ); String n = input.next(); System.out.println( "Enter address" ); String a = input.next(); System.out.println( "Enter contact" ); String c = input.next(); c[i] = new Clients(n, a, c); //created a new person (this is where I am getting the error, array required but string found } } public static void mainMenu(Account[]act) //main menu { int test; //asking for the user id do { System.out.println( "Enter the ID" ); //getting id test = input.nextInt(); if (test == - 1 ) { System.exit( 0 ); //if user enter the incorrect id the progrm would end } else { //for loop to iterate the array the amount of times the user would enter the their id for ( int i= 0 ; i<act.length; i++) { //checking to see if the user enter the correct id if (test==(act[i].getID())) { atmMenu(act[i]); break ; } } } } while (test!=- 1 ); } public static void atmMenu(Account a) { double amt; int sel; do { //asking the user to enter the transaction the user wish to make System.out.println( "Make a selection from the following" //asking the user to make a choice + "\n1\tBalance: " + "\n2\tWithdraw: " + "\n3\tDeposit: " + "\n4\tInformation: " + "\n5\tExit: \n" ); sel = input.nextInt(); switch (sel) { case 1 : a.getbalance(); //getting acct bal break ; //asking the user how much they would like to withdraw case 2 : System.out.println( "\nHow much would you like to withdraw?\n" ); //asking for how much to be withdraw amt = input.nextDouble(); if (amt>a.getbalance()) { //letting the user know the amount they withdraw is not sufficient in the account System.out.println( "\nInsufficient funds.\n" ); //letting the user know there not enough funds } else { a.withdraw(amt); //letting the user know there is enough in the account } break ; //asking the user how much the user want to deposit case 3 : System.out.println( "\nHow much would you like to deposit?\n" ); //ask how much to be deposited amt = input.nextDouble(); a.deposit(amt); //getting the amount to be deposit break ; case 4 : a.toString(); //acquiring the user information break ; case 5 : break ; } } while (sel!= 5 ); } |