Help .. java in netbeans

antmiu2

Distinguished
Dec 16, 2008
4
0
18,510
can anybody help me with some java programs in netbeans:

1. a Java program to identify and deploy simple interest from the formula:

i = c * r * t / 360, where i = interest, capital = c, r = rate, t = time

2. a Java program that captures keyboard gross salary (SB) from an employee. The program should calculate and print the discount (D) using a 5% to Gross (SB) empleado.Asimismo of the program should calculate and display the net salary (SN) of the employee to perform the remainder of Gross (SB) less The discount (D)


some one said the first one is something like:

public class Main {
public static void main(String[] args) {

double p; // Principle
double r; // Rate example .06 = 6%
int t; // Year

p = 50000.00;
r = 0.05;
t = 1;

double answer = p * r * t / 360;

System.out.println(answer);
}

}
 

Zenthar

Distinguished
Dec 31, 2007
250
0
18,960
If by "help me", you mean "do it for me" ... no. I saw way too many bad developers get a diploma to help it. However, if you have specific question like "Why does this code give me the wrong answer?" and "How do I do this specific operation?", then I will answer any question you have.

First, you can use the [ code ] tag to show code, it is much better as it preserves spacing and even numbers the lines for you so people can reference the code directly:
Code:
public class Main {
    public static void main(String[] args) {
        
        double p; // Principle
        double r; // Rate example .06 = 6%
        int t; // Year
        
        p = 50000.00;
        r = 0.05;
        t = 1;
        
        double answer = p * r * t / 360;
        
        System.out.println(answer);
    }
}

For your first task, the above code does work, you would know if you tried it. If you can, I would put it in a separate function so it it "reusable". Also make sure you of the units used for every parameter (capital and interest in $, rate as a simple real number between 1 (100%) and 0 (0%) and time in years?). Was the interest formula given to you or did you come-up with it? It would "work", but it isn't the "real" interest rate formula (which is a bit more complicated).

For the second task, you can find how to read from keyboard here (found using google, learn to search, it will be your best developer asset). To convert from String to whatever other type, look at the Integer.parseInt(String) and Double.parseDouble(String).