This site requires JavaScript, please enable it in your browser!
Greenfoot back
divinity
divinity wrote ...

2016/11/29

cannot find symbol, help

1
2
divinity divinity

2016/11/29

#
hi this program here is my second assignment, it is an upgrade to the first one that I had posted before but with a few more classes added; I am supposed to used the same set of coding with this one as in the first one but few more coding added to it and it is supposed to run the same way as the first one. the problem I am having is the cannot find symbol, I have tried looking in the respective classes to see where the error is originated from but cannot for the life of me, seem to find it. as i said, this is my second assignment, it is an upgrade to the first one with just a few more classes added. here is the codes and class the atm is the main class this is where the program will run from. can someone tell me how to fix it
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
public class ATM {
    DecimalFormat df = new DecimalFormat("#.00");
        public static void main(String[] args) {
            createAccount();
    }
        public static void createAccount()
        {
            Scanner input = new Scanner(System.in);
            int i=0;
            double bal=50.0;
            //this account hold 10 account
            Account[] acct = new Account[10];
            //creating a new person
            Person[] p = new Person[i++];
             
            for(i=0; i<acct.length; i++){
                System.out.println("Enter your name");
                String n = input.next();
                System.out.println("Enter your address");
                String a = input.next();
                System.out.println("Enter your contact");
                String c = input.next();           
                System.out.println("Enter the client number");
                int cn = input.nextInt();
                                 
                 
                //creating a new client each time the program runs
                Clients client = new Clients(n, a, c, cn);
                 
            }
                //asking the user to enter the type of account they want to utilize
                System.out.println("Welcome to the Account Type:\n  ");
                System.out.println("Please select from the following menu option:\n");
                System.out.println("=======================================");
                System.out.println("|   Please select your account type  | ");
                System.out.println("=======================================");
                System.out.println("| [\n1] Savings Account              |");
                System.out.println("| [\n2] Checking Account             |");
                System.out.println("| [\n3] CreditCard Account           |");
                System.out.println("======================================");     
                int accType = input.nextInt();
                
                if(accType == 1)
                {
                    acct[i] = new SavingsAccount(i, bal, client);this is where I am getting the cannot find symbol error(client- is the error)
                }
                else if(accType == 2)
                {
                    acct[i] = new CheckingAccount(i, bal, client);his is where I am getting the cannot find symbol error(client- is the error)
                                                                                                                                                  
                }
                else if(accType == 3)
                {
                    acct[i] = new CreditCardAccount(i, bal, client);his is where I am getting the cannot find symbol error(client- is the error)
                }
            while(true)
            {
                System.out.println("Enter your account id");
                int id = input.nextInt();
                 
                   if(id == -1)
                   {
                       break;
                   }
                   //this loop indicate that the id should be between 1 - 9
                while(id < 0 || id > 9)
                {
                    System.out.println("ID is incorect, try again");
                    id = input.nextInt();
                }
                //this while indicate whether the user enter the wrong id, given another chance to re-enter
                while(true)
                {
                    displayMenu();
                     
                    if(!useMenu(acct[id],input))
                    {
                        System.out.println();
                        break;
                    }
                     
                    System.out.println("\n");
                }
            }
        }
        public static boolean useMenu(Account acc, Scanner input)
        {
            int userchoice = input.nextInt();
             
            //everytime it runs it shall be false until it is true
            double amt=0;
            if(userchoice == 5)
            {
                return false;
            }
            else if(userchoice == 1)//
            {
                //user checking their balances
                System.out.println("The account balance is: "+ acc.getbalance());
                return true;
            }
            else if(userchoice == 2)
            {
                //indicating the amount to be withdrawn
                System.out.println("Enter the amount to withdraw");
                amt =input.nextDouble();//hold the amt to be withdrawn
                if(amt > acc.getbalance())//indicating if the amt withdrwn is over the limit
                {
                    //indicating that there is not enough funds in the account
                    System.out.println("Insufficient amount " + "Balance is "+acc.getbalance());
                }
                else
                {
                    //otherwise there is enought to be withdrawn
                    acc.withdraw(amt);
                    System.out.println("Balance is: "+ acc.getbalance());
                }
            }
            else if(userchoice == 3)
            {
                //user is asked to enter the amount to be deposited
                System.out.println("Enter the amount to deposit");
                acc.deposit(input.nextDouble());//hold the amt deposited
                System.out.println("Balance is "+ acc.getbalance());//gathering the balance after the  transactions
                return true;
            }
            else if(userchoice == 4)
            {
                //gathering the user information
                System.out.println(acc.getClient().toString());
            }
            else
            {
                //this indicated that the user enter a choice that is not there.
                System.out.println("invalid choice");
            }
            return true;
        }
         
