john corsic

Greenhorn
+ Follow
since May 14, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by john corsic

I've created a program that computes real estate commissions. The program prompts the user if they want to do a transaction. It then prompts them for the sale price and the property type (the property type corresponds with a certain rate). The program then calculates the commission and displays it. After the commission is displayed the program asks if you would like to do another transaction and continues to do so until the user selects no.
What I want to do is when the user selects no I want the program to display the total amount of the properties entered, and the total amount of the commissions calculated (both formatted as currency).

Also, if you have time. When the user enters an incorrect property type I want the program to say that it is an incorrect property type and to enter another one. I know how to display the message I just don't know how to go back to ask for the property type again.

Here is what i have done so far:


// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;

public class Calculator {
/** Main method */
public static void main(String[] args) {
double salePrice;
double commissionRate = 0;

while ( JOptionPane.showConfirmDialog(
null,
"Perform a transaction?",
"Continue",
JOptionPane.YES_NO_OPTION)==
JOptionPane.YES_OPTION ) {

// 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 Input", JOptionPane.QUESTION_MESSAGE);

if (propertyTypeString.equals ("R"))
commissionRate = 0.070;
else if (propertyTypeString.equals ("M"))
commissionRate = 0.060;
else if (propertyTypeString.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);


}
}
18 years ago
posted May 20, 2005 01:45 AM
--------------------------------------------------------------------------------
I've created a program that calculates real estate commission. The person inputs the sale amount and then enters a letter which represents a certain commission rate. It then calculates the commission and displays it. After the commission amount is displayed i want it to prompt the user for another transaction. When there are no more transactions i want the program to display the total amount of the properties entered, and the total amount of the commissions calcualted. I'm not too sure what to do. Should i use a while loop? Here is what i have done so far.
// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;

public class Calculator {
/** Main method */
public static void main(String[] args) {
double salePrice;
double commissionRate = 0;


// 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 Input", JOptionPane.QUESTION_MESSAGE);

if (propertyTypeString.equals ("R"))
commissionRate = 0.070;
else if (propertyTypeString.equals ("M"))
commissionRate = 0.060;
else if (propertyTypeString.equals ("C"))
commissionRate = 0.035;

// 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,
"Cakculator Output",
JOptionPane.INFORMATION_MESSAGE);

String transactionString = JOptionPane.showInputDialog (null,
"Would you like to do another transaction (YES or No)",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);

while (transactionString.equals ("YES"))

System.exit(0);

}
}
18 years ago
I actually want the program to ask the person if they would like to do another transaction. If they type in YES then the program will repeat. This is what i've done so far, but i'm still a little confused as how to repeat the program.

// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;

public class Calculator {
/** Main method */
public static void main(String[] args) {
double salePrice;
double commissionRate = 0;


// Enter sale price
String salePriceString = JOptionPane.showInputDialog (null,
"Enter sale price",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);

salePrice = Double.parseDouble(salePriceString);


while(salePrice == 0) continue;


// Enter property code (residential, multidwelling or commercial)
String propertyTypeString = JOptionPane.showInputDialog (null,
"Enter property code (residential (R), multidwelling (M) or commercial(C))",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);

if (propertyTypeString.equals ("R"))
commissionRate = 0.070;
else if (propertyTypeString.equals ("M"))
commissionRate = 0.060;
else if (propertyTypeString.equals ("C"))
commissionRate = 0.035;

// 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,
"Cakculator Output",
JOptionPane.INFORMATION_MESSAGE);

String transactionString = JOptionPane.showInputDialog (null,
"Would you like to do another transaction (YES or No)",
"Calculator Input", JOptionPane.QUESTION_MESSAGE);

while (transactionString.equals ("YES"))

System.exit(0);

}
}
18 years ago
I've created a program that calculates real estate commission. The person inputs the sale amount and then enters a letter which represents a certain commission rate. It then calculates the commission and displays it. After the commission amount is displayed i want it to prompt the user for another transaction. When there are no more transactions i want the program to display the total amount of the properties entered, and the total amount of the commissions calcualted. I'm not too sure what to do. Should i use a while loop? Here is what i have done so far.
// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;

public class Calculator {
/** Main method */
public static void main(String[] args) {
double salePrice;
double commissionRate = 0;

// 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 Input", JOptionPane.QUESTION_MESSAGE);

if (propertyTypeString.equals ("R"))
commissionRate = 0.070;
else if (propertyTypeString.equals ("M"))
commissionRate = 0.060;
else if (propertyTypeString.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);
}
}

[ EJFH: Removed a lot of extra whitespace ]
[ May 20, 2005: Message edited by: Ernest Friedman-Hill ]
18 years ago
Thank you very much Ernest for all the help. I finally figured it out thanks to your guideance.

Thanks again.
18 years ago
C:\JAVA\Calculator.java:42: variable commissionRate might not have been initialized
double commission = salePrice * commissionRate;
^
1 error

Tool completed with exit code 1

I did that and this is the error i get.
18 years ago
how would i go about doing this?
Sorry for all the questinons, I've just gotten into java and am a little confused
18 years ago
Yes, that's what i intended.
18 years ago
What wuuld you suggest?
18 years ago
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
18 years ago
I'm trying to create a program that will calculate real estate commission. The user must enter a sale price and a property code. There are 3 property codes (R,M,C) and each one represents a certain commission rate. I've been trying to figure it out, but i must be missing something. Take a look and let me know:

// 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 Input", JOptionPane.QUESTION_MESSAGE);




if (propertyType == 'R')
commissionRate = 0.070;
else if (propertyType == 'M')
commissionRate = 0.060;
else if (propertyType == 'C')
commissionRate = 0.035;
else{
JOptionPane.showMessageDialog (null,
"Error: Wrong property code, please try again",
"Calculator", 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);

}

}
18 years ago
Thanks for the help! I'm slowly on my way to figuring this out.

There are only three rates. I want the program to request the sale price of the property and then request the property code (the property code will correspond to a certain rate). Finally, i want it to calculate and display the commission based on the input. I am going to post the work I have done so far, if someone could please point me in the right direction.

Thanks again for all the help, i'm just a beginner.

// RealEstateCommission.java: Calculates real estate commissions
import javax.swing.JOptionPane;

public class Assignment2_1tests {
/** 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",
"Assignment2_1test 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))",
"Assignment2_1tests Input", JOptionPane.QUESTION_MESSAGE);




if (propertyType == 'R')
commissionRate = 0.070;
else if (propertyType == 'M')
commissionRate = 0.060;
else if (propertyType == 'C')
commissionRate = 0.035;
else{
JOptionPane.showMessageDialog (null,
"Error: Wrong property code, please try again",
"Assignment2_1tests 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,
"Assignment2_1tests Output",
JOptionPane.INFORMATION_MESSAGE);

System.exit(0);

}

}
18 years ago
I'm trying to create a program that calculate's real estate commission. I need certain property codes such as S,L, and M to represent different commission rates. How would i do this?
18 years ago