vendredi 30 janvier 2015

JOptionPane and If Statements

I am writing a program for my class and the program compiles and runs. There doesn't seem to be anything wrong with the logic in my "IF Statements" however, each time I get the same results no matter what values I enter for Growth Rate and Inflation. Does anyone see where I am going wrong.


Code:



import java.util.Scanner;
import javax.swing.JOptionPane;

public class Economy
{

public static void main(String[] args)
{
Scanner stdIn = new Scanner(System.in);
double GrowthRate=0; // Economic Growth Rate
double Inflation=0; // Inflation Rate


JOptionPane.showInputDialog ("Enter the Growth Rate % (as a whole number): ");

// System.out.print("Enter the Growth Rate % (as a whole number): ");
//GrowthRate = stdIn.nextDouble();

JOptionPane.showInputDialog ("Enter the Inflation Rate % (as a whole number): ");

//System.out.print("Enter the Inflation Rate % (as a whole number): ");
//Inflation = stdIn.nextDouble();
//System.out.print ("Based on the above information, you should: \n\n");

//First If
if (GrowthRate < 1 && Inflation < 3){
JOptionPane.showMessageDialog(null, "Increase welfare spending, reduce personal taxes, and decrease discount rate.");
}
else
{
JOptionPane.showMessageDialog(null, "Reduce business taxes.");
}
//Second If
if (GrowthRate > 4 && Inflation < 1){
JOptionPane.showMessageDialog(null, "Increase personal and business taxes, and decrease discount rate.");
}

//Third If
if (Inflation > 3 ){
JOptionPane.showMessageDialog(null, "Increase discount rate.");
}




}
} // end main

Aucun commentaire:

Enregistrer un commentaire