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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
| JButton btnEtablirLchance = new JButton("Etablir l'\u00E9ch\u00E9ance");
btnEtablirLchance.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int b=Integer.parseInt(txtNombreEche.getText());
montantAccorder=txtMontantAccordé.getText();
nobreEche=txtNombreEche.getText();
taux=cmbTaux.getSelectedItem().toString();
interet=Integer.parseInt(montantAccorder)*Integer.parseInt(taux)/100;//calcul d'interet
amort=Integer.parseInt(montantAccorder)/Integer.parseInt(nobreEche);
/*BigDecimal bd = new BigDecimal(amort);//Arrondi
bd= bd.setScale(2,BigDecimal.ROUND_DOWN);//arrondi
amort = bd.doubleValue();*///arrondi
mensualite=amort+interet;
/*BigDecimal bd1 = new BigDecimal(mensualite);
bd1= bd1.setScale(2,BigDecimal.ROUND_DOWN);
mensualite = bd1.doubleValue();*/
interetTotal=interet*Integer.parseInt(nobreEche);
epargne=Integer.parseInt(montantAccorder)*10/(Integer.parseInt(nobreEche)*100);
/*BigDecimal bd2 = new BigDecimal(epargne);//Arrondi
bd2= bd2.setScale(2,BigDecimal.ROUND_DOWN);//arrondi
epargne = bd2.doubleValue();//arrondi
*/ echeance=mensualite+epargne;
int capitalDegr=(((Integer.parseInt(montantAccorder)/Integer.parseInt(nobreEche))));
/*BigDecimal bd3 = new BigDecimal(capitalDegr);//Arrondi
bd3= bd3.setScale(2,BigDecimal.ROUND_DOWN);//arrondi
capitalDegr = bd3.doubleValue();//arrondi
*/
txtAmor.setText(String.valueOf(amort));
txtInteret.setText(String.valueOf(interet));
txtMensualite.setText(String.valueOf(mensualite));
txtTotaInteret.setText(String.valueOf(interetTotal));
txtEpargne.setText(String.valueOf(epargne));
txtEcheMens.setText(String.valueOf(echeance));
model = new DefaultTableModel();
model.setColumnIdentifiers(new Object[]{"N°","Date","Capital","Amortissemnt","Interet",
"Mensualite","Epargne","Echeance"});
Object[] row = new Object[8];
int a=1;
int j=1;
for(int i=0; i<Double.parseDouble(nobreEche); i++){
row[0] = a++;
Date today = dateDebutEche.getDate();
Instant instant = Instant.ofEpochMilli(today.getTime());
LocalDateTime localDateTime = LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
LocalDate date1 = localDateTime.toLocalDate();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd-MMM-yyyy");
if (date1.getDayOfWeek() == DayOfWeek.SATURDAY||date1.getDayOfWeek() == DayOfWeek.SUNDAY) {
LocalDate date2 = date1.plusMonths(j++);
TemporalAdjuster nextFriday = TemporalAdjusters.next(DayOfWeek.MONDAY);
LocalDate nextFridayDate = date2.with(nextFriday);
String formattedString = nextFridayDate.format(formatter);
row[1]= formattedString ;
}
else {
LocalDate date2 = date1.plusMonths(j++);
String formattedString = date2.format(formatter);
row[1]= formattedString ;
}
row[2] = (b--)*capitalDegr;// calcul du capital restant du
row[3] = amort;
row[4] = interet;
row[5] = mensualite;
row[6] = epargne;
row[7] = echeance;
///****************************************************************************/*
model.addRow(row);
}
table.setModel(model);
}
} |
Partager