bonjour a tous!
j'ai un petit souci pour mon projet dinformatik...
quand je compile mon fichier j'ai 2 erreurs qui apparaissen:
"illegal start of expression" pour: private double tx;
et private double mensualite;
je vou remerci de laide ke vou pourrez mapporter...
voila mon fichier:
import java.awt.* ;
import java.awt.event.*;
class Fenetre extends Frame {
protected Panel p,p1,p2,p3,p4;
protected TextArea texte;
protected Button bouton1 ;
protected CheckboxGroup cbg;
protected Checkbox chb1, chb2, chb3;
protected Choice c;
protected TextField tf1, tf2;
protected Delegue delegue;
protected Adaptateur adapt;
Fenetre() {
p=new Panel();
p.setLayout(new GridLayout(4,1));
p1=new Panel();
p1.setLayout(new FlowLayout());
p1.add(new Label("Type d'emprunt"));
cbg=new CheckboxGroup();
chb1=new Checkbox("immobilier", cbg, true);
p1.add(chb1);
chb2=new Checkbox("achat de véhicule", cbg, false);
p1.add(chb2);
chb3=new Checkbox("consommation", cbg, false);
p1.add(chb3);
p.add(p1);
p2=new Panel();
p2.setLayout(new FlowLayout());
p2.add(new Label("Montant demandé"));
tf1=new TextField(10);
p2.add(tf1);
p2.add(new Label("Nombres d'années de remboursement "));
c=new Choice();
c.addItem("3");
c.addItem("4");
c.addItem("5");
c.addItem("6");
c.addItem("7");
c.addItem("8");
c.addItem("9");
c.addItem("10");
c.addItem("11");
c.addItem("12");
c.addItem("13");
c.addItem("14");
c.addItem("15");
c.addItem("16");
c.addItem("17");
c.addItem("18");
c.addItem("19");
c.addItem("20");
c.addItem("21");
c.addItem("22");
c.addItem("23");
c.addItem("24");
c.addItem("25");
c.addItem("26");
c.addItem("27");
c.addItem("28");
c.addItem("29");
c.addItem("30");
p2.add(c);
p.add(p2);
p3=new Panel();
p3.setLayout(new FlowLayout());
p3.add(new Label("Revenu mensuel"));
tf2=new TextField(10);
p3.add(tf2);
p.add(p3);
p4=new Panel();
p4.setLayout(new FlowLayout());
bouton1=new Button("Valider");
p4.add(bouton1);
p.add(p4);
add("North", p);
texte=new TextArea();
add("South", texte);
delegue=new Delegue(this);
adapt=new Adaptateur(delegue);
this.addWindowListener(adapt);
bouton1.addActionListener(adapt);
}
}
class Delegue {
protected Fenetre fen;
Delegue(Fenetre f){
fen=f;
}
public void quitter() {
System.exit(0);
}
void calcule(){
float montant ;
int nbannee ;
float revenu ;
private double tx;
private double mensualite;
montant = new Float(fen.tf1.getText()).floatValue() ;
nbannee = new Integer(fen.c.getSelectedItem()).intValue() ;
revenu = new Float(fen.tf2.getText()).floatValue();
for(int i=0; i<nbannee; i++){
mensualite = (montant*(tx/12)) / (1-Math.pow(1+(tx/12),(-nbannee*12)));
}
boolean condition1 = (nbannee>2)&&(nbannee<31);
boolean condition2 = (montant <= 70*revenu);
boolean condition3 = (mensualite < (33/100)*revenu); // condition imposé pour tous les prêts
boolean condition4 = (nbannee>2)&&(nbannee<11) ;
boolean condition5 = (montant <= 10*revenu);
boolean condition6 = (nbannee>2)&&(nbannee<7);
boolean condition7 = (montant <= 5*revenu);
String res1 = "Emprunt";
String c1 = fen.cbg.getSelectedCheckbox().getLabel() ;
if (c1=="immobilier"){
if (condition1 && condition2) {
tx = 0.05;
res1 = res1 + "\nLe taux appliqué est de 0.05 annuel"+ "\nLe montant de la mensualité est:" + new Double(mensualite).toString() ;
if(condition3)
res1 += "PRET AUTORISE";
else res1 += "La mensualité dépasse 33% du revenu mensuel - PRET REFUSE";
}
}
else if(c1=="achat de véhicule") {
if(condition4 && condition5) {
tx = 0.06;
res1 = res1 + "\nLe taux appliqué est de 0.06 annuel\nLe montant de la mensualité est:" + new Double(mensualite).toString() ;
if(condition3)
res1+="PRET AUTORISE";
else res1 += "La mensualité dépasse 33% du revenu mensuel - PRET REFUSE";
}
}
else {
if(condition6 && condition7) {
tx = 0.08;
res1 = res1 + "\nLe taux appliqué est de 0.08 annuel\nLe montant de la mensualité est:" + new Double(mensualite).toString() ;
if(condition3)
res1 += "PRET AUTORISE";
else res1+="La mensualité dépasse 33% du revenu mensuel - PRET REFUSE";
}
}
fen.texte.setText(res1);
}
}
class Adaptateur implements WindowListener, ActionListener {
protected Delegue delegue;
Adaptateur(Delegue d) {
delegue=d;
}
public void windowOpened(WindowEvent e) {}
public void windowClosing(WindowEvent e) {
delegue.quitter();
}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
String param = ((Button)src).getLabel();
if (param == "Valider") delegue.calcule() ;
}
}
public class Emprunt4 {
public static void main (String args[]) {
Fenetre f=new Fenetre();
f.pack();
f.show();
}
}
merci pour votre aide...