Troubleshooting Final Balance Calculator Program

In summary: If you don't get any error messages, then enter> java FinalBalanceCalculatorIf you get error messages, then its your code. If it works, then it's probably something to do with Jgrasp.
  • #1
bomba923
763
0
Why won't this work? :frown:
----------------------------------------
import javax.swing.JOptionPane ;

public class FinalBalanceCalculator {

public static void main(String args[]) {

String input;
String name;
double b0;
double rc;
double ty;
double ans;

input = JOptionPane.showInputDialog("What is your name?") ;
name = input ;

input = JOptionPane.showInputDialog("What is your interest rate?") ;
rc = Double.parseDouble(input);

input = JOptionPane.showInputDialog("What is your initial balance?" );
ty = Double.parseDouble(input) ;

ans = Math.pow(1 + rc,ty) * b0 ;

System.out.PrintIn(name + "has an initial balance of $" + b0 + ",") ;
System.out.PrintIn("which is compounded annually at " + rc + "%") ;
System.out.PrintIn("After " + ty + " years, " + name + " will have exactly:") ;
System.out.PrintIn("$" + ans ) ;

}//main
}//FinalBalanceCalculator
 
Last edited:
Computer science news on Phys.org
  • #2
Errors would be nice.

bomba923 said:
Why won't this work? :frown:
----------------------------------------
import javax.swing.JOptionPane ;

public class FinalBalanceCalculator {

public static void main(String args[]) {

String input;
String name;
double b0;
double rc;
double ty;
double ans;

input = JOptionPane.showInputDialog("What is your name?") ;
name = input ;

input = JOptionPane.showInputDialog("What is your interest rate?") ;
rc = Double.parseDouble(input);

input = JOptionPane.showInputDialog("What is your initial balance?" );
ty = Double.parseDouble(input) ;

ans = Math.pow(1 + rc,ty) * b0 ;

System.out.PrintIn(name + "has an initial balance of $" + b0 + ",") ;
System.out.PrintIn("which is compounded annually at " + rc + "%") ;
System.out.PrintIn("After " + ty + " years, " + name + " will have exactly:") ;
System.out.PrintIn("$" + ans ) ;

}//main
}//FinalBalanceCalculator
 
  • #3
I don't program in Java so I could be missing something, but in your input you define ty as the initial balance, in the output you say ty is the number of years and b0 is never defined in the input, but is the initial balance in the output. So me thinks you need b0 for initial balance (not ty) and you need to add a statement to get the number of years (ty) in the input.
 
  • #4
:smile: Thanx, I fixed it as :
---------------------------------
import javax.swing.JOptionPane ;

public class FinalBalanceCalculator {

public static void main(String args[]) {

String input;
String name;
double b0;
double rc;
double ty;
double ans;

input = JOptionPane.showInputDialog("What is your name?") ;
name = input ;

input = JOptionPane.showInputDialog("What is your initial balance?" );
b0 = Double.parseDouble(input) ;

input = JOptionPane.showInputDialog("What is your interest rate?") ;
rc = Double.parseDouble(input );

input = JOptionPane.showInputDialog("How long will you keep this money?" );
ty = Double.parseDouble(input) ;

ans = Math.pow(1 + rc,ty) * b0 ;

System.out.PrintIn(name + "has an initial balance of $" + b0 + ",") ;
System.out.PrintIn("which is compounded annually at " + rc + "%") ;
System.out.PrintIn("After " + ty + " years, " + name + " will have exactly:") ;
System.out.PrintIn("$" + ans ) ;

}//main
}//FinalBalanceCalculator
-------------------------------------
*It appears on the error sheet that there is a problem with the compiler, javac.exe
and it cannot be found. I download "JDK5.0 Update 4" and programmed with Jgrasp,
but do I need an additional compiler where I download elsewhere?
(a sort of path problem, in regards to a javac.exe missing from a "working directory")
 
  • #5
System.out.PrintIn should be System.out.println

i.e. the "I" should be an "l"


Also, you have a decimal point problem in your interest rate calculation, but you can figure that out for yourself.
-------------
I don't know anything about Jgrasp (I've never used it), but your compiler problem may be just that your java bin directory is not listed in your path (in your environment variables).
Or maybe there's some problem with your installation of Jgrasp.
Have you tried to compile from the Dos command line? Open a DOS Command Prompt window, chdir to the directory that contains your java source code and enter:

> javac FinalBalanceCalculator.java
 

What is a Final Balance Calculator Program?

A Final Balance Calculator Program is a computer program that is used to calculate the final balance of an account. It takes into account various factors such as deposits, withdrawals, interest rates, and time periods to provide an accurate calculation of the final balance.

Why is my Final Balance Calculator Program not working?

There could be several reasons why your Final Balance Calculator Program is not working. Some common reasons include entering incorrect data, using outdated software, or having a bug in the program. It is important to double-check your inputs and make sure you are using the latest version of the program. If the issue persists, you may need to contact technical support for further assistance.

How accurate is the Final Balance Calculator Program?

The accuracy of the Final Balance Calculator Program depends on the accuracy of the data entered. If the input data is correct, the program should provide an accurate calculation of the final balance. However, it is always a good idea to double-check the results to ensure accuracy.

Can I use the Final Balance Calculator Program for different types of accounts?

Yes, most Final Balance Calculator Programs are designed to work for various types of accounts, such as checking, savings, and investment accounts. However, it is important to check the program's specifications to ensure it is compatible with the type of account you are using.

Do I need any special skills to use the Final Balance Calculator Program?

No, the Final Balance Calculator Program is designed to be user-friendly and easy to use. However, some basic math skills and knowledge of financial terms may be helpful in understanding the results. Most programs also provide instructions on how to use the program effectively.

Similar threads

  • Programming and Computer Science
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
1
Views
749
  • Engineering and Comp Sci Homework Help
Replies
12
Views
1K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
2
Views
2K
  • Precalculus Mathematics Homework Help
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
6K
  • Programming and Computer Science
Replies
1
Views
2K
Back
Top