Question: Hello, I have been working on this project, I would appreciate it if anyone could help me by pinpointing any mistakes and helping me with

Hello, I have been working on this project, I would appreciate it if anyone could help me by pinpointing any mistakes and helping me with the parts I got stuck on! I will leave the instruction of the project and my code below! Thank you!!

Hello, I have been working on this project, I would appreciate it

if anyone could help me by pinpointing any mistakes and helping me

with the parts I got stuck on! I will leave the instruction

of the project and my code below! Thank you!! Thank you!!! Binary

Double Or Nothing In this project we are going to make a

text based game with a save file system. Be patient, test your

code often, and pay careful attention to the instructions and you will

Thank you!!!

Binary Double Or Nothing In this project we are going to make a text based game with a save file system. Be patient, test your code often, and pay careful attention to the instructions and you will do just fine! I have tried to write the parts in such a way that they can be tested independently of each other, so if you get really stuck on one part, you can comment out your code and work on the next part. All of the code will be in one file for this lab, with each part happening right after each other, take screenshots at the points I provide sample runs. There are three total parts. Setup: The File System (You don't need to program this part, you can do it by hand) Create two files, current_save.txt and total.txt Their content should both be the number 0. Create them and put zeroes in by hand, not through programming. Part 1: The Continue System (~40 lines) Declare a variable to hold the current_game_score. Read the value from total.txt and display it as the amount of coins the user has. Read the value from current_save.txt into a variable called current_save not current_game_score. If the current save is 0: Set the current_game_score to 0. If the current_save is not 0 (Saved Game): Show the user the current_save value Present the user with two options, their input should be validated with a do while loop. These two options are 0 and 1, and each option has the following logic: Option 0: End Their Saved Game Show them their current total. . Add the current_save to their total Save this value back into total.txt Show them their new total Set current_game_score to 0. Write 0 to the current_save file. Option 1: Set Up To Continue Their Game Set the current_game_score to the current_save score. Save a 0 to the current_save file. Part 2: The Main Game: (-60 new lines) If the current game score is O, let the user know that it costs 5 coins start a new game Otherwise just display a message such as "Welcome back!" Ask the user if they would like to play. Have them enter a 1 for yes or a 0 for no. (Should be validated with a do while loop) No should display a goodbye message. 1. If they would like to play: If the current game score is O, the user is starting a new game. Do the following logic. Read the value in total.txt into a variable subtract 5 from that variable Write this value back into total.txt set the current_game_score to 5. continuing and nothing needs to be done before starting the If the current game score is not o, the user game 2. Play the game Make an int command variable. Create a do while loop whose condition is that the current_game_score isn't o (indicating they lost) AND the command isn't o 3. Inside the do while loop: Print: Double or Nothing! Guess the result of my coin flip and I'll double your money! Your current amount is Enter your guess for the coin flip: O for heads 1 for tails Next: Scan and validate the user's guess of 0 or 1. Generate a random 0 or 1. For 0, print "Heads" and for 1, print "Tails" If the user's guess was right: Double their current_game_score Inform them of the new score Ask them if they would like to flip again. Have them enter a l for yes and a 0 for no. Scan this into the command variable controlling the do while loop. If the users guess was wrong: Tell them YOU LOSE and laugh at them set their current score to 0. Write that o to current.txt End of do while loop End of "I would like to play" For testing purposes, you might want to print out the current game score at the end of your program. Part 3: The Save System (~20 lines) If the current_game_score is not 0, give the player a chance to either save their game or bank their earnings. Have them enter a 0 to bank their earnings, or a 1 to save their game. Validate their input with a do while loop. Banking Their Winnings Add the current_game_score to the total_score Write the new total back to total.txt. Write a 0 to current_save.txt Save Their Progress Write the current_game_score to the current_save.txt file. You are now done! Note that if you lose, nothing new happens. See how many coins you can make with your game! (or how far into debt you go) 1 //project 3 Binary Double or Nothing 2 #include 3 #include 4 #include 5- int main() { 6 //parti 7 int current_game_score; 8 FILE amount_coins_file=fopen("total.txt","r"); 9 int amount_coins; 10 fscanf(amount_coins_file, "%d",&amount_coins); 11 fclose(amount_coins_file); 12 FILE current_save_file=fopen("current_save.txt","r");|| 13 int current_save; 14 scanf(current_save_file, "%d",&current_save); 15 if (current_save==0) { 16 int current_game_score=0; 17 } 18 - else if (current_save!=0) { 19 printf("%d", current_save); 20 do { 21 printf("Type o if you want to end your saved game, and type 1 22 if you want to continue the game: "); 23 int option; 24 scanf("%d", &option); 25 - switch(option) { 26 case 0: 27 printf("The current total is %d coins. In", amount_coins); //come back not sure 28 //what is the current total!! 29 int current_total=current_save+amount_coins; //confused on how to 30 ////addcurrent_save w/total 31 FILE amount_coins_file=fopen("total.txt", "w"); 32 fprintf(amount_coins_file, "%d", current_total); 33 fclose(amount_coins_file); 34 printf("Your new total is %d ", current_total); 35 current_game_score=0; 36 FILE*current_save_file=fopen("current_save.txt", "w"); 37 fprintf(current_save_file, "%d", current_game_score); 38 fclose(current_save_file); 39 break; 40 case 1: 41 current_game_score=current_save; 42 current_save=0; 43 File current_save_file=fopen("current_save", "w"); 44 fprintf(current_save_file, "%d", current_save); 45 fclose(current_save_file); 46 break; 47 default: 48 printf("sorry I did not understand "); }}} 49 //part2 50 if(current_game_score==0) { 51 printf("It cost 5 coins to start a new game "); 52 } 53 else { 54 printf("Welcome back!!"); 55 scanf("%d",&choice); 56 do { 57 Sprintf("Would you like to play/continue playing? Type 1 for yes and for no: "); 58 switch(Choice) { 59 case 0: 60 printf("GoodBye Thanks for playing..... "); 61 break; 62 case 1: 63 if(current_game_score==0) { 64 FILE amount_coins_file=fopen("total.txt","r"); 65 int coins; 66 fscanf(amount_coins_file, "%d", coins); 67 coins -5; 68 fclose(amount_coins_file); 69 } 70 else { 71 printf("continuing game..."); 72 } 73 break; 74 default: 75 printf("Sorry I dont understand. "); }}} 76 int command; 77 scanf("%d", &command); 78 do { 79 printf("Double or Nothing! Guess the result of my coin flip and I'll double your money!'); 80 printf("Your current amount is %d ", coins); printf("Enter your guess for the coin flip: for heads 1 for tails."); 82 srand(time(NULL)); 83 int num=(rand()%(1 -0+1)) +0; 84 switch(command){ 85 case 0: 86 printf("Heads "); 87 break; 88 case 1: 89 printf("Tails "); 90 break; 91 default: 92 printf("Can't understand!! "); 93 } while(command !=0||command !=1)} 94 if (num==command) { 95 current_game_score=current_game_score*2; 96 printf("Your new game score is %d. ", current_game_score); 97 printf("Would you like to flip again? "); 98 int flip; 99 scanf("%d",&flip); 81 78 do { 79 printf("Double or Nothing! Guess the result of my coin flip and I'll double your money"); 80 printf("Your current amount is %d ", coins); 81 printf("Enter your guess for the coin flip: for heads for tails."); 82 srand(time(NULL)); 83 int num=( (%(1-0+1))+; 84 switch(command) { 85 case 0: 86 printf("Heads "); 87 break; 88 case 1: 89 printf("Tails "); 90 break; 91 default: 92 printf("Can't understand!! "); 93 } while(command !=0|command !=1)} 94 if (num==command) { 95 current_game_score=current_game_score*2; 96 printf("Your new game score is %d. ", current_game_score); 97 printf("Would you like to flip again? "); 98 int flip; 99 scanf("%d",&flip); 100 do{ 101 switch (flip)/////How to make this go back to the command do while Loop??? 102 } Il/instead of using the variale int, and creationg a new do while loop?? 103 else { 104 printf("You loose HAHAHAHAHAHAHAHAHAHAHAH. ... ... "); 105 current_game_score=; 106 FILE*current_file=fopen("current.txt", "W"); 107 int current_score=; 108 fprintf(current_file"%d", current_score); 109 fclose(current_file); 110 printf("The current score is %d ", current_score); 111 }} 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 } //part3 scanf("%d",&option); do { printf("Choose from the following option's: o to bank you'r earnings 1 to save you'r game: "); int option; switch (option) { case 0: printf("you chose baking! "); current_game_score=current_game_score+amount_coins; FILE*amount_coins_file=fopen("total.txt", "w"); fprintf(amount_coins_file, "%d", current_game_score); fclose(amount_coins_file); case 1: FILE*current_save_file=fopen("current_save.txt", "w"); fprintf(current_save_file,"%d",current_save); fclose(current_save_file); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!