program problems

I am new to c++ and have a problem with this program. I have one choice weather the person is full time or part time and if they are full time they get on rate if the sale is above or below $ 10000000. The question I have is how to distinguish between part time and full and be able to use it later in the program.



#include <iostream>
#include <cctype>
#include <string>
using namespace std;




bool part_or_full()
{
cout << "What work time status are you part / full? ";
while (true)
{
string s;
cin >> ws;
getline(cin, s);
if (s.empty()) continue;
switch (toupper(s[0]));
{
case 'F': return true;
case 'P': return false;
}
cout << "Thank you but the two options are eith full or part";
}
}


int main()
{
double commEarned = 0.00;
double valSale = 0.00;
double totalSale = 0.00;
double rate = 0.00;

cout << "what is the total amount of your sales?";
cin >> totalSale;
{
if ('F' && totalSale <= 10000000)
rate = .035;


if ('F' && totalSale >= 10000000)
rate = .075;
else
rate = .05;

}

//calculations

commEarned = totalSale*rate;
valSale = totalSale - commEarned;


cout << "Your work status:" << endl;
cout << endl << endl;
cout << "Your total sales: $" << totalSale << endl;
cout << " Your companies profit is: $" << valSale << endl;
cout << "This is how much commission you received: $" << commEarned << endl;
system("pause");
return(0);


Thank you for any kind of help
I think this line switch(toupper(s[0])); should be switch(toupper(s[0])) // no semicolon . And I noticed that you created a function named part_or_full (which I assume you would be using in your code) but you didn't call it anywhere. Plus, I think you could use
1
2
3
4
5
6
	if('F' && totalSale <= 10000000)
		rate = .035;
	else if('F' && totalSale >= 10000000)
		rate = .075;
	else
		rate = .05;
instead of replicated ifs. You could even use scopes.

Anyway, I'm also a begginer I don't think I can point a direct solution (err, I may also be wrong for what I pointed out!) for your question but I hope I helped you.
Let's wait for someone more experienced than me so he/she can precisely help you out!
if ('F') is almost certainly not what you want.
Any non-zero value (including the character 'F') is interpreted as true. Thus it is a meaningless test here, since it will always be true.
Thank you for all your help. I am truly grateful...
Topic archived. No new replies allowed.