I was trying to use if the statement was allowed to check the number entered Fits in am But apparently this is not working. Here I am the statement
The user inputs the weight and I check that it is between small / top weight
const float SMALL_WEIGHT = 2.3f; // low end 1 range weight const Floot TOP_SMALL_WEIGHT = 4.3f; // Top end 1 range weight cout & lt; & Lt; "Enter the weight of the laptop:"; Cin & gt; & Gt; Weight; If (weight> SMALL_WEIGHT & weight> TOP_SMALL_WEIGHT) {cout & lt; & Lt; "Weight" & lt; & Lt; Weight & lt; & Lt; "Not Between" & lt; & Lt; SMALL_WEIGHT & lt; & Lt; "And" & lt; & Lt; TOP_WEIGHT & lt; & Lt; Endl; Return 1; }
I have reason to believe or || But it still does not work
EDIT: This is the complete code
#include & lt; Iostream & gt; # Include & lt; Iomanip & gt; using namespace std; Const float SALE_START_PRICE = 500.0f; // Discount if more than 500 const float DISCOUNT_PCT = .15f; // 15% Discount Cost Float TAX_PCT = .075f; // tax 7.5% constant float is SMALL_WEIGHT = 2.3f; // low end 1 range weight const Floot TOP_SMALL_WEIGHT = 4.3f; // Top end 1 range weight const float TOP_MID_WEIGHT = 5.8f; // Top Range Weight Costs Float TOP_WEIGHT = 7.9F; // Top 3 Range Weight Stable Flowl SMALL_SHIP = 5.4f; // First Range Original Ship Charged Cost Flat MID_SHIP = 5.8F; // second class original ship charge CA float TOP_SHIP = 6.2f; // Original range of original ship charge cost flame SMALL_SHIP_PCT = .025f; Const Flat MID_SHIP_PCT = 2.75 F; Const float TOP_SHIP_PCT = 3.5; Int main () {Float price, weight; Float discount amount, sale price; Float tax amounts, shipping charges, total solium; Cout & lt; & Lt; Enter the original price of the laptop: "; Cin & gt; & Gt; value; Cout & lt; & Lt; "Enter the weight of the laptop:"; Cin & gt; & Gt; Weight; If (weight> SMALL_WEIGHT & weight> TOP_SMALL_WEIGHT) {cout & lt; & Lt; "Weight" & lt; & Lt; Weight & lt; & Lt; "Not Between" & lt; & Lt; SMALL_WEIGHT & lt; & Lt; "And" & lt; & Lt; TOP_WEIGHT & lt; & Lt; Endl; Return 1; } If (Price & gt; SALE_START_PRICE) {Discontent = Price * DISCOUNT_PCT; } And discountAnmount = 0.00; Tax amount = price * TAX_PCT; Sale Price = Price - Discounts allowance; If (Weight = TOP_SMALL_WEIGHT & amp; weight & amp; MID_SHIP) shipping charge = MID_SHIP + (Sale Price * MID_SHIP_PCT); And shipping charge = TOP_SHIP + (Sale Price * TOP_SHIP_PCT); Total Solimount = Sales Price + Tax Amount + Shipping Charges; Cout & lt; & Lt; Fixed & lt; & Lt; Showpoint & lt; & Lt; Setprecision (2); Cout & lt; & Lt; "Original price: $" & lt; & Lt; Price & lt; & Lt; Endl; Cout & lt; & Lt; "Discounts: $" & lt; & Lt; Discount discount & lt; & Lt; Endl; Cout & lt; & Lt; "Sale Price: $" & lt; & Lt; Sale price & lt; & Lt; Endl; Cout & lt; & Lt; "Sales Tax: $" & lt; & Lt; Tax amount & lt; & Lt; Endl; Cout & lt; & Lt; "Shipping: $" & lt; & Lt; Shipping Charge & lt; & Lt; Andal & lt; & Lt; Endl; Cout & lt; & Lt; "Total Sales: $" & lt; & Lt; Total seamount & lt; & Lt; Endl; Return 0; }
weight
can not be smaller than Bigger than SMALL_WEIGHT
and TOP_SMALL_WEIGHT
.
I think you are a logical or ||
if it wants to:
if (weight> SMALL_WEIGHT || weight & gt; TOP_SMALL_WEIGHT) {cout & lt; & Lt; "Weight" & lt; & Lt; Weight & lt; & Lt; "Not Between" & lt; & Lt; SMALL_WEIGHT & lt; & Lt; "And" & lt; & Lt; TOP_WEIGHT & lt; & Lt; Endl; Return 1; }
Comments
Post a Comment