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

2016/12/14

increasing instead of decreasing what is the cause, plz help

1
2
3
danpost danpost

2016/12/20

#
divinity wrote...
there is none actually, the program ask for 10 account, so I was just testing out to see if any number can work besides 3.
Well, line 267 in the output section above shows you entering an ID value of '7'.
do u want me to post the savingsaccount, checking account,creditcard and all of the othere class account.
I wanted at least the one the type that '7' above was assigned; but, if you do not know. then, yes -- all three types please.
divinity divinity

2016/12/20

#
hi danpost have yuh ever program an application,when you are seeing an error but you are not seeing any red lines, what do you call that type of error and how do you fix it.
this is the checking Account
package ATMMachine;

public class SavingsAccount extends Account {
  
    //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();

    }
}

this is the credit card
package ATMMachine;

public class CreditCardAccount extends Account {

    private final double withdrawTax;

    public CreditCardAccount(int i, double b, Clients c) {
        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();
        super.setbalance(super.getbalance() - amt);
        if (amt < super.getbalance()) {
            super.setacctBalance(super.getbalance() - 0.1075);
            if (super.getacctTransaction() > 10) {
                applyChargeFee();
            }
        }


this is the savings account
danpost danpost

2016/12/20

#
At line 64, you call a method called 'applyChargeFee'; but, I do not see that method anywhere. That and the CreditCardAccount class given is incomplete. Even the 'withdraw' method is not closed. The savings account class is not showing at all.
danpost danpost

2016/12/20

#
divinity wrote...
have yuh ever program an application,when you are seeing an error but you are not seeing any red lines, what do you call that type of error and how do you fix it.
There are two types of error. There are those that are caught during compilation of the project. Usually those are syntax and type discrepancy errors. Then, there are those that are caught during either the initial world construction or the running of the project (during code execution). These are run-time errors which produce a terminal output that trace the execution to the error. These errors are called exception. The most common types of these that beginners run into are 'NullPointerException', 'IllegalStateException' and 'IndexOutOfBoundsException'. Two other errors that beginners may run into are 'Out of memory' and 'Stack overflow'. These last two are memory issues. All, however, are due to either how something was coded or the lack of appropriate coding. Getting back to your question, run-time errors will not produce red lines in your code; but, print a execution trace to your terminal window. This trace can be made use of to point you to where to look in your code for what the actual issue might be.
divinity divinity

2016/12/20

#
This is the method for the applychargefee in the creditcard account. sorry about that
this is the checking account

public class CheckingAccount extends Account {
    //intantiate variable
    
    private final double withdraw;
    

    //constructor with parameter
    public CheckingAccount(int i, double b, Clients c) {
        super(i, b, c);//refering to the variable in the parents class
        withdraw = 0.3167;
    }
    
    
    @Override
    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() - 0.3167 );
            if(super.getacctTransaction() > 10)
            applyChargeFee();
        }
    }
    //applying the fee 
    public void applyChargeFee() {
        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 credit card class
    public class CreditCardAccount extends Account {

        private final double withdrawTax;

        public CreditCardAccount(int i, double b, Clients c) {
            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();
            super.setbalance(super.getbalance() - amt);
            if (amt < super.getbalance()) {
                super.setacctBalance(super.getbalance() - 0.1075);
                if (super.getacctTransaction() > 10) {
                    applyChargeFee();
                }
            }

        }

        public void applyChargeFee() {
            double TempBalance = super.getbalance() - 0.1075;
            super.setbalance(TempBalance);
        }

        @Override
        public String toString() {
            return super.toString()
                    + "\n CreditCardAccount "
                    + "Account Balance "
                    + super.getbalance();
        }
    }

this is the savingsaccounts class
public class SavingsAccount extends Account {
  
    //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();

    }
}

danpost danpost

2016/12/20

#
In the CheckingAccount class above, line 26 is the only thing that is changing the balance on a withdrawal (which fits your resultant balance in the output).
divinity divinity

2016/12/20

#
danpost what would I do without you. I want to say thank you very much, fix line 26 and I got it to give the correct result. I want to take this time to wish you and your family a merry christmas and a bright and properous new year.
danpost danpost

2016/12/20

#
divinity wrote...
I want to take this time to wish you and your family a merry christmas and a bright and properous new year.
Likewise, I am sure -- with many blessings.
divinity divinity

2016/12/31

