| A New Income |
A NEW INCOMEA New Income Q&A
Q: Below is a program.. i cant figure out how to return the info in the return statement.. HELP? import java.util.Scanner; public class CaseStudyPart3 { public static void main(String[] args) { //declare variables Scanner reader = new Scanner(System.in); double disposableIncome; //TO DO: Gather the user's monthly disposable income System.out.println("Enter disposable income "); disposableIncome = reader.nextDouble(); //process first debt and get new value for remaining // disposable income disposableIncome = processDebt(disposableIncome); //TO DO: Process second and third debts and get //value for remaining disposable income //TO DO: Display the final amount of //disposable income } public static double processDebt(double disposableIncome) { //declare variables Scanner reader = new Scanner(System.in); double debtBalance; double interestRate; double minimumPayment; double paymentAmount; double finalBalance; double principalPaid; double interestPaid; String debtName; System.out.println("\n\nENTERING A SINGLE DEBT\n"); System.out.println("----------------------------"); System.out.println("Enter a name for this debt: "); debtName = reader.next(); //TO DO: gather inputs(debtBalance, interestRate, and // minimum payment). System.out.println("Enter debt balance "); debtBalance = reader.nextDouble(); System.out.println("Enter interest rate "); interestRate = reader.nextDouble(); System.out.println("Enter minimum payment "); minimumPayment = reader.nextDouble(); //TO DO: calculate amount of disposable income //to use on debt. paymentAmount = minimumPayment; //TO DO: calculate the amount of interest that //will be added to the debt during the month. //This will also be the amount of interest //that will be paid for the month. interestPaid = (interestRate / 12) * debtBalance; //TO DO: calculate the amount of principal that //will be paid for the month. principalPaid = paymentAmount - interestPaid; //TO DO: calculate the final balance of the debt //at the end of the month. finalBalance = (debtBalance + interestPaid) - paymentAmount; //Display output System.out.println("Debt Name: " + debtName); //TO DO: display the results (paymentAmount, //finalBalance, principalPaid, and //interestPaid). System.out.println("The amount of disposable income to use on the debt is $" + paymentAmount); System.out.println("The amount of interest that will be paid for the month is $" + interestPaid); System.out.println("The amount of principal that will be paid for the month is $" + principalPaid); System.out.println("The final balance at the end of the month is $" + finalBalance); //TO DO: return the amount of disposable income //left after the payment is made. return disposableIncome - finalBalance; } } i do have disposableIncome being input in the program.. do i need to have it with the second set of coding?? it doesnt return anything A: You can't return the info. main(String[] args) is public static void. And void methods cannot return anything.
|
© 2010 anewincome.com Contact us - Q&A powered by Yahoo! Answers
| A New Income |