Hey! I'm working on a practice program and i ran into a problem! I've looked around , and i'm pretty sure that this should work, but i really can't figure out why it doesn't!
1 2 3 4 5 6 7 8 9 10
while (total != 3.50){
if (total < 3.50){
cout << "Insert coin: ";
cin >> inserted; //inserted is a double
while ((inserted != 1.00) || (inserted != 0.25)){
cout << "Please insert correct denominations: ";
cin >> inserted;
}//Even if I insert 1.00 or 0.25, the loop keeps on going
total += inserted;
}
Thanks for the article! It looks like an informative read!
But quick question, doesn't that mean that the first while loop while (total != 3.50) // total is a double as well
shouldn't work either?
while ((inserted != 1.00) || (inserted != 0.25)){
cout << "Please insert correct denominations: ";
cin >> inserted;
}//Even if I insert 1.00 or 0.25, the loop keeps on going
It works now! Thank you very much! But if you don't mind me asking, I get how it works kind of, but isn't the logic behind && that if one statement is true and the other is false, it returns false? So if i put 0.25, that means that the first statement is false, but the second is true. Shouldn't that return false with an and?