Thanks ernest for the help, I did what you said, but it still doesn't work. Here is what it looks like now and i've also included the error message at the end.
// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;
public class Calculator{
/** Main method */
public static void main(String[] args) {
double salePrice;
char propertyType = ('R', 'M', 'C');
double commissionRate;
// Enter sale price
String salePriceString = JOptionPane.showInputDialog (null,
"Enter sale price",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);
salePrice = Double.parseDouble(salePriceString);
// Enter property code (residential, multidwelling or commercial)
String propertyTypeString = JOptionPane.showInputDialog (null,
"Enter property code (residential (R), multidwelling (M) or commercial(C))",
"Calculator", JOptionPane.QUESTION_MESSAGE);
if (propertyType.equals ("R"))
commissionRate = 0.070;
else if (propertyType.equals ("M"))
commissionRate = 0.060;
else if (propertyType.equals ("C"))
commissionRate = 0.035;
else{
JOptionPane.showMessageDialog (null,
"Error: Wrong property code, please try again",
"Calculator Output", JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
// Calculate commission
double commission = salePrice * commissionRate;
// Format to keep two digits after the decimal point
commission = (int)(commission * 100) / 100.0;
// Show results
JOptionPane.showMessageDialog(null,
"the commission is" + commission,
"Calculator Output",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
C:\JAVA\Assignment2_1tests.java:8: ')' expected
char propertyType = ('R', 'M', 'C');
^
1 error
Tool completed with exit code 1