5-3 CreditCard

posted Mar 8, 2014, 10:01 AM by Dlovan ismail   [ updated Mar 8, 2014, 10:02 AM by Karwan Jacksi ]
//This program uses two void methods.

package creditcard;
import javax.swing.JOptionPane;

public class CreditCard
{
    public static void main(String[] args) 
    {
            double salary;        // Annual salary
            int creditRating;   // Credit rating
            String input;           // To hold the user's input

            // Get the user's annual salary.
            input = JOptionPane.showInputDialog("What is your annual salary?");
            salary = Double.parseDouble(input);

            // Get the user's credit rating (1 through 10).
            input = JOptionPane.showInputDialog("on a scale of "
                    +"1 through 10, what is your credit rating?\n"
                    +"(10 = excellent, 1 = very bad)");
            creditRating = Integer.parseInt(input);

            // Determine whether the user qualifies.
            if (salary >= 20000 && creditRating >= 7)
                qualify();
            else
                noQualify();

            System.exit(0);

        }

        /*
        The qualify method informs the user that he
        or she qualifies for the credit card.
        */

        public static void qualify()
        {
            JOptionPane.showMessageDialog(null, "Congratulations! You qualify for the credit card!");
        }

        /*
        The noQualify method informs the user that he
        or she does not qualify for the credit card.
        */

        public static void noQualify()
        {
            JOptionPane.showMessageDialog(null, "I'm sorry. You do not qualify for the credit card.");
        }
    
}

ċ
CreditCard.java
(2k)
Karwan Jacksi,
Mar 8, 2014, 10:01 AM
Comments