15,566,390 members
See more:
Write a program in JAVA that performs several steps to obtain a loan, as follows:
A. Introduction of loan value, interest and repayment months
B. Calculation of interest in one month
C. Calculation of payment in one month
The above calculation operations should be performed with functions that do not return a value (void).

What I have tried:

```package Algorithms;
import java.util.Scanner;

public class exercise {
public static void InterestMonthly (double n) {
double AnnualInterest = 0;
AnnualInterest / = 100.0;
double MonthlyInterest = AnnualInterest / 12;
}

public static void KestiMujor (double n) {
double Principal = 0, MonthlyInstallment = 0, MonthlyInterest = 0, NumberofMonths = 0;
double MonthlyInstallment = Principal * MonthlyInterest / (1 - Math.pow (1 + MonthlyInterest,
-NumberMonths));
}

public static void main (String [] args) {
Scanner input = new Scanner (System.in);
System.out.print ("Annual loan interest rate (in%):");
double InterestAnnual = input.nextDouble ();
System.out.println ("");
System.out.print ("Loan maturity period (NumberofMonths):");
int NumberofMonths = input.nextInt ();
System.out.println ("");
System.out.print ("Credit Principal: All");
double Principal = input.nextDouble ();
System.out.println ("");
double n;
System.out.println ("Monthly Credit Installment is Euro" + MonthlyInstallment);
System.out.println ("Monthly loan interest in% is:" + MonthlyInterest (n) * 100.0 + "%");
System.out.println ("Monthly cash loan interest is:" + MonthlyInterest (n) *
MonthlyInstallment + "Euro");
}
}```
Posted
Updated 27-May-22 8:05am
Xxx Yyy 2022 27-May-22 10:49am
Please sm help ASAP
Xxx Yyy 2022 27-May-22 10:49am
My deadline is near
Richard MacCutchan 27-May-22 10:51am
You will not get any help unless you explain what your problem is; we cannot guess.
Xxx Yyy 2022 27-May-22 11:04am
there is a problem on my void method
Xxx Yyy 2022 27-May-22 11:04am
it doesn't run

## Solution 1

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

And looking at your code, you haven't done anything much at all. Your methods are useless because they only work with local variables that are discarded when the method exits, and they don't use the value you pass to them at all - but that's ok because you don't assign it a value before you call the methods anyway!

To be honest, that looks like you threw some code at your screen without thinking about what you were trying to do at all, and hoped that either it would magically work or someone else would re-write it for you so it did
Neither of those things is likely to happen. Ever.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

## Solution 2

If a function that calculates a result must return void, the general approach is to provide the result in an argument that the function can update. In Java, you'll have to define an object that contains the result, pass the object to the function, and have the function update the result within the object.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Top Experts
Last 24hrsThis month
 OriginalGriff 100 Graeme_Grant 50 Dave Kreskowiak 40 Richard Deeming 25 longjmp 10
 OriginalGriff 330 Dave Kreskowiak 185 Graeme_Grant 165 Richard MacCutchan 140 k5054 120

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900