| Dionisseus (4) | |
|
Hi im new to c++ and to this forum, and im sure this will be an easy topic to answer but im really losing my head around this problem that i have i want to ask for a number between 0 and 9999 and if any other number that is not between that range is given, return and ask for the number again and i would like to also loop it if you input a char. thanks in advance for the help #include <iostream> #include <conio.h> #include <string> using namespace std; struct bazzinga{ string name; string console; float price; string tipo; char bar[7]; } videogame[9]; do{ cout<<endl<<"Introdusca el precio de "<<videogame[i].name<<endl<<"$"; cin>>videogame[i].price; if (videogame[i].price<=0 && videogame[i].price>=9999) cout<<"Precio invalido \n\n Precio debe ser entre 0 y 9999 creditos Videogame. \n Intentelo de nuevo."<<endl; }while (videogame[i].price<=0 && videogame[i].price>=9999); | |
|
|
|
| Stewbond (1670) | |
This line is wrong:(videogame[i].price<=0 && videogame[i].price>=9999)You will NEVER have a case where the price is less than 0 and greater than 9999. Try using the || operator. | |
|
|
|
| reddeffect (2) | |
|
if (videogame[i].price<0 || videogame[i].price>9999) | |
|
|
|