import java.io.*; public class Account { String custName; String accNo; String amount; double balance; Account(String h,String i,String j,double k) { custName=h; accNo=i; amount=j; balance=k; } public void input() { try { BufferedReader br=new BufferedReader (new InputStreamReader(System.in)); System.out.println("Enter the name of a account holder"); custName=br.readLine(); System.out.println("Enter the account number of a account holder"); accNo=br.readLine(); System.out.println("Enter the amount to be deposited"); balance=Double.parseDouble(amount); } catch(Exception g) { } } public void deposit() { try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the amount to be deposited"); amount=br.readLine(); double amt=Double.parseDouble(amount); balance=balance+amt; System.out.println("Balance: "+balance); } catch(IOException e) { }} public void withdraw() { try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter the amount to be withdraw1"); amount=br.readLine(); double amt=Double.parseDouble(amount); balance=balance-amt; System.out.println("balance: "+balance); } catch(IOException e) { }} public void display() { System.out.println("Account holder details"); System.out.println("----------------------"); System.out.println("Name: "+custName); System.out.println("Balance: "+balance); }} import java.io.*; public class Current extends Account { public void chequebook() { if (balance<1000) System.out.println("cheque book has not been issued"); else System.out.println("chèque book has been issued"); } public void minimumBal() { double penalty=1000; if(balance<10000) { balance=balance-penalty; } } public void display() { minimumBal(); super.display(); } } import java.io.*; public class Saving extends Account { public void calInterest() { double interest=0; System.out.println(interest); balance=balance*Math.pow(1.05, 2); System.out.println(balance); } public void display() { calInterest(); System.out.println(balance); super.display(); } public char menu() { char choice='a'; System.out.println("Menu"); System.out.println("1.Current account"); System.out.println("2.Savings account"); System.out.println("3.exit"); System.out.println("Enter your choice (1-3)"); try { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); choice=(char)br.read(); } catch(Exception e) { System.out.println("Error"); } if (choice=='3') { System.exit(0); } return choice; } public static void main (String a []) { char choice; Saving o=new Saving(); while(true) { // choice=o.menu(); try { switch(choice) { case '1': Current object=new Current(); while(true) { System.out.println("menu"); System.out.println("1.enter details"); System.out.println("2.deposit amount"); System.out.println("3.withdraw amount"); System.out.println("4.display balance"); System.out.println("5.issue chequeBook"); System.out.println("6.exit"); try { System.out.println("enter your choice(1-6)"); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); char ch=(char)br.read(); switch(ch) { case'1':object.input(); break; case'2':object.deposit(); break; case'3':object.withdraw(); break; case'4':object.display(); break; case'5':object.chequebook(); break; case'6':choice=o.menu(); default: System.out.println("Please enter the valid choice"); break; } } catch(IOException e) { } } case'2': Saving object1=new Saving(); while(true) { System.out.println("Menu"); System.out.println("1. Enter Details"); System.out.println("2. Deposit Amount"); System.out.println("3. Withdraw Amount"); System.out.println("4. Display Balance"); System.out.println("5. Exit"); try { System.out.println("enter your choice(1-6)"); BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); char ch=(char)br.read(); switch(ch) { case'1':object1.input(); break; case'2':object1.deposit(); break; case'3':object1.withdraw(); break; case'4':object1.display(); break; case'5':o.menu(); default: System.out.println("please enter the valid choice"); break; }} catch(IOException e) { } } case'3'://System.out.println("please entre the valid choice"); System.exit(0); break; } //switch } catch(Exception e) { } } }//while }//main
Implicit super constructor Account() is undefined for default constructor. Must define an explicit constructor
public Account() { // à complèter .. }
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionpublic class Account { String custName; String accNo; String amount; double balance; Account(String h,String i,String j,double k) { custName=h; accNo=i; amount=j; balance=k; }
import java.io.*; public class Account { String custName; String accNo; String amount; double balance; Account(String h,String i,String j,double k) { custName=h; accNo=i; amount=j; balance=k; }