Oh well, when the hell did English make any sense anyway?Originally Posted by comwiz
I don't think it was mentioned, but relook at that line.Code:if ( cleaning = 'Y' || 'y')
Oh well, when the hell did English make any sense anyway?Originally Posted by comwiz
I don't think it was mentioned, but relook at that line.Code:if ( cleaning = 'Y' || 'y')
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
No, You need spelling. What if you spell "red" wrong and your page comes out purple? Oh NO!
but it is only for a quarter.
It was.Originally Posted by Dae
Sent from my iPadŽ
There is an edit button.
He was being sarcastic (see my quote).
++postcount;
Edit: Oh, I see Sly. >.<
Warning: Have doubt in anything I post.
GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101
OK, how would I check my dataOk variable?Originally Posted by SlyMaelstrom
Code:if (dataOK)
Code:#include <iostream> using namespace std; int main () { string name; //input variaable for patient's name string::size_type namlen; // used for determining string size char xray; //input variable for x-ray char cavity; //input variable for cavity filling char cleaning; //input variable for cleaning float xbill; //input variable for xray bill float cavbill; //input variable for cavity filling bill float cbill; //input variable for cleaning bill float totalbill; // sum of all services performed bool dataOk; // True if data is correct // Prompt for patient's name and services performed cout << "Enter patient's name: "; getline (cin, name); cout << " Was cleaning performed? (Y or y = yes, N or n = no): "; cin >> cleaning; cout << " Was an x-ray performed? (Y or y = yes, N or n = no): "; cin >> xray; cout << " Was a cavity filling performed? (Y or y = yes, N or n = no): "; cin >> cavity; // Testing section namlen = name.length(); if (namlen < 4) // make sure a name is entered { cout << "Must input name."; // if no name over 4 characters, display this return 1; // end program } // Testing section for services if (cleaning == 'Y' || cleaning == 'y' || cleaning == 'N' || cleaning == 'n') dataOk = true; else dataOk = false; if (xray == 'Y' || xray == 'y' || xray == 'N' || xray == 'n') dataOk = true; else dataOk = false; if (cavity == 'Y' || cavity == 'y' || cavity == 'N' || cavity == 'n') dataOk = true; else dataOk = false; if ( dataOk) // if above is found true, move on to next part { // Assigning values to billing if ( xray == 'Y'||'y') //if the input for xray was "Y" or "y" assign 200.00 to xbill xbill = 200.00; else xbill = 0.00; if ( cleaning == 'Y' || 'y') //if the input for xray was "Y" or "y" assign 50.00 to cbill cbill = 50.00; else cbill = 0.00; if ( cavity == 'Y' || 'y') //if the input for xray was "Y" or "y" assign 150.00 to cavbill cavbill = 150.00; else cavbill = 0.00; } else //if the input is not a "Y", "y", "N", or "n" { cout << "Must answer Y or y or N or n to all questions."; return 2; } totalbill = xbill + cbill + cavbill; //total bill // display output ;cout << "Patient's name " << name; ;cout << "Cleaning Charge is " << cbill; ;cout << "Cavity filling charge is " << cavbill; ;cout << "X-ray charge is " << xbill; ;cout << "Total bill for services is: " << totalbill; return 0;
}
OK, this is my entire program. The good news is that at this point if the wrong type of data is entered it stops, the bad it doesn't assign values based on imputs. any ideas?
look at // Testing section for services
and see what is different in // Assigning values to billing
Originally Posted by Syneris
Aiya!!! Thank you so much!!
I do have one more question. My output screen has all the information running together, when i'd rather have it list line by line. how do i get that?
To create a new line, you have two choices (that I know of):
The newline character '\n', which creates a new line, or endl, which creates a new line and flushes the output buffer.
Example:
OutputCode:cout << "stuff"; cout << "new line\n"; cout << new line << endl;
Code:stuffnew line new line
There is a difference between tedious and difficult.
Newline
And there is a problem with your dataOK in // Testing section for services
I could enter any invalid answer for the first 2 questions. If I answer yes to the 3rd then the bill would be 150. If i answer no to the 3rd then my bill would be 0.
Can loops be used?
No loops can't be used. Loops is in our next chapter though. Do you have any ideas? Keep in mind this is a beginning programming class.Originally Posted by Syneris