# For Newbies: Battlefield 2 Rank Calculator

Page 1 of 1

## 0 Replies - 422 Views - Last Post: 02 September 2005 - 12:42 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=364147&amp;s=b92c7f18d62e08ca843686c259035a1b&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 eLliDKraM

• Pepè Le Pewn

Reputation: 7
• Posts: 6,565
• Joined: 13-August 05

# For Newbies: Battlefield 2 Rank Calculator

Posted 02 September 2005 - 12:42 PM

Description: Insert a numerical global score 0-2,500,000 and the program will run a series of if commands to determine your present rank.Calculates your current rank in Battlefield 2 by requesting the user's global score. This is for newbies only because it goes over simple while/if commands and does basic calculations.
```#include <stdio.h>

int main(void) {
/* Most of my variables are self explanatory */
char quit;
float user_score;
float percentage;
float difference;
float pfc=500, lcpl=1000, cpl=10500, sgt=25000, ssgt=50000, gysgt=75000;
float msgt=150000, mgysgt=250000, sgtmajc=2500000;

/* ^^ These variables are just the transition poins to where you gain a level
e.g. mgysgt= Master Gunnery Sergeant, sgmajc=Sergeant Major of the Corps */

quit='N', 'n';

/* ^^ We could also use a do command but I <3 while
so I need to assign a value to the quit variable. If you used
while, you would not need to define anything until the end. */

while(quit=='N' || quit=='n') {

/* runs the following while the user does not want to quit */

printf("Welcome to Mark Dille's Global Rank Battlefield 2 Calculator!nn");

printf("Enter in your global score: ");
scanf("%f", &user_score);

/*Prompts and receives the global score of the user */

printf("nnn");

/* percentage just states how much they've completed their current rank
for example if they're a private with 250 points, they are half way to leveling
The difference calculates how many points they have to go until the next
rank.  I print the following later.  To print the % icon, I used %c and
at the end of the print statement I defined it as the variable '%',
however you can just use %% if you are more confortable with that. */

if (user_score<500) {
printf("You are a Private (PVT), soldier!nn");
percentage=(user_score/pfc)*100;
difference=pfc-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Private First Class!nKeep up the good work!", percentage, '%', difference);
}

else if (user_score<1000 && user_score>=500) {
printf("You are a Private First Class (PFC), soldier!nn");
percentage=(user_score/lcpl)*100;
difference=lcpl-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Lance Corporal!nKeep up the good work!", percentage, '%', difference);
}

else if (user_score<10500 && user_score>=1000) {
printf("You are a Lance Corporal (LCpl), soldier!nn");
percentage=(user_score/cpl)*100;
difference=cpl-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Corporal!nKeep up the good work!", percentage, '%', difference);
}

else if (user_score<25000 && user_score>=10500) {
printf("You are a Corporal (Cpl), soldier!nn");
percentage=(user_score/sgt)*100;
difference=sgt-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Sergeantl!nKeep up the good work!", percentage, '%', difference);
}

else if (user_score<50000 && user_score>=25000) {
printf("You are a Sergeant (Sgt), soldier!nn");
percentage=(user_score/ssgt)*100;
difference=ssgt-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Staff SergeantnKeep up the good work!", percentage, '%', difference);
}

else if (user_score<75000 && user_score>=50000) {
printf("You are a Staff Sergeant (SSgt), soldier!nn");
percentage=(user_score/gysgt)*100;
difference=gysgt-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Gunnery Sergeant!nKeep up the good work!", percentage, '%', difference);
}

else if (user_score<150000 && user_score>=75000) {
printf("You are a Gunnery Sergeant (GySgt), soldier!nn");
percentage=(user_score/msgt)*100;
difference=msgt-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Master Sergeant!nKeep up the good work!", percentage, '%', difference);
}

/* The following is pretty self-explanatory, if the user has not completed all basic kit awards, they put no which
sends them to a lesser rank.  Once they do, they say input their score and put yes and it tells them the next
available upgrade to them.  I just used the char command to store the answers. */

else if (user_score<250000 && user_score>=150000) {
printf("Have you received ALL of the following awards:nBasic KnifenBasic PistolnBasic Assaultn");
printf("Basic Anti-RanknBasic SnipernBasic Spec OpsnBasic SupportnBasic EngineernBasic Medicn");
printf("nnHave you received all of the awards listed above? (Y/N)  ");
printf("nn");

printf("Since you said you completed all the basic kit awards:nYou are a First Sergeant (1stSgt), soldier!nn");
percentage=(user_score/mgysgt)*100;
difference=mgysgt-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Master Gunnery Sergeant!nKeep up the good work!", percentage, '%', difference);
}
printf("Since you said you have NOT completed all the basic kit awards.nYou are a Master Sergeant (MSgt), soldier!nn");
printf("Complete all the basic kit awards and you will become a First Sergeant!  Keep up the good work!");
}
}

else if (user_score<2500000 && user_score>=250000) {
printf("If you made it to this point, it is understood you have completed all the basic kit awards (e.g. Basic Anti-Tank).n");
printf("If you have not, please do so before entering a rank in this point range.nn");
printf("Have you received all of the following awards:nBasic ArmornBasic TransportnBasic HelicopternBasic Aviatorn");
printf("Basic Air DefensenBasic Ground Defensennn");
printf("Have you received all of the awards listed above? (Y/N)  ");
printf("nn");

printf("Since you said you completed all the basic awards:nYou are a Sergeant Major (SgtMaj), soldier!nn");
percentage=(user_score/sgtmajc)*100;
difference=sgtmajc-user_score;
printf("You are "%.0f%c" to leveling and "%.0f pts" away from becoming a Sergeant Major of the Corps! (SgtMajC)nKeep up the good work!", percentage, '%', difference);
}
printf("Since you said you have NOT completed all the basic awards.nYou are a Master Gunnery Sergeant (MgySgt), soldier!nn");
printf("Complete all the basic awards and you will become a Sergeant Major!  Keep up the good work!");
}
}

else if (user_score>=2500000) {
printf("*****nCongratulations!!!  You are one of the few individuals to have achieved a score of such magnitude!n");
printf("Only one of the hundreds of thousands (possibly millions) of players are allowed to have then");
printf("Sergeant Major of the Corps rank.  If you do not hold this rank, tough luck, better luck next timen");
printf("because you're still a Sergeant Major (which is still a rank proving exemplary skills)!");
printf("GOOD PLAYER SOLDIER!");
printf("n******");
}

/* If you're running in Windows you can't forget something similar to this set of quit commands
because Windows is used to running and displaying the results and then just closing the application
this allows the window to halt with your information and allows you to read it then decide if you
wish to run the program again.  Remember the while command above. */

printf("nnn");
printf("Do you want to quit (Y/N)?  ");
scanf("%s", &quit);
printf("nnn");
printf("***************************n");
printf("***************************");
printf("nnnn");

}

return(0);

}
```

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }