I'm writing a program that outputs a value based on a value the user inputs. For example, if the user inputs a value from 0 to 0.35, the program triples the value and returns it. And if the user inputs a value from 0.36 to 0.50, the program doubles it, and so on until the user enters a value less than zero, which ends the program.
// name : Sean Hwang
// date : 5/19/2015
/*
this program will display
using variables concept
*/
#include <iostream>
#include <iomanip>
#include <string>
usingnamespace std;
void main()
{
// define variables here
double couponvalue = 0.0;
double couponrealvalue = 0.0;
do
{
// user inputs the coupon value here
cout << "value of coupon is: " << endl;
cin >> couponvalue;
// does not compute correctly
if (0 < couponvalue < 0.36){
couponrealvalue = couponvalue * 3;
cout << couponrealvalue;
}
// does not compute correctly
if (0.36 <= couponvalue < 0.51){
couponrealvalue = couponvalue * 2;
cout << couponrealvalue;
}
// does not return anything at all
if (0.51 <= couponvalue < 1.00){
couponrealvalue = 1.00;
cout << couponrealvalue;
}
if (couponvalue >= 1.00){
couponrealvalue = couponvalue;
cout << couponrealvalue;
}
} while (couponvalue > 0);
// output
cout << "The total value of the coupons is " << couponvalue << " dollars" << endl;
}
The problem I am having is that when I try to enter any value, it returns an incorrect value or no value at all.