Skip to content

CAN ANYONE HELP FIX MY C++ CODE

Xeronator··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 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.

Xeronator1 votes

{quoted}

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.

I got most part of my code done. I just need that one tweak in order to make it work properly. My code compiles, it's just that ONE part of the code won't appear from the output. And no, I'm just trying to gain knowledge lol.

But I see where you are coming from though. Most of the code that I do are all on scratch so no plagarism here

(my professor does not even recommend spamming if statements on a program like this lol)

KFCeytron1 votes

{quoted}

I got most part of my code done. I just need that one tweak in order to make it work properly. My code compiles, it's just that ONE part of the code won't appear from the output. And no, I'm just trying to gain knowledge lol.

But I see where you are coming from though. Most of the code that I do are all on scratch so no plagarism here

You are still screaming in caps for strangers to finish the homework that you're too lazy to debug and complete. If you want to "gain knowledge," then read your textbook, talk to your professor, discuss with your classmates, Google any error messages you're getting, use a debugger to step through your program, reason through your algorithm out loud, use print debugging, refactor into functions, and so on. Throwing up your hands and dumping your half-finished work into someone else's lap is never the answer.

Xeronator1 votes

{quoted}

You are still screaming in caps for strangers to finish the homework that you're too lazy to debug and complete. If you want to "gain knowledge," then read your textbook, talk to your professor, discuss with your classmates, Google any error messages you're getting, use a debugger to step through your program, reason through your algorithm out loud, use print debugging, refactor into functions, and so on. Throwing up your hands and dumping your half-finished work into someone else's lap is never the answer.

Yea, I guess I'll keep working on my code I suppose. This specific part of the code has been bothering me for hours, actually days lol. But other that I'll try to find the errors for that specific part of the program.

Any feedback is appreciated though

The Anivia OTP2 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.

More from General Discussion

More by Xeronator