CAN ANYONE HELP FIX MY C++ CODE

Xeronator·3/19/2019, 9:02:17 AM·1 votes·909 views

https://pastebin.com/L4p2dpk4

My code is there ^^

 **   if ((drug_potency_loss < 100 && drug_potency_loss > 0) && (target_effectiveness > 25 && target_effectiveness < 100)) {
        cout << "Potency loss = " << drug_potency_loss / 100.00 << endl; // This will calculate the potency loss in decimal numbers instead of percentage numbers.
        cout << "Target effectiveness = " << target_effectiveness << endl; // cout statement tells the user the target effectiveness.
        cout << " " << endl; //creates a blank line.
        cout << "Determining drug effectiveness: ..." << endl; // cout statement.
        cout << "" << endl; // blank line.
    }**

(Lines 22-28)

With this code, the user is supposed to enter -4 50

and then it will say error, try again

101 (error)

100 (error) and then 4 (the code will work)

but the output from my code won't show.

However, whenever I type in 4 50 for the first time, the output shows. I put all of my code in a do-loop but for some reason, the output that is bolded will only appear whenever I type in the correct numbers.

I'm trying to make that specific part of the code show regardless of the attempts tried.

That's all I needed help fixing.

AND YES THE CODE COMPILES AND THE LOOP WORKS

5 Comments

KFCeytron3/19/2019, 9:04:17 AM3 votes

Screaming in caps for strangers to do your homework for you multiple times a day will not help you learn programming, and could in fact get you into major trouble with your school.

The Anivia OTP3/19/2019, 10:16:15 AM2 votes

don't use 100, instead use 100.f for float or 100. for double, people working with you will thank your for that.

also (drug_potency_loss < 100 && drug_potency_loss > 0) need it's own verification

instead i advise you doing the error in before :

If(drug_potency_loss > 100 || drug_potency_loss < 0){\error here if drugpotency is overpôtency is not within 100 and 4} else{\the rest of your code in here};

also , it's a lol forum buddy , not a programmer forum , you'd better go to stackoverflow.

i pointed out thing i'm not even sure since you explained it the worst way you possibly could, and i have still 0 idea of what you're trying to say. or even what this program is supposed to do.

and i'm getting very lazy about it due to overcommenting your code is too noisy, If you want to explain what the code does, do it before the lines so anyone who tries to help you sees it more clearly, comment only what is important to. not every single line.

edit :

this -> using namespace std;//Always include in C++ programming. i'm sorry but NO, sometimes you don't want to use namespace for std lib

and could just do with std::cout and std::cin namespace are here to make your code easier in term of compatibility so you can have both

torture::cook(person prisonner)//Traditional torture for informations and cuisine::cook(person prisonner)//Traditional cooking for cannibals

Good luck with maintaining your code.