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

2021/6/16

How can I get this program to run properly?

1
2
divinity divinity

2021/6/23

#
hi danpost I have added the consructor but it is still giving the errors and it is the me that the firstname, lastname, telephone, email add, homeadd has not been initialized, why do i have to initialized that, and how do i initialized it or am I missing something the customer class above was the one before I had before I add the constructor, that is why you are not seeing the constructor in there, so am going to post again so that u can see it is right there. so plz tell what to do again many thanks and here is the customer classs again
public class Customer {
    private String first_name;
    private String last_name;
    private String email_add;
    private  String home_add;
    private String telephone;
    
    
   public Customer(String first_name, String last_name, String email_add, String home_add, String telephone){
        
        
        this.first_name = first_name;
        this.last_name = last_name;
        this.email_add = email_add;
        this.home_add = home_add;
        this.telephone = telephone;
    }

    
    public String getfirst_name(){
        return first_name;
    }
    
     public String getlast_name(){
         return last_name;
     }
     
     public String getemail_add(){
         return email_add;
     }
     
     public String gethome_add(){
         return home_add;
     }
     
     public String gettelephone(){
         return telephone;
     }
     
     public void setfirst_name(String first_name){
         this.first_name=first_name;
     }
     
     public void setlast_name(String last_name){
         this.last_name=last_name;
     }
     
     public void setemail_add(String email_add){
         this.email_add=email_add;
     }
     
     public void settelephone(String telephone){
         this.telephone=telephone;
     }
     
    @Override
     public String toString(){
         return "Customer details"+ " First name of the customer :" + this.first_name+","+ "Last name of the customer:" + this.last_name+","+
                 "Home addres of the customer: "+ this.home_add+","+ "Email address of the customer: "+this.email_add+
                 ","+ "The customer telephone contact: "+ this.telephone;
     }
}

danpost danpost

2021/6/23

#
Please show main method.
divinity divinity

2021/6/24

#
This is he main method and the error is the customer customer = new customer();
public static void main(String[]args){
        Scanner keyin = new Scanner(System.in);
        
        
        char type;
        boolean quit;
        boolean isContains;
        String first_name;
        String last_name;
        String acctnum;
        double bal=0;
        float interestRate;
        String email_add;
        String telephone;
        
        Customer customer = new Customer();  the error is right here it is saying to constructor in the customer class when there is already a constructor in the customer class and another error is constructor Customer in class Customer cannot be applied to given types;
        customer.getfirst_name();
        customer.getlast_name();
        customer.gethome_add();
        customer.getemail_add();
        customer.gettelephone();
        
       
        
        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 (true){
           
            if(type  == 'o'){
             System.out.println("Please enter the trasaction type /(D to deposit, W to withdraw, Q to quit)");
              type = keyin.next().toUpperCase().toLowerCase().charAt(0);// tell the user to use either the upper case or lower case
              
                
                switch (type) {
                    case '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("Please enter a starting balance $"+bal);
                        bal = keyin.nextDouble();
                        System.out.println("Please enter your current interest rate");
                        interestRate = keyin.nextFloat();
                        break;
                    case 'c':
                        System.out.println("Please enter a chequing account number:");
                        acctnum=keyin.next();
                        System.out.println("Enter a starting balance:");
                        bal=keyin.nextDouble();
                        break;
                    case 'd':
                        System.out.println("Please enter the account number you wish to make a deposit to");
                        acctnum = keyin.next();
                       
                       
                        
                        break;
                    default:
                        break;
                        
                     
                }
            }
        }
        
    } 
          
          
  }
danpost danpost

2021/6/24

#
Do you want to run this for any one specific customer per run or run it with option of customers in one run? (the first way would be much easier)
divinity divinity

2021/6/24

#
the information below is how it should run, that is the output it should give. that is what I am looking for. Withdraw Which account to you wish to withdraw from: 2134 Amount: 500.00 Current Balance of account 1234: 1021 Pay Interest Enter command: I (N.B will list the new balances for ALL Savings Accounts) New Balances -------------------- 1234 $1041.42 Transaction Select an account: 1234 List of Transactions: (N.B. Please note that you must list ALL the transactions done on the account) 1. Date: 12/09/2019 Transaction type: D Amount: 521.00 Balance: 1521.00 Description: Withdrawal from account. 2. Date: 14/11/2019 Transaction type: W Amount: 500.00 Balance: 1021.00 Description: Withdrawal from account. Quit
danpost danpost

2021/6/24

#
Okay, it looks like one customer per run. Do you want customer info to be supplied to run or should it always be the same for all runs?
divinity divinity

2021/6/25

#
let try it with one customer per run and see how it works
divinity divinity

2021/6/25

#
yes i need all customer info to be the same but with different customer per run
danpost danpost

2021/6/25

#
divinity wrote...
yes i need all customer info to be the same but with different customer per run
Then make use of "String args" to bring in the information (name, address, etc.)
divinity divinity

2021/6/25

#
but all of the names address etc are strings, dont u see that
danpost danpost

2021/6/25

#
divinity wrote...
but all of the names address etc are strings, dont u see that
Of course I see that. Then no problem.
You need to login to post a reply.
1
2