.
.
.
.
.
.
.
.
.
.
.
Beiträge von Java-Appi
-
-
Okay Leute,
ich Poste gerade mal 2 Sachen hier in das Forum und schon glaubt Ihr mich zu kennen... LOL... sag ich nur.
Okay ich gebs zu, ICH bin nicht der Beste Programmierer. Ich bin gerade in einer Online-Universität in dem Java-Kurs für Anfänger. Dort ist nunmal alles auf Amerikanisch. Und da ich ein Amerikaner bin hab ich auch keine Probleme die Texte (Aufgabenstellungen) zu verstehen. Diese Codes wurden von mir persönlich erstellt und nicht von irgendwo "zusammengeklaut"... Aber Denkt doch bitte was Ihr wollt.
Ein wenig hilfe hätte ich schon erwartet von so "erfahrenen" Programmierern wie "euch".
Hier ist ein Update von meinem Programm. Dort habe ich nun noch einen Fehler. Zwar dass ich eine Endlosschleife erstellt habe und ich nicht weiss wie ich diese anhalten kann. Vielleicht kann mir Bitte ein Hilfsbereiter Programmierer weiterhelfen.
vielen Dank im vorraus
Java-Appi
Java
Alles anzeigen//Mortgage Program / //This program will calculate and display the mortgage / //monthly payments for a loan given the / //amount, the term and the interest rate of the mortgage. / //Hardcoded amounts are provided by the instructor. / / //Version 1 / //Modification 1 / //This program has been modified using an array to display / //3 mortgage loans: 7 year at 5.35%, 15 year at 5.5%, and / //30 year at 5.75%. In addition, this program will display / //the mortgage monthly payments amount for each loan. / / //and display the mortgage payment amount, and the interest / //paid for each payment over the term of the loan. To include/ //the balance after each payment. The program will use loops / //to display a partial list, hesitates and display more of / //the list / //Version 3.1.1 / ////////////////////////////////////////////////////////////// //To set digits after decimal point// import java.text.NumberFormat; class MortgageArray1 { public static void main(String args[])throws InterruptedException { double principal = 200000; //Hardcoded amounts// double []percent = {5.35/100, 5.5/100, 5.75/100}; short []nyears = {7, 15, 30}; //Loop to displays results for each loan// for (int x = 0; x < 3; x++) { getmonthly(principal, percent[x], nyears[x]); } } public static void getmonthly(double principal,double percent, short nyears)throws InterruptedException { //Used to set two digits after decimal point// NumberFormat fmt = NumberFormat.getInstance(); fmt.setMaximumFractionDigits(2); fmt.setMinimumFractionDigits(2); //Formula calculations to figure monthly payments// //Principal= principal*(percent/(1-(1+percent)^-years))// //Reference Chou, H.(2000)US Mortgage formula// double intmo = percent / 12; int npmts = nyears * 12; double pmt = principal * (intmo / (1 - Math.pow(1 + intmo, -npmts))); for (short mo = 1; mo <= npmts; ++mo) { double prinpmt, intpmt = principal * intmo; if (mo < npmts) prinpmt = pmt - intpmt; else prinpmt = principal; principal -= prinpmt; { System.out.println("\nPrincipal = $" + fmt.format(principal) + "\nInterest = " + percent*100 + "%" + "\nYears = " + nyears); System.out.println("Monthly Payments are = $ " + fmt.format(pmt)); } { //Display results// System.out.println(mo + "\t\t" + fmt.format(intpmt + prinpmt) + "\t" + fmt.format(intpmt) + "\t" + fmt.format(prinpmt) + "\t\t" + fmt.format(principal)); } //Used to display line by line with hesitation time// int delay =1; if (delay == 1) { Thread.sleep(800); } } } }//End of Mortgage program//
-
Hallo Zentor,
ich habe noch ein Problem mit einem Code. Könntest Du ihn dir Bitte ansehen und mir sagen wo das Problem steckt.
Vielen Dank im vorraus
//Mortgage Program /
//This program will calculate and display the mortgage /
//monthly payments for a loan given the /
//amount, the term and the interest rate of the mortgage. /
//Hardcoded amounts are provided by the instructor. /
//Version 1 /
//Modification 1 /
//This program has been modified using an array to display /
//3 mortgage loans: 7 year at 5.35%, 15 year at 5.5%, and /
//30 year at 5.75%. In addition, this program will display /
//the mortgage monthly payments amount for each loan.
//Modification 2
//This program will list the loan balance and interest paid for
//each payment over the term of the loan
//
//Version 3.2 /
//////////////////////////////////////////////////////////////
//To set digits after decimal point//
import java.text.NumberFormat;
class MortgageArray1
{
public static void main(String args[])throws InterruptedException
{
double principal = 200000; //Hardcoded amounts//
double []percent = new double [3];
percent[0] = 5.35/100;
percent[1] = 5.5/100;
percent[2] = 5.75/100;
short []nyears = new short[3];
nyears[0] = 7 ;
nyears[1] = 15;
nyears[2] = 30;
int delay = 1;
//Used to set two digits after decimal point//
NumberFormat fmt = NumberFormat.getInstance();
fmt.setMaximumFractionDigits(2);
fmt.setMinimumFractionDigits(2);
//Loop to displays results for each loan//
//Formula calculations to figure monthly payments//
//Principal= principal*(percent/(1-(1+percent)^-years))//
//Reference Chou, H.(2000)US Mortgage formula//
for (int x = 0; x < 3; x++)
{
double intmo = percent[x] / 12;
int npmts = nyears[x] * 12;
double pmt = principal * (intmo / (1 - Math.pow(1 + intmo, -npmts)));
System.out.println("\nPrincipal = $" + fmt.format(principal)
+ "\nInterest = "
+ percent[x] + "%"
+ "\nYears = " + nyears[x]);
System.out.println("Monthly Payments are = $ "
+ fmt.format(pmt));
}
//Formula calculations to figure interest pay in
//each monthly payment and the balance afterwards//
//Reference Chou, H.(2000)US Mortgage formula//
for (int x = 1; x <= npmts; ++x) {
double prinpmt, intpmt = principal * intmo;
if (x < npmts)
prinpmt = pmt - intpmt;
else prinpmt = principal;
principal -= prinpmt;
//Display results//
System.out.println(x + "\t\t" + fmt.format(intpmt + prinpmt)
+ "\t" + fmt.format(intpmt)
+ "\t" + fmt.format(prinpmt)
+ "\t\t" + fmt.format(principal));
//Used to display line by line with hesitation time//
if (delay == 1)
{
Thread.sleep(1000);
delay = 1;
}
Thread.sleep (1000);
}
}
} -
Vielen Dank für die schnelle Antwort.
Das war die Korrekte lösung. Nächstes mal drücke ich mich noch deutlicher aus :thumb: .
Schönen Wochenanfang noch
gruß
J-Appi -
Hallo liebe Leute,
ich habe ein kleines Java-Programmierungsproblem. In dem unten stehendem Quellcode müsste die monatliche zahlung bei jedem Output stehen. Nun ist meine Frage.
Wie kann ich die monatliche Zahlung in jedem der 3 Ausgaben einfügen?
Vielen Dank für schnelle Antworten
grüsse//Mortgage Program /
//This program will calculate and display the mortgage /
//monthly payments for three different loans given the /
//amount, the term and the interest rate of the mortgage. /
//Hardcoded amounts are provided by the instructor. / /
//Version 1 /
//Modification 1 /
//This program has been modified to display 3 mortgage loans,/
//7 year at 5.35%, 15 year at 5.5%, and 30 year at 5.75%, /
//using an array for the different loans. In addition, this /
//program will display the mortgage payment amount for each /
//loan. /
//Version 1.1 /
////////////////////////////////////////////////////////////////To set digits after decimal point//
import java.text.NumberFormat;class MortgageArray {
public static void main(String args[])throws InterruptedException
{
double principal = 200000; //Hardcoded amounts//
double []percent = new double [3];
percent[0] = 5.35/100;
percent[1] = 5.5/100;
percent[2] = 5.75/100;
short []nyears = new short[3];
nyears[0] = 7 ;
nyears[1] = 15;
nyears[2] = 30;
//Used to set two digits after decimal point//
NumberFormat fmt = NumberFormat.getInstance();
fmt.setMaximumFractionDigits(2);
fmt.setMinimumFractionDigits(2);
//Displays Results
System.out.println("\nPrincipal = $" + fmt.format(principal) + "\nInterest = "
+ percent[0] + "%"
+ "\nYears = " + nyears[0]);
System.out.println("Monthly Payments = $ " +fmt.format(pmt));
System.out.println("\nPrincipal = $" + fmt.format(principal) + "\nInterest = "
+ percent[1] + "%"
+ "\nYears = " + nyears[1]);
System.out.println("Monthly Payments = $"+fmt.format(pmt));
System.out.println("\nPrincipal = $" + fmt.format(principal) + "\nInterest = "
+ percent[2] + "%"
+ "\nYears = " + nyears[2]);
System.out.println("Monthly Payments = $"+fmt.format(pmt));
//Formula calculations to figure monthly payments//
//Principal= 200000*(5.75/(1-(1+5.75)^-360))//
//Reference Chou, H.(2000)US Mortgage formula//
double intmo = percent / 12;
int npmts = nyears * 12;
double pmt = principal * (intmo / (1 - Math.pow(1 + intmo, -npmts)));
}
}