#
hi danpost and supper_hippo how was allyuh christmas holidays, hope it went fine and it was spend with family, am looking forward to new year and more advice from u guys. I dont know if I have passed object programming 1 as yet but if I do I will see u guys for obj2 programming happy new year all
divinity divinity

2017/1/1

#
hello everybody happy new year to u all here wey it is. this program hear was supposed ti be my final project a bank simulation but I ended up doing it in a group but I have been practicing it on my own.(it was really an individual assignment but they lecturer didnt specify any given instruction but the question paper did say group) but anyway i had started doing it in case of anything going bad, here is the problem. I am having some serious problems getting the coding for the gui part. I was doing the main part where it is supposed to be the same way as both assignment 1 and 2. it is supposed to have basically the same coding and it supposed to run just the same way as assignment 1 & 2. in the main part where is it coded the same as assignment 2, am having a cannot find symbol error, and for the life of me, doh kno how to fix it. have been trying to get at it but to no avail. it is supposed to be linked to the savingsAccount, checking Account and the creditcardaccount here it wat am speaking about here is the main part it should be link to the constructor in all accounts class. hoping for some relief
public  

class BankATM {
    
        DecimalFormat df = new DecimalFormat("#.00");
    
        Account[] newacct = new Account[10];
    
    public static void  main(String[]args){
        
        new BankATM().createAccount();
    }
   
    public void createAccount(){ 
        
        Scanner keyboard = new Scanner(System.in); 
        double bal = 50.0;
        int i;
        
        for(i = 0; i < newacct.length; i++){
            
            System.out.println("Please enter  your first name");
            String fn = keyboard.next();
            
            System.out.println("Pleased enter your last name");
            String ln = keyboard.next();
            
            System.out.println("Please enter your address");
            String a = keyboard.next();
            
            System.out.println("Please enter your contact number");
            String cnt =  keyboard.next();
            
            System.out.println("Please enter your client number");
            int cn = keyboard.nextInt();
            
            Client client = new Client(fn, ln, a, cnt, cn);
                    
            System.out.println("\nWelcome to the banking ATM");
            System.out.println("Welcome to the account type:\n");
            System.out.println("Please select from the following menu:\n");
            System.out.println("=========================================");
            System.out.println("              Main Menu                  |");
            System.out.println("=========================================|");
            System.out.println("| [\n1]  Savings Account                 |");
            System.out.println("| [\n2]  Checking Account                |");
            System.out.println("| [\n3]  CreditCard Account              |");
            System.out.println("| Select your choice now!!!!!            |");
            System.out.println("=========================================|");
            int newacctType = keyboard.nextInt();
            
            
            if(newacctType == 1)
            {
                newacct[i] = new SavingsAccount(i, b, client); the b is the error, cannot find symbol
            }
            else if(newacctType == 2)
            {
                newacct[i] = new CheckingAccount(i, b, client); the b is where the error is(cannot find symbol
            }
            else if(newacctType == 3)
            {
                newacct[i] = new CreditCardAccount(i, b, client); the b is the error, cannot find symbol
            }
        }
        while(true)
        {
            //asking the user to enter there ID
            System.out.println("Please enter your account ID");
            int acctID = keyboard.nextInt();
            
            //at the end of the program this if statment would help break out of the loop
            if(acctID == -1)
            {
                break;
            }
            while(acctID < 0 || acctID > 9)
            {
                System.out.println("acctID is invalid, please try again");
                acctID = keyboard.nextInt();
            }
            while(true)
            {
                displayMenu();
                
                if(!useMenu(newacct[acctID], keyboard))
                {
                    System.out.println();
                    break;
                }
                System.out.println("\n");
            }
        }
    }
    public boolean useMenu(Account acct, Scanner keyboard){
        
        double amt;
        int userchoice = keyboard.nextInt();
        
        if(userchoice == 5)
        {
            return false;
        }
        else if(userchoice == 1)
        {
            System.out.println("The account balance is: "+ acct.getacctbalance());
            return true;
        }
        else if(userchoice == 2)
        {
            System.out.println("Please enter the amount to be withdraw");
            amt = keyboard.nextDouble();
            
            if(amt > acct.getacctbalance())
            {
                System.out.println("Insufficient funds available "+ " Balance is $:"+ acct.getacctbalance());
            }
            else if(acct instanceof CheckingAccount)
            {
                CheckingAccount ca = (CheckingAccount) acct;
                ca.withdraw(amt);
            }
            else if (acct instanceof SavingsAccount)
            {
                SavingsAccount sa = (SavingsAccount) acct;
                sa.withdraw(amt);
            }
            else if (acct instanceof CreditCardAccount)
            {
                CreditCardAccount cca = (CreditCardAccount) acct;
                cca.withdraw(amt);
            }
            System.out.println("Balance is $: "+ acct.getacctbalance());
        }
        else if(userchoice == 3)
        {
            System.out.println("Please enter the amount to deposit");
            acct.deposit(keyboard.nextDouble());
            System.out.println("Money is successfully deposited!!!! "+"The Balance is $: "+acct.getacctbalance());
            return true;
        }
        else if(userchoice == 4)
        {
            System.out.println(acct.getCustomer().toString());
        }
        else 
        {
            System.out.println("Invalid choice");
        }
        return true;
    }

    private 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 owner's Details     |");
            System.out.println("| [5] Exist                       |");
            System.out.println("Please select your choice now!!   |");
            System.out.println("====================================");
            
    }
    
}
this is the checking Account
package BankATM;


