While statement not working?

前端 未结 2 1443
北恋
北恋 2021-01-29 12:43
#include 
#include 
using namespace std;
int main()
{
    int number;
    float cost;
    char beverage;

    bool validBeverage;

    cou         


        
2条回答
  •  逝去的感伤
    2021-01-29 12:51

    Change

    while(beverage!='e'||beverage!='E'); // Condition becomes true always 
    

    to

    while(beverage!='e'&& beverage!='E');  
    

    And similarly replace all || by && in first while loop conditional expression

    while(beverage!='A' && beverage!='B' &&beverage!='C'&& beverage!='D' && beverage!='E' && beverage!='a' && beverage!='b' && beverage!='c' &&
         beverage!='d' && beverage!='e')
    

提交回复
热议问题