To talk on Icrontic, just register!

It only takes 30 seconds.

Have an account? Sign in:

Forgot?
XZGohan
Icrontic Regular
XZGohan
38 Posts

C++ Question

ok...
code:
Code:
...
cout<<"Ranged Level ";
cin>>rangedlevel;
rangedlimit = (attacklevel + strengthlevel) / 1.475;
rangedpurity = rangedlevel - rangedlimit; //if negative = 0
rangedamount = 0>rangedpurity ? 0 : rangedpurity;
combatlevel = ((attacklevel + defenselevel + strengthlevel + hitpointslevel) / 4) + ((magiclevel + prayerlevel + rangedamount) / 8);
...

Im trying to make prayerlevel = 0 if it is below 0, negative, if its above 0 it will make itself to be that number.
That above is my lame attempt at doing something like it, however it doesnt work, of course
Wtf am I doing wrong? lol. I hate being a noob at things.

Thanks.
__________________ Powered by Linux and OpenBSD
ktulu_tco
Icrontic Regular
ktulu_tco
39 Posts
I don't see where you define prayerlevel... I mean, your code says that rangedamount shouldn't be negative... where did you instantiate prayerlevel (can we see that code?)
__________________ Compaq Presario R3000Z CTO (AMD64 3400+)
Am I a sellout? Hehe
XZGohan
Icrontic Regular
XZGohan
38 Posts
If you want the whole program, here :P
Code:
#include 
int main()
{
  int chooser;
  cout<<"[---------------------------------------------beta.02-]\n";
  cout<<"[               >>Runescape Calculator<<              ]\n";
  cout<<"[  Instructions: Type the number of the calculator    ]\n";
  cout<<"[  want to use, then hit [enter].                     ]\n";
  cout<<"[                                                     ]\n";
  cout<<"[               1. Max Weapon Hit                     ]\n";
  cout<<"[               2. Max Ranged Hit                     ]\n";
  cout<<"[               3. Max Ranged Level                   ]\n";
  cout<<"[               4. Hit Points Level                   ]\n";
  cout<<"[               5. Combat Level                       ]\n";
  cout<<"[                                                     ]\n";
  cout<<"[-----------------------------------------------ch!bo-]\n";
  cout<<"Choose: ";
  cin>>chooser;
  if(chooser==1)
  {
    int strengthlvl;
    int weaponpow;
    int weaponhit;
    int bos;
    int ss;
    int us;
    cout<<"[---------------------------------------------beta.02-]\n";
    cout<<"[               >>Max Weapon Hit<<                    ]\n";
    cout<<"[  Instructions: Type in your strength and weapon     ]\n";
    cout<<"[  power and hit [enter].                             ]\n";
    cout<<"[                                                     ]\n";
    cout<<"[-----------------------------------------------ch!bo-]\n";
    cout<<"Strength Level: ";
    cin>>strengthlvl;
    cout<<"Weapon Power: ";
    cin>>weaponpow;
    weaponhit = (strengthlvl + weaponpow + 3) / 8.5;
    bos = ((strengthlvl + weaponpow + 3) * 1.05) / 8.5;
    ss = ((strengthlvl + weaponpow + 3) * 1.10) / 8.5;
    us = ((strengthlvl + weaponpow + 3) * 1.15) / 8.5;
    cout<<"\n";
    cout<<"You can hit "<>Max Ranged Hit<<                      ]\n";
    cout<<"[ Instructions:  Simply input your ranged level and   ]\n";
    cout<<"[ the arrows you will shoot with.                     ]\n";
    cout<<"[                                                     ]\n";
    cout<<"[ Arrow Codes:                                        ]\n";
    cout<<"[  1. Bronze Arrows                                   ]\n";
    cout<<"[  2. Iron Arrows                                     ]\n";
    cout<<"[  3. Steel Arrows                                    ]\n";
    cout<<"[  4. Mithril Arrows                                  ]\n";
    cout<<"[  5. Adamantite Arrows                               ]\n";
    cout<<"[  6. Runite Arrows                                   ]\n";
    cout<<"[                                                     ]\n";
    cout<<"[-----------------------------------------------ch!bo-]\n";
    cout<<"Ranged Level: ";
    cin>>rangedlevel;
    cout<<"Type of Arrows: ";
    cin>>arrowtype;
    arrowhit = (rangedlevel / 3) + arrowtype; //FIND THE RIGHT ONE FIND THE RIGHT ONE//FIND THE RIGHT ONE//FIND THE RIGHT ONE//FIND THE RIGHT ONE
    cout<<"You can hit "<>Max Ranged Level<<                    ]\n";
    cout<<"[  Instructions:  Just input your strength and        ]\n";
    cout<<"[  attack levels, and the program will do the rest.   ]\n";
    cout<<"[                                                     ]\n";
    cout<<"[-----------------------------------------------ch!bo-]\n";
    cout<<"Strength Level: ";
    cin>>strengthlevel;
    cout<<"Attack Level: ";
    cin>>attacklevel;
    rangedlevel = (attacklevel + strengthlevel) / 1.475;
    cout<<"You may raise your ranged level to "<>Combat Level<<                        ]\n";
    cout<<"[  Instructions: Input your attack, defense,          ]\n";
    cout<<"[  strength, hitpoints, ranged, magic, and prayer     ]\n";
    cout<<"[  levels to receive your combat level.               ]\n";
    cout<<"[                                                     ]\n";
    cout<<"[  Primary Levels: Attack, Defense, Strength, Hits    ]\n";
    cout<<"[  Secondary Levels: Magic, Prayer                    ]\n";
    cout<<"[    Note: Ranged affects combat if over the          ]\n";
    cout<<"[    level supplied by the calculator. It is a        ]\n";
    cout<<"[    secondary level.                                 ]\n";
    cout<<"[                                                     ]\n";
    cout<<"[-----------------------------------------------ch!bo-]\n";
    cout<<"Attack Level: ";
    cin>>attacklevel;
    cout<<"Defense Level: ";
    cin>>defenselevel;
    cout<<"Strength Level: ";
    cin>>strengthlevel;
    cout<<"Hitpoints Level: ";
    cin>>hitpointslevel;
    cout<<"Ranged Level: ";
    cin>>rangedlevel;
    cout<<"Magic Level: ";
    cin>>magiclevel;
    cout<<"Prayer Level: ";
    cin>>prayerlevel;
    rangedlimit = (attacklevel + strengthlevel) / 1.475;
    rangedpurity = rangedlevel - rangedlimit;
    rangedamount = 0>rangedpurity ? 0 : rangedpurity;
    combatlevel = ((attacklevel + defenselevel + strengthlevel + hitpointslevel) / 4) + ((magiclevel + prayerlevel + rangedamount) / 8);
    primary = ((combatlevel + 1) * 4) - ((attacklevel + defenselevel + strengthlevel + hitpointslevel) / 4);
    secondary = ((combatlevel + 1) * 8) -((prayerlevel + magiclevel) * 8);
    cout<<"\n";
    cout<<"You are: \n";
    cout<<"Combat Level: " <
