Need a little help with this program, any help or advice would be appreciated! Here is the question it asks..
Suppose that sale and bonus are double variables. Write an if.
..else statement
that assigns a value to bonus as follows: If sale is greater than $20,000, the value assigned to
bonus is 0.10; If sale is greater than $10,000 and less than or equal to $20,000, the value
assigned to bonus is 0.05; otherwise, the value assigned to bonus is 0. Print out the sale and
bonus values
#include <conio.h> // For function getch()
#include <cstdlib> // For several general-purpose functions
#include <fstream> // For file handling
#include <iomanip> // For formatted output
#include <iostream> // For cin, cout, and system
#include <string> // For string data type
usingnamespace std; // So "std::cout" may be abbreviated to "cout"
int main()
{
int x = 10;
if (x > 20000)
{
printf_s("x is .10!\n");
}
else
{
printf_s("x is 0.10!\n"); // this statement will not be executed
}
x = 1;
if (10000 < x <= 20000)
{
printf_s("x is 0.05!\n"); // this statement will not be executed
}
else
{
printf_s("x is not 0.05!\n");
}
return 0;
}
I think the thing that is messing with me is that the only applications I've made so far is where the user inputted a value. Is that not the case for this problem?
#include <conio.h> // For function getch()
#include <cstdlib> // For several general-purpose functions
#include <fstream> // For file handling
#include <iomanip> // For formatted output
#include <iostream> // For cin, cout, and system
#include <string> // For string data type
usingnamespace std; // So "std::cout" may be abbreviated to "cout"
int main()
{
double sale;
double bonus;
if (sale > 20000)
{
cout << "The bonus is 0.10" << endl;
}
elseif (10000 < sale <= 20000)
{
cout << "The bonus is 0.05" << endl;
}
elseif (sale == 30)
{
cout << "The bonus is 30" << endl;
}
else
{
cout << "Value of sale is not matching" << endl;
}
cout << "Exact value of a is : " << sale << endl;
return 0;
}