how could I put the values I displayed ( IN JAVA CODE ) in an array. as in what the user will see. (what is the best way to paste my code in here ) so you can view my code?
here is my code....I need the users to see the output values in an Array the javac compile works ,....the java does run in dos....it is just I need the output to be an array Code: import java.text.*; //20 May 2008, Revision ...many import java.io.IOException; class mortgage //program class name { public static void main(String[] args) throws IOException { double amount,moPay,totalInt,principal = 200000; //monthly payment, total interest and principal double rate [ ] = {.0535, .055, .0575}; //the three interest rates int [ ] term = {7,15,30}; //7, 15 and 30 year term loans int time,ratePlace = 0,i,pmt=1,firstIterate = 0,secondIterate = 0,totalMo=0; char answer,test; boolean validChoice; System.in.skip(System.in.available()); //clear the stream for the next entered character do { validChoice = true; System.out.println("What Choice would you Like\n"); System.out.println("1-Interest rate of 5.35% for 7 years?"); //The interest rate per each 3 loans , per line System.out.println("2-Interest rate of 5.55% for 15 years?"); //each number is the seletion that a user can select on the keyboard System.out.println("3-Interest rate of 5.75% for 30 years?"); System.out.println("4-Quit"); answer = (char)System.in.read(); if (answer == '1') //7 yr loan at 5.35% { ratePlace = 0; firstIterate = 4; secondIterate = 21; totalMo= 84; } else if (answer == '2') //15 yr loan at 5.55% { ratePlace = 1; firstIterate = 9; //it helps If I have the correct numbers to calcualte as in 9*20 to equal 180...that why I was off -24333.76 secondIterate = 20; //now it is only of -0.40 cents totalMo = 180; } else if (answer == '3') //30 yr loan at 5.75% { ratePlace = 2; firstIterate = 15; secondIterate = 24; totalMo = 360; } else if (answer == '4') //exit or quit { System.exit(0); } else { System.in.skip(System.in.available()); //validates choice System.out.println("Invalid choice, try again.\n\n"); validChoice = false; } }while(!validChoice); //when a valid choice is found calculate the following, ! means not, similar to if(x != 4) for(int x = 0; x < 25; x++)System.out.println(); amount = (principal + (principal * rate[ratePlace] * term[ratePlace] )); moPay = (amount / totalMo); totalInt = (principal * rate[ratePlace] * term[ratePlace]); DecimalFormat df = new DecimalFormat("0.00"); System.out.println("The Interest on $" + (df.format(principal) + " at " + rate[ratePlace]*100 + "% for a term of "+term[ratePlace]+" years is \n" +"$"+ (df.format(totalInt) +" Dollars\n"))); System.out.println("\nThe total amount of loan plus interest is $"+(df.format(amount)+" Dollars.\n")); System.out.println("\nThe Payments spread over "+term[ratePlace]* 12+" months would be $"+ (df.format (moPay) + " Dollars a month\n\n")); System.in.skip(System.in.available()); System.out.println("\nWould you like to see a planned payment schedule? y for Yes, or x to Exit"); answer = (char)System.in.read(); if (answer == 'y') { System.out.println((term[ratePlace]*12) + " monthly payments:"); String monthlyPayment = df.format(moPay); for (int a = 1; a <= firstIterate; a++) { System.out.println(" Payment Schedule \n\n "); System.out.println("Month Payment Balance\n"); for (int b = 1; b <= secondIterate; b++) { amount -= Double.parseDouble(monthlyPayment); System.out.println(""+ pmt++ +"\t"+ monthlyPayment + "\t"+df.format(amount)); } System.in.skip(System.in.available()); System.out.println(("This Page Is Complete Press [ENTER] to Continue")); System.in.read(); } } } }
I need the output to the users ( that they view ) be in an array how can I make this happen javac compiler works ...no issues...and the java in dos works.....I just need the output to be an array. Code: import java.text.*; //20 May 2008, Revision ...many import java.io.IOException; class memortgage //program class name { public static void main(String[] args) throws IOException { double amount,moPay,totalInt,principal = 200000; //monthly payment, total interest and principal double rate [ ] = {.0535, .055, .0575}; //the three interest rates int [ ] term = {7,15,30}; //7, 15 and 30 year term loans int time,ratePlace = 0,i,pmt=1,firstIterate = 0,secondIterate = 0,totalMo=0; char answer,test; boolean validChoice; System.in.skip(System.in.available()); //clear the stream for the next entered character do { validChoice = true; System.out.println("What Choice would you Like\n"); System.out.println("1-Interest rate of 5.35% for 7 years?"); //The interest rate per each 3 loans , per line System.out.println("2-Interest rate of 5.55% for 15 years?"); //each number is the seletion that a user can select on the keyboard System.out.println("3-Interest rate of 5.75% for 30 years?"); System.out.println("4-Quit"); answer = (char)System.in.read(); if (answer == '1') //7 yr loan at 5.35% { ratePlace = 0; firstIterate = 4; secondIterate = 21; totalMo= 84; } else if (answer == '2') //15 yr loan at 5.55% { ratePlace = 1; firstIterate = 9; //it helps If I have the correct numbers to calcualte as in 9*20 to equal 180...that why I was off -24333.76 secondIterate = 20; //now it is only of -0.40 cents totalMo = 180; } else if (answer == '3') //30 yr loan at 5.75% { ratePlace = 2; firstIterate = 15; secondIterate = 24; totalMo = 360; } else if (answer == '4') //exit or quit { System.exit(0); } else { System.in.skip(System.in.available()); //validates choice System.out.println("Invalid choice, try again.\n\n"); validChoice = false; } }while(!validChoice); //when a valid choice is found calculate the following, ! means not, similar to if(x != 4) for(int x = 0; x < 25; x++)System.out.println(); amount = (principal + (principal * rate[ratePlace] * term[ratePlace] )); moPay = (amount / totalMo); totalInt = (principal * rate[ratePlace] * term[ratePlace]); DecimalFormat df = new DecimalFormat("0.00"); System.out.println("The Interest on $" + (df.format(principal) + " at " + rate[ratePlace]*100 + "% for a term of "+term[ratePlace]+" years is \n" +"$"+ (df.format(totalInt) +" Dollars\n"))); System.out.println("\nThe total amount of loan plus interest is $"+(df.format(amount)+" Dollars.\n")); System.out.println("\nThe Payments spread over "+term[ratePlace]* 12+" months would be $"+ (df.format (moPay) + " Dollars a month\n\n")); System.in.skip(System.in.available()); System.out.println("\nWould you like to see a planned payment schedule? y for Yes, or x to Exit"); answer = (char)System.in.read(); if (answer == 'y') { System.out.println((term[ratePlace]*12) + " monthly payments:"); String monthlyPayment = df.format(moPay); for (int a = 1; a <= firstIterate; a++) { System.out.println(" Payment Schedule \n\n "); System.out.println("Month Payment Balance\n"); for (int b = 1; b <= secondIterate; b++) { amount -= Double.parseDouble(monthlyPayment); System.out.println(""+ pmt++ +"\t"+ monthlyPayment + "\t"+df.format(amount)); } System.in.skip(System.in.available()); System.out.println(("This Page Is Complete Press [ENTER] to Continue")); System.in.read(); } } } }
Code: import java.text.*; //20 May 2008, Revision ...many import java.io.IOException; class memortgage //program class name { public static void main(String[] args) throws IOException { double amount,moPay,totalInt,principal = 200000; //monthly payment, total interest and principal double rate [ ] = {.0535, .055, .0575}; //the three interest rates int [ ] term = {7,15,30}; //7, 15 and 30 year term loans int time,ratePlace = 0,i,pmt=1,firstIterate = 0,secondIterate = 0,totalMo=0; char answer,test; boolean validChoice; System.in.skip(System.in.available()); //clear the stream for the next entered character do { validChoice = true; System.out.println("What Choice would you Like\n"); System.out.println("1-Interest rate of 5.35% for 7 years?"); //The interest rate per each 3 loans , per line System.out.println("2-Interest rate of 5.55% for 15 years?"); //each number is the seletion that a user can select on the keyboard System.out.println("3-Interest rate of 5.75% for 30 years?"); System.out.println("4-Quit"); answer = (char)System.in.read(); if (answer == '1') //7 yr loan at 5.35% { ratePlace = 0; firstIterate = 4; secondIterate = 21; totalMo= 84; } else if (answer == '2') //15 yr loan at 5.55% { ratePlace = 1; firstIterate = 9; //it helps If I have the correct numbers to calcualte as in 9*20 to equal 180...that why I was off -24333.76 secondIterate = 20; //now it is only of -0.40 cents totalMo = 180; } else if (answer == '3') //30 yr loan at 5.75% { ratePlace = 2; firstIterate = 15; secondIterate = 24; totalMo = 360; } else if (answer == '4') //exit or quit { System.exit(0); } else { System.in.skip(System.in.available()); //validates choice System.out.println("Invalid choice, try again.\n\n"); validChoice = false; } }while(!validChoice); //when a valid choice is found calculate the following, ! means not, similar to if(x != 4) for(int x = 0; x < 25; x++)System.out.println(); amount = (principal + (principal * rate[ratePlace] * term[ratePlace] )); moPay = (amount / totalMo); totalInt = (principal * rate[ratePlace] * term[ratePlace]); DecimalFormat df = new DecimalFormat("0.00"); System.out.println("The Interest on $" + (df.format(principal) + " at " + rate[ratePlace]*100 + "% for a term of "+term[ratePlace]+" years is \n" +"$"+ (df.format(totalInt) +" Dollars\n"))); System.out.println("\nThe total amount of loan plus interest is $"+(df.format(amount)+" Dollars.\n")); System.out.println("\nThe Payments spread over "+term[ratePlace]* 12+" months would be $"+ (df.format (moPay) + " Dollars a month\n\n")); System.in.skip(System.in.available()); System.out.println("\nWould you like to see a planned payment schedule? y for Yes, or x to Exit"); answer = (char)System.in.read(); if (answer == 'y') { System.out.println((term[ratePlace]*12) + " monthly payments:"); String monthlyPayment = df.format(moPay); for (int a = 1; a <= firstIterate; a++) { System.out.println(" Payment Schedule \n\n "); System.out.println("Month Payment Balance\n"); for (int b = 1; b <= secondIterate; b++) { amount -= Double.parseDouble(monthlyPayment); System.out.println(""+ pmt++ +"\t"+ monthlyPayment + "\t"+df.format(amount)); } System.in.skip(System.in.available()); System.out.println(("This Page Is Complete Press [ENTER] to Continue")); System.in.read(); } } } }
Code: import java.text.*; //20 May 2008, Revision ...many import java.io.IOException; class memortgage //program class name { public static void main(String[] args) throws IOException { double amount,moPay,totalInt,principal = 200000; //monthly payment, total interest and principal double rate [ ] = {.0535, .055, .0575}; //the three interest rates int [ ] term = {7,15,30}; //7, 15 and 30 year term loans int time,ratePlace = 0,i,pmt=1,firstIterate = 0,secondIterate = 0,totalMo=0; char answer,test; boolean validChoice; System.in.skip(System.in.available()); //clear the stream for the next entered character do { validChoice = true; System.out.println("What Choice would you Like\n"); System.out.println("1-Interest rate of 5.35% for 7 years?"); //The interest rate per each 3 loans , per line System.out.println("2-Interest rate of 5.55% for 15 years?"); //each number is the seletion that a user can select on the keyboard System.out.println("3-Interest rate of 5.75% for 30 years?"); System.out.println("4-Quit"); answer = (char)System.in.read(); if (answer == '1') //7 yr loan at 5.35% { ratePlace = 0; firstIterate = 4; secondIterate = 21; totalMo= 84; } else if (answer == '2') //15 yr loan at 5.55% { ratePlace = 1; firstIterate = 9; //it helps If I have the correct numbers to calcualte as in 9*20 to equal 180...that why I was off -24333.76 secondIterate = 20; //now it is only of -0.40 cents totalMo = 180; } else if (answer == '3') //30 yr loan at 5.75% { ratePlace = 2; firstIterate = 15; secondIterate = 24; totalMo = 360; } else if (answer == '4') //exit or quit { System.exit(0); } else { System.in.skip(System.in.available()); //validates choice System.out.println("Invalid choice, try again.\n\n"); validChoice = false; } }while(!validChoice); //when a valid choice is found calculate the following, ! means not, similar to if(x != 4) for(int x = 0; x < 25; x++)System.out.println(); amount = (principal + (principal * rate[ratePlace] * term[ratePlace] )); moPay = (amount / totalMo); totalInt = (principal * rate[ratePlace] * term[ratePlace]); DecimalFormat df = new DecimalFormat("0.00"); System.out.println("The Interest on $" + (df.format(principal) + " at " + rate[ratePlace]*100 + "% for a term of "+term[ratePlace]+" years is \n" +"$"+ (df.format(totalInt) +" Dollars\n"))); System.out.println("\nThe total amount of loan plus interest is $"+(df.format(amount)+" Dollars.\n")); System.out.println("\nThe Payments spread over "+term[ratePlace]* 12+" months would be $"+ (df.format (moPay) + " Dollars a month\n\n")); System.in.skip(System.in.available()); System.out.println("\nWould you like to see a planned payment schedule? y for Yes, or x to Exit"); answer = (char)System.in.read(); if (answer == 'y') { System.out.println((term[ratePlace]*12) + " monthly payments:"); String monthlyPayment = df.format(moPay); for (int a = 1; a <= firstIterate; a++) { System.out.println(" Payment Schedule \n\n "); System.out.println("Month Payment Balance\n"); for (int b = 1; b <= secondIterate; b++) { amount -= Double.parseDouble(monthlyPayment); System.out.println(""+ pmt++ +"\t"+ monthlyPayment + "\t"+df.format(amount)); } System.in.skip(System.in.available()); System.out.println(("This Page Is Complete Press [ENTER] to Continue")); System.in.read(); } } } }