Are you sure the error is coming from this line of code ?
Transaction_Account newtrans = new Transaction_Account(new Date(),'W', bal, 0, 0, "Withdrawal made");
public void withdraw(double total_amt){ if(total_amt < bal){ System.out.print("Your transaction declined because there is no funds available"+ bal); } else{ System.out.println("\n "+ "Your current balance is"+this.bal); } Transaction_Account newtrans = new Transaction_Account(new Date(), char type, this.bal, double amt, double newbal, 'W' "Withdrawal made"); } //deposit method public void deposit(double total_amt){ this.bal +=total_amt; System.out.print("\n"+total_amt+"Your balance is:"+this.bal); Transaction_Account newtrans = new Transaction_Account(new Date(), char type, this.bal, double amt, double newbal, 'D', "Deposit deposited");
Transaction_Account newtrans = new Transaction_Account(new Date(),'W', bal, 0, 0, "Withdrawal made");
System.out.println("Please enter a saving account number"); acctnum = keyin.next(); Savings.add(acctnum) this function is what i am trying to bring up but for some reason it is not coming and the savings is causing a error I am trying to understand what can I do to bring up this function and what it is called
public class Saving_Account extends Account{ private float interestRate; public Saving_Account(String first_name, String last_name, String home_add, String email_add, double bal, String telephone, double acctnum, float interestRate){ super(first_name, last_name, home_add, email_add, acctnum,telephone); this.interestRate=interestRate; } public float getinterestRate(){ return interestRate; } public double getbal(){ return bal; } public float setinterestRate(float interestRate){ return interestRate = interestRate/100; } public void setbal(double bal){ this.bal=bal; } public void payInterest(){ double total_amt = getbal(); double bal=0; bal=(total_amt + (total_amt *getinterestRate())); setbal(bal); System.out.println("Account balance with interest is: $"+bal); Transaction_Account newtrans = new Transaction_Account(new Date(), 'I', bal,0,0,"Interest Paid"); } //withdrawal method @Override public void withdraw(double total_amt){ double bal=0; double acctamt=0; if(acctamt < total_amt){ System.out.println("Insufficient funds, balance is :$"+ acctamt); } else{ bal=acctamt-=total_amt; setbal(bal); System.out.println(); } } @Override public void deposit(double total_amt){ double acctamt = getbal(); bal = acctamt+=total_amt; setbal(bal); System.out.println("Your deposit amount is: $"+ bal + "was successful, your new balance is: $"+bal); Transaction_Account newtrans= new Transaction_Account(new Date(), 'D', bal, 0,0, "deposit made"); } @Override public String toString(){ return this.toString()+ "Interest Rate"+ interestRate; } }
System.out.println("Please enter a saving account number"); acctnum = keyin.next(); Savings.add(acctnum) this function is what i am trying to bring up but for some reason it is not coming and the savings is causing a error I am trying to understand what can I do to bring up this function and what it is called
*/ public class BankAccount { public static void main(String[]args){ Scanner keyin = new Scanner(System.in); char type, choice; boolean quit; String first_name; String acctnum; double bal; float interestRate; System.out.println("\n "+ "Please select one of the following opeitons"); System.out.println("| o-To Open Account |"); System.out.println("| d-To Make a deposit"); System.out.println("| w-To Make a Withdrawal"); System.out.println("| i-To Pay Interest"); System.out.println("| t - To View the Transation"); System.out.println("| q - To quit"); type = keyin.next().trim().toUpperCase().toLowerCase().charAt(0); while (type !='q'){ if(type == 'o'){ System.out.println("please select the type of accoun you will like to open s-Saving or c-Chequin"); choice = keyin.next().trim().toUpperCase().toLowerCase().charAt(0); if(choice == 's'){ System.out.println("Enter the account holder first name"); first_name = keyin.next(); System.out.println("Please enter a saving account number"); acctnum = keyin.next(); System.out.println("Enter the saving acct number"); acctnum = keyin.next(); System.out.println("Please enter a starting balance"); bal = keyin.nextDouble(); System.out.println("Please enter your current interest rate"); interestRate = keyin.next(); ( the error is right here, incompitatible type, string cannot be converted to double } } } } } this is the saving account class public class Saving_Account extends Account{ private float interestRate; public Saving_Account(String first_name, String last_name, String home_add, String email_add, double bal, String telephone, double acctnum, float interestRate){ super(first_name, last_name, home_add, email_add, acctnum,telephone); this.interestRate=interestRate; } public float getinterestRate(){ return interestRate; } public double getbal(){ return bal; } public float setinterestRate(float interestRate){ return interestRate = interestRate/100; } public void setbal(double bal){ this.bal=bal; } public void payInterest(){ double total_amt = getbal(); double bal=0; bal=(total_amt + (total_amt *getinterestRate())); setbal(bal); System.out.println("Account balance with interest is: $"+bal); Transaction_Account newtrans = new Transaction_Account(new Date(), 'I', bal,0,0,"Interest Paid"); } //withdrawal method @Override public void withdraw(double total_amt){ double bal=0; double acctamt=0; if(acctamt < total_amt){ System.out.println("Insufficient funds, balance is :$"+ acctamt); } else{ bal=acctamt-=total_amt; setbal(bal); System.out.println(); } } @Override public void deposit(double total_amt){ double acctamt = getbal(); bal = acctamt+=total_amt; setbal(bal); System.out.println("Your deposit amount is: $"+ bal + "was successful, your new balance is: $"+bal); Transaction_Account newtrans= new Transaction_Account(new Date(), 'D', bal, 0,0, "deposit made"); } @Override public String toString(){ return this.toString()+ "Interest Rate"+ interestRate; } }