Hello BennysMaria,
Looking over the program at this point I see no use for "cmath". If you plan on using the functions "abs()", "pow()", "sqrt()", "sin()", tan()" or others then you would need "cmath". If you would be using just (+, -, *, / or %) then "cmath" is not needed as these are built into the IDE/compiler and always available.
It is always a good idea to initialize your variables when defined. If for no other reason than to know that they do not contain a garbage value.
1 2 3 4 5 6 7 8 9 10
|
//Declare variable
char answer{};
int storageCapacity{};
double years{};
double costPerMonth{};
double yearlyCost{};
bool freeTheme{ true };
bool customDesign{}; // <--- From C++11 on this is all you need.
bool seoTools = false; // <--- This is extra work that does the same as above.
bool liveSupport = false;
|
The empty {}s, available from C++11 on, will set the variable to (0) zero based on the type of variable.
Since "freeTheam" is available to each plan you can set this one to true and then you do not need to ask any question about it.
"double" is the preferred choice for a floating point type, but even a "double" can have problems. From what I can see for now an "int" would work just fine as you are only using whole numbers.
For your if statements.
I used this as an example, but it is not needed because "freeTheam" is set to true and available to every plan.
1 2 3 4 5 6 7 8 9 10 11
|
cout << "\t\n 1.) Would you like to utilize free themes? (y/n)" << endl;
cin >> answer;
if (answer = 'y') // <--- But what if the user typed 'Y'? You should have "if (answer =='y' || answer == 'Y')"
{
freeTheme = true;
}
else
{
freeTheme = false;
}
|
As the comment shows you should check for either case of the letter. Any given user will break your program without even trying. Best to try and anticipate any problems.
The "else" part is not needed. More so in the rest of the if statements as the variables are initialized to false this makes them redundant since the variables are already set to false.
I would consider either setting the bool variables to reflect the "free" plan or the plan that you want to push. Then adjust the plan type based on the answers to the questions.
I do see a potential problem with question 5. If the user enters "3, 5, 13 or 999" everything is OK, but if the user types "3GB, 6GB or 13GB" the formatted input will store the number in the variable stopping at the first character that is not a number leaving the "GB\n" in the input buffer for the next "cin" to use which would cause "cin" to fail when it expects a number based on "years" being defined as a numeric value and you are trying to give it something that is not a number. The same would happen if the user enter the letter 'u' or "unlimited".
This is one solution that would get a proper number to use instead of something that would cause a problem.
How much data will you need to host?
1. 3GB
2. 6GB
3. 13GB
4. unlimited
Enter choice:_ // <--- The (_) denotes a space.
|
Your next set of if statements:
1 2 3 4
|
if (storageCapacity == 3)
{
costPerMonth = 0.00;
}
|
First if you initialize your variables when defined this is redundant as "costPerMonth" is already set to zero.
These statements make it look like you are basing the cost of a plan solely on the amount of storage which would make the first 4 questions unnecessary. The answers to these questions would have not bearing on the plan type. I do not think that is what the program is intended to do.
One question I do have is after looking at your link the green check is easy to understand. But what does the red X mean and what is the difference between the red X and an empty cell? Knowing the difference may determine how you write your program.
Andy