        public static void displayMenu()
        {
            //displaying the menu where the user has to choose from
            System.out.println("Welcome to the Automated Teller Machine!\n");
            System.out.println("Select from the following menu options below:\n");
            System.out.println("=======================================");
            System.out.println("|         Main Menu                   |");
            System.out.println("=======================================");
            System.out.println("| [1] Check Balance                   |");
            System.out.println("| [2] Withdraw                        |");
            System.out.println("| [3] Deposit                         |");
            System.out.println("| [4] Display User Information        |");
            System.out.println("| [5] Exist                           |");
            System.out.println("Please select your choice now!!       |");
            System.out.println("=======================================");
        }
}
 
this is the account class
public abstract class Account {
    //instantiate the variable
    private int id;
    private double balance;
    private Clients client;
    private double acctTransaction;
     
     
    //constructor with parameter, this initialiing the id, bal and client number
    public Account(int i, double b, Clients c)
    {
        id = i;
        balance = b;
        client = c;
        acctTransaction=0;
    }
    // getting clients
    public Clients getClient()
    {
        return client;
    }
    // getting accid
    public int getid()
    {
        return id;
    }
    // getting balance
    public double getbalance()
    {
        return balance;
    }
    //setting clients
    public void setClients(Clients client)
    {
        this.client = client;
    }
    //setting accid
    public void setid(int id)
    {
        this.id = id;
    }
    // setting balance
    public void setbalance(double balance)
    {
        this.balance = balance;
    }
    public void setacctBalance(double balance){
        this.balance = balance;
    }
    public abstract void withdraw(double amt);
     
    public abstract void deposit(double amt);
     
    @Override // getting user information
    public String toString(){
        String getdetails = "acct ID "+id+"balance "+balance
                +"\nClient "+client.toString();
         
        return getdetails;
    }
    public void reviseTransaction(){
        acctTransaction++;
    }
    public double getacctTransaction(){
        return acctTransaction;
    }
}
this is the checkingAccount class
package Project;
 
/**
 *
 * @author luanataylor
 */
public class CheckingAccount extends Account {
    //intantiate variable
     
    private final double withdraw;
     
 
    //constructor with parameter
    public CheckingAccount(int i, double b, Clients c, double w) {
        super(i, b, c);//refering to the variable in the parents class
        withdraw = 0.3167;
    }
     
     
    public void deposit(double amt){
        super.setbalance(super.getbalance() + amt);
    }
     
 
    @Override
    public void withdraw(double amt) {
        reviseTransaction();// transaction is being updated
        if (amt > super.getbalance()) {//super calling the getbalance
            super.setacctBalance(super.getbalance() - amt);
            if(super.getacctTransaction() > 10)
            applyFee();
        }
    }
    //applying the fee
    public void applyFee() {
        double Tempbalance = super.getbalance() - 0.3167;
        super.setbalance(Tempbalance);
 
    }
 
    @Override
    //gathering the information needed
    public String toString() {
        return super.toString()
                + " -> CheckingAccount:\n\t"
                + "acct balance "
                + super.getbalance()
                + " num of account transaction "
                + super.getbalance();
    }
}
 
 
 
 
this is the client class
public class Clients extends Person{
     
    //instantiate the variable
     
    private final int clientNumber;
     
    //constructor with parameter
    public Clients(String n, String a, String c, int cn) {
        super(n, a, c);
        clientNumber = cn;
    }
 
    public int getclientNumber() {
        return clientNumber;
    }
    //getting user detailsride
    @Override
    public String toString() {
       return super.toString()+
               "\nClient Number "+ clientNumber;
    }
this is the creditcard class
 
public class CreditCardAccount extends Account {
    private final double withdrawTax;
         
        public CreditCardAccount(int i, double b, Clients c, double w)
        {
            super(i, b, c);
            withdrawTax = 0.1075;
        }
         
        public double getwithdrawTax(){
             return withdrawTax;
         }
        @Override
        public void deposit( double amt){
            super.setbalance(super.getbalance() + amt);
        }
        @Override
        public void withdraw(double amt){
            reviseTransaction();
            if(amt > super.getbalance()){
                super.setacctBalance(super.getbalance() - amt);
                if(super.getacctTransaction() > 10)
                    applyFee();
            }
             
        }
        public void applyFee(){
            double TempBalance = super.getbalance()- 0.1075;
            super.setbalance(TempBalance);
        }
        public String toString(){
            return super.toString()+
                    "\n CreditCardAccount "+
                    "Account Balance "+
                    super.getbalance();
        }
}
this is the person class
package Project;
 
public abstract class Person {
    //instantiating the variables
    private String name;
    private String address;
    private String contact;
    private Person person;
                         
    //implementing the constructor with arguements
    public Person(String n, String a, String c)
    {
        name = n;
        address = a;
        contact = c;
    }
    public Person getperson(){
        return person;
    }
    //getting name
    public String getname(){
        return name;
    }
    //getting address
    public String getaddress(){
        return address;
    }
    //getting contact
    public String getcontact(){
        return contact;
    }
    public void setPerson(Person person){
        this.person = person;
    }
    //setting the name
    public void setname(String newName){
        this.name = newName;
    }
    //setting address
    public void setaddress(String newaddress){
        this.address = newaddress;
    }
    //setting contact
    public void setcontact(String newContact){
        this.contact = newContact;
    }
    //toString to display the client information
     
