ok I have a program that is suppose to use dialogs boxes to obtain input and display output and also use console input an output. But here is the thing, I believe my code is a little right but don't understand the errors, can somebody help me please, here is my code:

//Input: to obtain interest
//Process:  Calculate interest by balance and annual interest rate
//Output:Display interest in dialog and console input and out put 
//Purpose: to obtain interest 

public class Interest {
     public static void main(String [] args) {
      //creat a scanner for input
      java.util.Scanner keyboard = new java.util.Scanner(System.in);
      //declare variables
      double annualInterestRate;
      double balance;
      double interest;
      //Enter annual interest rate
      double annualInterestRate = keyboard.nextDouble(letters);
      //Enter balance
      balance = keyboard.nextDouble(numbers);
      //declare interest
      interest = keyboard.nextDouble(symbol);
      //Calculate payment
      interest = balance * (annualInterestRate / 1200);
      //Format to keep to decimal points
      interest = (int)(interest * 100) / 100.0;
      //Input results 
      String letters = javax.swing.JOptionPane.showInputDialog("Enter annual interest");
      String numbers = javax.swing.JOptionPane.showInputDialog("Enter balance");
      //Display results
      System.out.println("The interest is " + interest);
      javax.swing.JOptionPane.showMessageDialog(null, "output data");
      }
}

You defined annualInterestRate twice

The variables number, symbol and letters are not defined before you attempt to use them with nextDouble also nextDouble does not take any params.

I fixed it up but it is still not working, what is wrong, there are no errors?????

It wont read in the command prompt

public class Interest {
     public static void main(String [] args) {
      //creat a scanner for input
      java.util.Scanner keyboard = new java.util.Scanner(System.in);
      //declare variables
      double annualInterestRate = 9;
      double balance = 5;
      double interest;
      //Enter annual interest rate
      annualInterestRate = keyboard.nextDouble();
      //Enter balance
      System.out.print("Enter balance");
      balance = keyboard.nextDouble();
      //declare interest
      System.out.print("Enter annual interest");
      interest = keyboard.nextDouble();
      //Calculate payment
      interest = balance * (annualInterestRate / 1200);
      //Format to keep to decimal points
      interest = (int)(interest * 100) / 100.0;
     
      //Display results
      System.out.print("The interest is " + interest);
      javax.swing.JOptionPane.showMessageDialog(null, interest);
      }
}

Also, did I do the code right or do I doing something wrong even though it is complete with no errors?

Your application is working for me, You do not prompt the user to enter the annualInterestRate, Although this is the first value you require.

You also prompt again for the annualInterest later, Perhaps you should only ask for this once.

Other then that it appears to be working fine, As well as I can tell, I am promted for my balance then my interest rate, then the applicaiton tells me how much interest i will make in a year and then pops it up using a dialog box.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.