1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
| public class CompteBancaire
{
public String nom, prenom, adresse,tel;
public CompteBancaire()
{
System.out.println("Vous allez créer un compte :");
System.out.println("Entrez le nom du titulaire :");
this.nom=Lire.chaine();
System.out.println("\nEntrez le prenom titulaire :");
this.prenom=Lire.chaine();
System.out.println("\nEntrez l'adresse du titulaire :");
this .adresse=Lire.chaine();
}
public void afficherAdresse()
{
System.out.println("\nAdresse du compte de " + this.nom + " = " + this.adresse );
}
}
public class CompteEpargne2 extends CompteBancaire
{
public final double soldeMinimal=1;
public double tauxInteret=3/100;
public double montantApresInteret(double montantInitial)
{
return montantInitial*(1+tauxInteret);
}
}
public class TesterHeritage2
{
public static void main(String[] args)
{
CompteEpargne2 c2=new CompteEpargne2();
double sommeVersées=2524;
System.out.println("\nSolde après un an : "+c2.montantApresInteret(sommeVersées));
}
} |