    @Override
    public String toString(){
        String details = " name "+name+
                         "\naddress "+address+
                         "\ncontact "+contact+
                         "\nPerson "+person;
         
        return details;
    }
             
             
}
this is the savingsaccount class
package Project;
 
public class SavingsAccount extends Account {
    //instantiating the variables
    double balance;
     
 
    //constructor with parameters
    public SavingsAccount(int i, double b, Clients c) {
        super(i, b, c);//this is refering the variables in the parent class
    }
     
     
    @Override
    public void deposit(double amt) {
        super.setbalance(super.getbalance() + amt);
    }
 
    @Override
    //get the withdra method
    public void withdraw(double amt) {
        reviseTransaction();
        if (amt > super.getbalance()) {// calling the balance method
            super.setacctBalance(super.getbalance() - amt);//calculating the balance from the amt
 
        }
    }
    @Override
    //gathering the account information
    public String toString() {
        return super.toString()+
                "-> Saving Account "+
                "account balance "+
                super.getbalance();
 
    }
}
Super_Hippo Super_Hippo

2016/11/29

#
As far as I know, "cannot find Symbol" is always a compilation error, so it should tell you exactly the line where the error occurs.
divinity divinity

2016/11/29

#
hi super_hippo I have been looking all over the program, been checking in the other class and cant seem to find where the compilation error is and in the creditcard account it incur a 10.75% fee which should be applied to the balance, how do i applied this before the withdraw and in the checking account it incur a 31.67% fee which should be applied to the balance, how do i applied this before the withdraw how do i calculate this in both account and applied it to the balance plz
Super_Hippo Super_Hippo

2016/11/29

#
Well, "normally" when it tells you what error it is, it shows you the part red underlined. I am not sure how the fee should work. So let's say you have 100 $ and want to withdraw 10 $. Without fee, you would have 90 $ left. What exactly should be the result here? Do you want, that an additional 10.75 % of the withdraw will be "lost"? I am a bit confused about line 325 in the previous post. It checks if it tries to withdraw more than the balance? Shouldn't it be the other way around?
1
2
3
4
5
6
7
8
9
10
        @Override
        public void withdraw(double amt){
            //reviseTransaction();
            if(1.1075*amt < balance){ //if you make balance protected instead of private, you don't have to use a method to get it
                setacctBalance(balance - 1.1075*amt);
                //if(getacctTransaction() > 10)
                    //applyFee();
            }
              
        }
I am not sure what this acctTransaction should do. You increase it by one every time something is withdrawn (or tried to withdraw and failed, because it is before the condition is checked) and only if it is above 10, it should apply the fee? Btw, line 208 and 210. Methods which don't have code in it. I have never done that, so I am not sure if you can do this.
danpost danpost

2016/11/29

#
Super_Hippo wrote...
Btw, line 208 and 210. Methods which don't have code in it. I have never done that, so I am not sure if you can do this.
Those lines declare methods that must be overridden by any subclass of the class. Notice that all three classes that extend the Account class have 'deposit' and 'withdraw' methods. You can read up on this here. @divinity, usually the message will continue with what it could not find 'Cannot find symbol -- ____ _____' (giving the type and name). Does it not give you these?
divinity divinity

2016/11/29

#
in line 208 and 210, it is declared as an abstract method as you can see. hence the reason there is no code in it. if at any time i put any codes in it, it would give me an errors or can i put any codes in it
divinity divinity

2016/11/29

#
@danpost, i have overriden them in the classes but am still getting the cannot find symbol error. something is causing that error and I am exhausted trying to find it. but I will keep trying though even though I am exhaused trying it doesnt mean I have given up
danpost danpost

2016/11/29

#
divinity wrote...
in line 208 and 210, it is declared as an abstract method as you can see. hence the reason there is no code in it. if at any time i put any codes in it, it would give me an errors or can i put any codes in it
I was not suggesting that you add codes to those methods. I was just letting Super_Hippo know why they were coded the way you had them.
am still getting the cannot find symbol error
Again, what cannot it find? It should be saying more than 'cannot find symbol'.
divinity divinity

2016/11/29

#
hi danpost that is what the error is telling me, cannot find symbol, nothing else
Super_Hippo Super_Hippo

2016/11/29

#
Could you make a screenshot please?
divinity divinity

2016/11/29

#
ok
divinity divinity

2016/11/29

#
i took the screenshot but how do i upload it and put it here
danpost danpost

2016/11/29

#
divinity wrote...
i took the screenshot but how do i upload it and put it here
You need to upload it to some image hosting site, like imgur or tinypic. Then get the URL of the image (not the page the image is on) and use the image link below the reply box to insert the image into your post.
divinity divinity

2016/11/29

#
Super_Hippo Super_Hippo

2016/11/29

#
Hm, I am not even seeing an error message.
There are more replies on the next page.
1
2