I am a beginner in java. My current assignment is to turn a previous code, into one that uses a GUI. Here is the previous code.
public class Tax {
public static void main(String[] args) {
//Variables
double RealHouseValue;
double AssessedValueRate;
int TaxDistrict;
double AssessedValue;
double PropertyTaxRate;
//Insert applicable numbers
RealHouseValue = 300000;
AssessedValueRate = .35;
TaxDistrict = 200;
AssessedValue = RealHouseValue*AssessedValueRate;
PropertyTaxRate = .03;
System.out.println("Actual House Value: $" + RealHouseValue); //Displays current house value
System.out.println();
System.out.println("Assessed Value Rate is: " + AssessedValueRate + " for tax district: " + TaxDistrict);
System.out.println();
System.out.println("Assesed Value: $" + AssessedValue);
System.out.println();
System.out.println("Local Property Tax Rate: " + PropertyTaxRate);
System.out.println();
System.out.println("Property Tax Due This Year: $" + AssessedValue*PropertyTaxRate);
What I want to do is have a box ask for the users actual house value, or "E" to exit. When the user inputs their house value, I want it to do the above calculation and output their property taxes due for the year. If they press "E", I want to print out "Good Bye", and stop running. Here's what I've got so far:
import javax.swing.JOptionPane; // Needed for the Scanner class
public class taxGui {
public static void main(String[] args) {
String custInput;
double realHouseValue;
double AssessedValueRate;
double AssessedValue;
double PropertyTaxRate;
//Insert applicable numbers
realHouseValue = 0.0;
AssessedValueRate = .35;
AssessedValue = realHouseValue*AssessedValueRate;
PropertyTaxRate = .03;
custInput = JOptionPane.showInputDialog("Enter your house value, or press 'E' to exit.");
realHouseValue = custInput.charAt(0);
if (realHouseValue > 0)
{
JOptionPane.showMessageDialog(null, "Your property tax due this year is: " + AssessedValue*PropertyTaxRate);
realHouseValue= custInput.charAt(0);
}
}
}
I am trying to get the realHouseValue to equal user input instead of 0.0 as declared. I have had a hell of a time with this class, Intermediate Object Oriented Programming. I have tried asking my professor questions, but his answers go right over my head. Any help would be appreciated. Sorry if the formatting or anything is off, this is my first post. Thank you for looking!
-Charles