Complex Coding

#include #include #include #define HIGHSCORE 585 //Braxten's Score int appleSells; int main () { //variables srand ( time(NULL) ); float version = 2.0; int gold = 0; int score = 0; int ans; int ATS; //apples to sell (sauces) int ASV = rand() % 14 + 1; //apple sauce value int apples = rand() % 100 + 30; //generates a random number int AppleValue = rand() % 4 + 1; //apple value int pressed; int yesNo; //instructions or not int play; int SpecialApples = 0; int PointsM = 100; int randChance = rand() % 5 + 1; //to get a random reward from special apples int useSA = 0; //Use special apple int rank = 0; if (apples > 100) { apples = 100; } printf("Welcome to the apple game version %0.2f!\nPress 1 then enter for instructions.\nOtherwise do any other key then enter.\n",version); scanf("%d",&yesNo); if (yesNo == 1) { printf("Ok heres how you get money:\nAt the begging of the game you will be asked how many apples you want to sell.\nApples can be sold from 1-6 gold, then it will ask about apple sauses,\n1-15 gold, chose wisley!\n\n"); } printf("You will start with %d apples.\n",apples); printf("How many apples would you like to sell?\n"); //user choses how many apples to sell scanf("%d",&appleSells); if (appleSells > apples) { score = apples*2-10; printf("You don't have that many apples. Game over. Score: %d\n",score); return 0; } else { //special apples if (appleSells == 0) { SpecialApples = 0; } else if (appleSells >= 30) { SpecialApples = 1; } if (appleSells >= 60) { SpecialApples = 2; } //calculates how much gold you get gold = appleSells*AppleValue; apples -= appleSells; printf("You now have %d gold. You have %d apples left. You have %d Special Apples.\n",gold,apples,SpecialApples); //1 special apple rewards if (SpecialApples == 1) { printf("Would you like to use your special apples?\n1 for yes other for no.\n"); scanf("%d",&useSA); } if (useSA == 1) { SpecialApples = 0; if (randChance == 1) { gold+=50; } else if (randChance == 2) { gold -= 60; } else if (randChance == 3) { apples += 10; } else if (randChance == 4) { apples -= 12; } else if (randChance == 5) { apples += 7; gold += 40; } else if (randChance == 6) { apples -= 10; gold -= 45; } } if (SpecialApples == 2) { printf("Would you like to use your special apples?\n1 for yes other for no.\n"); scanf("%d",&useSA); } if (useSA == 1 && SpecialApples == 2) { SpecialApples = 0; if (randChance == 1) { gold+=60; } else if (randChance == 2) { gold -= 70; } else if (randChance == 3) { apples += 25; } else if (randChance == 4) { apples -= 26; } else if (randChance == 5) { apples += 20; gold += 10; } else if (randChance == 6) { apples -= 30; gold -= 65; } } //write other code here //if apples are less than 0 = 0 if (apples < 0) { apples = 0; } printf("You now have %d gold and %d apples.",gold,apples); } printf(" \nHow many apple sauces would you like to sell?\n"); //user types amount of apples sauces they want to make scanf("%d",&ATS); if (ATS*5 > apples) { //if you don't have enough apples. score = apples+gold-50; printf("Sorry you don't have that many apples. Score: %d\n",score);//5 > 25 return 0; } else { //calculates apples, gold, then the total score. apples=apples-ATS*5; gold+=ATS*ASV; score = gold*2+apples*2.3+ATS*10; //ranks if (score <= 200) { rank = 1; } if (score <= 300 && score >= 201) { rank = 2; } if (score <= 400 && score >= 301) { rank = 3; } if (score <= 550 && score >= 401) { rank = 4; } if (score >= 700 && score >= 551) { rank = 5; } //tells end stats of game printf("\nTotal Game Stats:\nGold: %d\nApples: %d\nApple Sauces sold: %d\nApple Sauces Value: %d\nRecord Score: %d\nRank: %d\n",gold,apples,ATS,ASV,HIGHSCORE,rank); printf("Score = %d\n", score); printf("\nHow the score is calculated:\ngold*2+apples*2.3+ATS*10\n"); //to close program printf("\nPress 1 then enter to close.\n"); scanf("%d",&pressed); if (pressed == 1) { return 0; } } }