I created a program, that calculates volume of prism and area of rectangle. But I want user to decide how how long he wants to work with this programm:
#include <iostream>
using namespace std;
int main()
{
bool run = true;
while(run = true){
double len,width,area,volume,height;
char check;
cout << "Please, enter length,width and height of a prism(rectangular)!";
cin >> len >> width >> height;
area = width*len;
volume = area*height;
cout << "The area of rectangle is equal to: " << area << "\n" << "The volume of rectangular prism is equal to: " << volume << "\n";
cout << "Do you want to try again?(y/n)\n";
cin >> check;
while(check != 'y'|| check != 'n'){
cout <<"Please enter y or n\n";
cin >> check;
}
if(check == 'n'){
run = false;
break;
}
}
return 0;
}
In the first part everything works fine, but I cannot get out of this loop:
while(check != 'y'|| check != 'n'){
cout <<"Please enter y or n\n";
cin >> check;
}
Where did I do the mistake and how can I fix it?