#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
double addition;
double subtraction;
double top, bottom;
double multiplication, multiplication2;
char variable;
double total = 0.0;
cout << "Type in:\n'A' For Addition\n"
<< "'S' For subtraction\n" << "'D' For division\n"
<< "'M' For multiplication\n";
cin >> variable;
switch (variable)
{
case 'A':
{
cout << "Enter 0 for input\n";
cin >> addition;
while(addition != 'Q' || addition != 'q')
{
cout << "Enter numbers for adding\nThen type in"
<< "Q or q to quit\n";
cin >> addition;
total += addition;
}
cout << "Your total is " << total << endl;
}
It loops infinitely starting out at the first cout statement in the while loop. I will type in numbers, then as soon as I type in q or Q and hit enter it will immediately loop infinitely. Thanks!
additionis bothQandqsimultaneously. So it never ends.doublevalue with a character literal like'Q'rarely makes sense.while(addition != 'Q' || addition != 'q')better use&&instead of||addition can't be both at the same time.additioncan't be bothqandQat the same time so no matter what your input is the condition is always true.