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

2 days ago

can some correct this error plz

divinity divinity

2 days ago

#
hi danpost. this program was one that I am currently doing. I am getting these do errors. here is the code
public static void main(String[]args){
        Scanner keyin = new Scanner(System.in);
        
        ArrayList savings = new ArrayList();
        ArrayList chequing = new ArrayList();
        
        String firstname;
        char type;
        double balance;
        float rate;
        String acctnum;
        double total_amt;
        char yourchoice;
        
        Saving_Account sa = new Saving_Account(); this is the first error. the errors says: constructor Chequing_Account in class Chequing_Account cannot be applied to given types;
        Chequing_Account ca = new Chequing_Account(); this is the second error
        
        System.out.println("\n"+ "Please select one of the following option");
        System.out.println("| o - To open an account");
        System.out.println("| d - To make a deposit");
        System.out.println("| w - To make a withdraw");
        System.out.println("| i - To pay the interest");
        System.out.println("| t - To view the transactions");
        System.out.println("| q - To quit");
        type = keyin.next().trim().toUpperCase().toLowerCase().charAt(0);
       
        while(type !='q'){
            
          if(type == 'o'){
              
              System.out.print("Please select the type of account you will like to open: s-Saving or c-Checking");
              yourchoice = keyin.next().trim().toUpperCase().toLowerCase().charAt(0);
              if(yourchoice == 's'){
                  System.out.print("Please enter account holder");
                  firstname = keyin.next();
                  
                  System.out.print("please enter the Saving Account Number");
                  acctnum = keyin.next();
                  sa.acctnum();
              }
              
          }
        }

 Saving_Account sa = new Saving_Account();
        Chequing_Account ca = new Chequing_Account();  I need to use these but I dont want to remove them from the class, I just want to error to go away without having to add any more classes
danpost danpost

2 days ago

#
You need to supply arguments for the parameters in both the Savings_Account and Chequing_Account constructor.
divinity divinity

2 days ago

#
hi danpost: I have added the argument and now am getting another error
 Saving_Account sa = new Saving_Account(String firstname, String acctnum, float interestRate); the errors: ')' expected
        Chequing_Account ca = new Chequing_Account(String firstname, String acctnum, double balance);
        
this is the errors that I am getting now, aint seeing where it is picking up those errors: ')' expected
danpost danpost

2 days ago

#
Arguments are values -- not variables being declared (or dummy variables/parameters). The values will be assigned to the parameters/declared variables of the constructors. No error will happen if you remove all "String", "float", and "double" from the argument lists (in the two lines provided above). However, the values will be useless because no valid values have been assigned those variables prior to the constructor calls.
divinity divinity

2 days ago

#
hi danpost, ok i remove the string, double and float, and now am getting another set of errors, it is not telling me that i have to initialize. initialize the firstname, acctnum, interestRate and balance. what do i do and how do i initialize them without getting another set of errors
danpost danpost

2 days ago

#
danpost wrote...
no valid values have been assigned those variables prior to the constructor calls.
Assign values to them prior to calling the constructors.
You need to login to post a reply.