Click here to Skip to main content
15,868,055 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Once I compile my program the following error occurs:

java:11: '{' expected
public class DebtRatioSwing.Java
^
java:40: '}' expected
}
^

//Both errors are located at the first and last curly braces.

What I have tried:

import javax.swing.JOptionPane;

public class DebtRatioSwing.Java
{
   public static void main(String[] args)
   {
         //Declaring Variables
         String strMonthlyIncome, strMortgage, strAutoLoan, strOtherDebt;
         double monthlyIncome, mortage, autoLoan, otherDebt;

         //Get Input from User
         strMonthlyIncome=JOptionPane.showInputDialog(null, "Enter your monthly income: ");
         strMortgage=JOptionPane.showInputDialog(null, "Enter amount spent on mortgages: ");
         strAutoLoan=JOptionPane.showInputDialog(null, "Enter amount spent on automobile loans: ");
         strOtherDebt=JOptionPane.showInputDialog(null, "Enter amount spent on other debt: ");


         //Conversions
         monthlyIncome = Integer.parseInt(strMonthlyIncome);
         mortgage = Integer.parseInt(strMortgage);
         autoLoan = Integer.parseInt(strAutoLoan);
         otherDebt = Integer.parseInt(strOtherDebt);

         //Calculations
         double ratio = (mortgage + autoLoan + otherDebt)/ monthlyIncome;

         //Output
         JOptionPane.showMessageDialog(null, "Your Debt Ratio is; " + (ratio) + ".", "Debt Ratio Calculator",JOptionPane.PLAIN_MESSAGE);

         System.exit(0);
      }
}
Posted
Updated 7-Aug-18 9:08am
v2
Comments
Paulo Zemek 6-Aug-18 18:41pm    
I think the problem is the dot in the class name: "DebtRatioSwing.Java"
I believe it is expecting the { where the dot appears.

Remove the "." character in the class name.
 
Share this answer
 
Thanks guys

The problem was that the class name wasn't saved correctly.
 
Share this answer
 

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



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