Sign in with
Sign up | Sign in
Your question

Help .. java in netbeans

Last response: in Applications
Share
May 27, 2009 11:37:23 AM

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);
}

}

More about : java netbeans

a b L Programming
May 27, 2009 3:48:14 PM

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:
  1. public class Main {
  2. public static void main(String[] args) {
  3.  
  4. double p; // Principle
  5. double r; // Rate example .06 = 6%
  6. int t; // Year
  7.  
  8. p = 50000.00;
  9. r = 0.05;
  10. t = 1;
  11.  
  12. double answer = p * r * t / 360;
  13.  
  14. System.out.println(answer);
  15. }
  16. }


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).
!