How to print a variable returned from some other method?
Joined: Feb 24, 2010
I actually missed one lecture in which our professor talked about methods. and I have an assignment to do, in which we can not ask for input or print anything in the methods but we can print and ask for input in the main program.
I tried to learn methods and their implementation in java on my own through various online sources, but I am not aware of how to print the new variable returned from some other method.
Below is my code. Right now, it gives me an error saying that "finalrate" could not be found.
The assigned problem is:
Create a module called Finance.java. Inside this module, write methods to perform the following tasks. You will have to write an appropriate method signature and also implement the method by writing code.
Compute Annual Percentage Yield (APY): Given an annual interest rate (on some kind of deposit account) and the number of times per year that interest compounds, compute the corresponding APY. (formula)
Compute monthly loan payment: Given a loan amount (principal), an annual interest rate, and the duration of the loan (in years), compute the monthly payment the borrower will have to pay. (formula)
These methods should not use the IO module at all. Declare arguments to each method to obtain inputs. Use the "return" statement to provide output.
Construct a set of test cases for your Finance methods, and write a driver program called FinanceDriver that executes your test cases by calling each method with the appropriate inputs. Write the expected output of each test case in a comment in your driver.
I am just working on the APY part of the problem right now..