It gets cut off if I make it one code box...

Also, for the life of me, I cannot figure out why primary/secondary are working right. o_O
Tropical
looking for something to do
Tropical
87 Posts
okay i haven't program in c++ for a long time but i program c like everyday, so here i go with my first solution:

make int prayerlevel if you have declare it an unsigned int prayerlevel which makes go to 0 to 65535.

here is my second solution but it has more code:

if (prayerlevel < 0 )
{prayerlevel = 0;}

I hope that helps (and works)!
XZGohan
Icrontic Regular
XZGohan
38 Posts
Ive been going for ranged level, so I guess I will try this...
Code:
cout<<"Ranged Level: ";
cin>>rangedlevel;
rangedlimit = (attacklevel + strengthlevel) / 1.475;
rangedpurity = rangedlevel - rangedlimit;
if (rangedpurity < 0)
{
rangedamount = 0;
}
else if (rangedpurity > 0)
{
rangedamount = rangedpurity;
}
Thanks Tropical
a2jfreak
madasiemanym
a2jfreak
3,351 Posts
What tropical posted will work, but I don't see where in your code you're attempting to check the value of prayerlevel.

if you want it condensed, then use the ternary operator like you did w/ one of the ranged variables.

prayerlevel = ((prayerlevel > 0) ? prayerlevel : 0);
Go Back   Icrontic Forums > Tech: Software > General Software
Jump to
This Thread Search this Thread
Search this Thread:

Advanced Search


Current time: 11:32am (GMT)
Powered by vBulletin®
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Get Vanilla instead. Trust me.