public class CheckingAccount extends Account {
    private double overdraftLimit;
    private double bal;
    
    public CheckingAccount(int i, double b, Client c, double overdraftLimit){
        super(i, b, c);
        this.overdraftLimit = overdraftLimit;
    }
    public double getoverdraftLimit(){
        return overdraftLimit;
    }
    public void setoverdraftLimit(double overdraftLimit){
        this.overdraftLimit = overdraftLimit;
    }
    @Override
    public boolean withdraw(double amt){
        
        if(amt > overdraftLimit){
            System.out.println("Insufficient funds available");
            return false;
        }
        else if(amt < overdraftLimit){
            bal = bal - amt;
        }
            return true;
        }
    @Override
     public boolean deposit(double amt){
         bal = bal + amt;
         
         return true;
     }
    @Override
     public String toString(){
         return super.toString() +
                 "\nOverdraft Limit "+ overdraftLimit;
     }
    
}
this is the creditcard account
package BankATM;


public  class CreditCardAccount extends Account {
    
        private double creditlimit;
        private final double withdrawTax;
        private double bal;

        public CreditCardAccount(int i, double b, Client c, double creditlimit) {
            super(i, b, c);
            withdrawTax = 0.1075;
            this.creditlimit = creditlimit;
        }

        public double getwithdrawTax() {
            return withdrawTax;
        }
        public double getcreditlimit(){
            return creditlimit;
        }
        public void setcreditlimit(double creditlimit){
            this.creditlimit = creditlimit;
        }

        @Override
        public boolean deposit(double amt) {
            super.setacctbalance(super.getacctbalance() + amt);
            return true;
        }
        
        @Override
        public boolean withdraw(double amt) {
            if(amt > creditlimit){
                System.out.println("Insufficient funds available");
                return false;
            }
            else if(amt < creditlimit){
                bal = bal - amt;
                return true;
            }
            
            if (amt < super.getacctbalance()) {
             super.setacctbalance(super.getacctbalance() -amt);
                if (super.getacctTransaction() > 10) {
                    applyChargeFee();
                }
            }
            return true;
        }

        public void applyChargeFee() {
            double TempBalance = super.getacctbalance() - 0.1075;
            super.setacctbalance(TempBalance);
        }

        @Override
        public String toString() {
            return super.toString()
                    + "\n Credit Limit " +creditlimit;
        }
    }

    

this is the savingsAccount
danpost danpost

2017/1/1

#
Think about it -- what is 'b' supposed to be (what value does it represent)? where is that value coming from (must be declared somewhere before it within the method, or from a parameter in the method declaration line or declared as a field in this class or one of its super class(es))? could it, or should it be 'bal' as declared on line 17?
divinity divinity

2017/1/2

#
hi danpost when i put in the bal instead of the b, am getting this error, constructor SavingsAccount in class SavingsAccount cannot be applied to given types and it says so for both the creditcard account and the checking account even after i fix it
danpost danpost

2017/1/2

#
Both the creditcard and checking account constructors require another double value (for overdraft and creditlimit).
divinity divinity

2017/1/2

#
hi danpost both the checking account and the creditcard account have the double overdraft and credit limit it is right there
danpost danpost

2017/1/2

#
divinity wrote...
hi danpost both the checking account and the creditcard account have the double overdraft and credit limit it is right there
Yes, but lines 59 and 63 of the BankATM class do not have arguments for those parameters.
There are more replies on the next page.
1
2
3