/*
   Chapter 3:     Programming Assignment 5
   Programmer:    Brad Shedd
   Date:          January 29, 2004
   Program Name:  DebtRatioApplet.java
   Purpose:       This project will compare a customer's income to debt.
*/

import javax.swing.JOptionPane;

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

     
//Declaring Variables
      String strMonthlyIncome;
      String strMortgage;
      String strAutoLoan;
      String strOtherDebt;
     
double monthlyIncome, mortgage, autoLoan, otherDebt, ratio;

     
//print prompts and get input
      System.out.println("\tINCOME TO DEBT RATIO CALCULATOR");
      strMonthlyIncome=JOptionPane.showInputDialog(
null,
     
"Enter amount of monthly income: ");
         monthlyIncome = Integer.parseInt(strMonthlyIncome);
      strMortgage=JOptionPane.showInputDialog(
null,
     
"Enter amount of mortgage or rent (or zero): ");
         mortgage = Integer.parseInt(strMortgage);
      strAutoLoan=JOptionPane.showInputDialog(
null,
     
"Enter amount of auto loan (or zero): ");
         autoLoan = Integer.parseInt(strAutoLoan);
      strOtherDebt=JOptionPane.showInputDialog(
null,
     
"Enter amount of other debt (or zero): ");
         otherDebt = Integer.parseInt(strOtherDebt);

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

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

     
//Output
      System.out.println("Your debt ratio is "+ ratio);

   System.exit(0);

   }
}

Homepage