
Please help me i need to finish this. my problem is in the error description.i need to calculate the price to liters when i click the button total.
output is:
price: 500
liters: 11.693... (500 / 42.76) i need to change the *= to /=. anyone know this?
Murugesh PPosted Mar 10, 2015, 7:53 AM
price = Convert.ToDouble(tcxtprice.Text); //You have to assign the text box value first
price /= diesel;
Murugesh PPosted Mar 10, 2015, 8:31 AM
Andariel SharpPosted Mar 10, 2015, 8:25 AM
Murugesh PPosted Mar 10, 2015, 8:24 AM
Andariel SharpPosted Mar 10, 2015, 8:15 AM
diesel /= price;
txtLiters.Text = Convert.ToString(price); to
price = Convert.ToDouble(txtLiters.Text);
price =/ diesel; there still an error.
Andariel SharpPosted Mar 10, 2015, 7:52 AM
Andariel SharpPosted Mar 10, 2015, 7:41 AM
Look it has the same output. diesel *= price; or price *= diesel; still the same i get 0 in Liter box.
Murugesh PPosted Mar 10, 2015, 7:33 AM
Ignore the previous suggestions.
---------------------------------------------------------------------------------------------------------------------Mark it as answer if it helps you.
Murugesh PPosted Mar 10, 2015, 7:30 AM
Murugesh PPosted Mar 10, 2015, 7:29 AM
Andariel SharpPosted Mar 10, 2015, 7:26 AM
take a look of this. :(
Murugesh PPosted Mar 10, 2015, 7:25 AM
Andariel SharpPosted Mar 10, 2015, 7:22 AM
Murugesh PPosted Mar 10, 2015, 7:12 AM
You could assign some default value for variable "price" while declaring.
EX:double price = 0.00;
Andariel SharpPosted Mar 10, 2015, 6:55 AM
Murugesh PPosted Mar 10, 2015, 6:25 AM
1.Remove const Key word before double diesel(If you declare something as constant you cannot change it, thats what the first error is about. it is Expecting a variable)
2 .txtprPrice.text = Convert.ToString(Price); try this to avoid second error(tctPrice.text expects a string value whereas price is not a string, so just convert it).