unassigned use of variable
Hi all
was wondering if anyone can help me.
I have an equation with an unknown variable (i'm using the equation to get its value) but i am unsure on how to use it. here is some of the code
double acceptableProfit = callValidation.validatePrice(profitTxt.Text); //known
double ebay1 = callValidation.validatePrice(ebayCostTxt.Text); //known
double bprice = callValidation.validatePrice(boughtPriceTxt.Text); //known
double recommendedSPrice;
double ebay2 = recommendedSPrice/10;
double payPal = (2.4 * recommendedSPrice + 20)/100;
//to calculate the recommended sale price
acceptableProfit = recommendedSPrice - (ebay1 + bprice + ebay2 + payPal);
recommendedSPrice = acceptableProfit + ebay1 + bprice + ebay2 + payPal;
but obivously for me to use the variable i must define a value for it
Nilanka DharmadasaPosted Oct 19, 2009, 7:48 AM
double recommendedSPrice = (acceptableProfit + ebay1 + bprice - 20) / 87.6
Then using that value we can find the answers for following equations.
double ebay2 = recommendedSPrice/10;
double payPal = (2.4 * recommendedSPrice + 20)/100;
Yasmine AminPosted Oct 19, 2009, 5:57 AM
Kirtan PatelPosted Oct 17, 2009, 3:43 AM
I think you should initialize your recommendedSPrice=1 because you are using it in multiplication and division so initialize it as 1
use below code and
dont forget to mark "do you like this answer if it helped you :
//Assign Values 0 to Variable First
double acceptableProfit = 0, ebay1 = 0, ebay2 = 0;
double bprice = 0, recommendedSPrice = 1, payPal = 0;
//use thee Variables
acceptableProfit = callValidation.validatePrice(profitTxt.Text);
ebay1 = callValidation.validatePrice(ebayCostTxt.Text);
bprice = callValidation.validatePrice(boughtPriceTxt.Text);
ebay2 = recommendedSPrice / 10;
payPal = (2.4 * recommendedSPrice + 20) / 100;
//to calculate the recommended sale price
acceptableProfit = recommendedSPrice - (ebay1 + bprice + ebay2 + payPal);
recommendedSPrice = acceptableProfit + ebay1 + bprice + ebay2 + payPal;
jingePosted Oct 17, 2009, 2:57 AM
Yasmine AminPosted Oct 16, 2009, 9:34 AM
ebay2 = recommendedSalePrice/10 payPal = [2.4 * recommendedSalePrice + 20] Profit = recommendedSalePrice - (ebay1 + bPrice + ebay2 + paypal). i can solve the equation on paper i just dont know how write it in code..
jingePosted Oct 16, 2009, 7:22 AM
recommendedSPrice should give a value before using it.
Kirtan PatelPosted Oct 16, 2009, 7:22 AM
its better to initialize variable before using it :-)
see below corrected code :-)
dont forget to mark "do you like this answer" if my answer helped you :)
//Assign Values 0 to Variable First
double acceptableProfit = 0, ebay1 = 0, ebay2 = 0;
double bprice = 0, recommendedSPrice = 0, payPal = 0;
//use thee Variables
acceptableProfit = callValidation.validatePrice(profitTxt.Text);
ebay1 = callValidation.validatePrice(ebayCostTxt.Text);
bprice = callValidation.validatePrice(boughtPriceTxt.Text);
ebay2 = recommendedSPrice / 10;
payPal = (2.4 * recommendedSPrice + 20) / 100;
//to calculate the recommended sale price
acceptableProfit = recommendedSPrice - (ebay1 + bprice + ebay2 + payPal);
recommendedSPrice = acceptableProfit + ebay1 + bprice + ebay2 + payPal;