Need help with Looping

I have setup a vending machine program but I need to use looping to keep asking the user for money and accepting until $1.00 has been entered. For example, if the user enters .25 it will ask them to enter in more money. If they have entered in .25 and they enter in another .25 it should show that their new total is .50. I wanted to make the entire main function loop so that once the transaction is completed, the program will ask if you want to purchase a drink (Y/N) and once Y(yes) is chosen the program would loop again and start over with 0.00 and will ask to insert money again. If N(no) should be selected, the loop should exit and an output statement of what has been purchased should show up.

Code:

#include <stdio.h>
main()
{
float fAnySelection = 1.00;
int iSelection = 0;
float f1Payment = 0.00;
float fChangeDue = 0.00;
printf("\nWelcome to Harry's Retro Soda Pop Vending Machine\n");
printf("\nPlease Enter $1.00 to view Various Soda Choices: ");
scanf("%f%", &fAnySelection);
if (fAnySelection < 1.00){ //$1 inserted is greater than any selection.
printf("\nInserting more money guarantees you a drink next time! "); //User has to insert more money to get a drink from vending machine
printf("Please Enter at the least $1.00: ");
scanf("%f%", &fAnySelection);}
if (fAnySelection >= 1.00){ //Any selection is greater than or equal to $1
printf("\nEnter 1. for Coca-Cola\n"); //Different types of soda's that the user gets a choice from. Some of these are still around but they have been since the 1970's or even earlier.
printf("\nEnter 2. for Pepsi-Cola\n");
printf("\nEnter 3. for RC Cola\n");
printf("\nEnter 4. for Diet Rite Cola\n");
printf("\nEnter 5. for Tab\n");
printf("\nEnter 6. for Big Red Soda\n");
printf("\nEnter 7. for Brookdale Orange Soda\n");
printf("\nEnter 8. for Fresca Soda\n");
printf("\nEnter 9. for Nehi Grape Soda\n");
printf("\nEnter 10. for Welch's Grape Soda\n");
printf("\nPlease Enter Your Selection:");
scanf("%d%", &iSelection);}
if (iSelection == 1) {
printf("\nThanks for your purchase,you made an excellent choice, enjoy and don't forget your drink!\n");
}
if (iSelection == 2) {
printf("\nThanks for your purchase, you made an excellent choice, enjoy and don't forget your drink!\n");
}
if (iSelection == 3) {
printf("\nThanks for your purchase and enjoy. Ohh! and don't forget your drink!\n");
}
if (iSelection == 4) {
printf("\nThanks for your purchase, you made an excellent choice, enjoy and don't forget your drink!\n"); //Let's user know that the choice they have made was a good idea.
}
if (iSelection == 5) {
printf("\nThanks for your purchase, you made an excellent choice, enjoy and don't forget your drink!\n");
}
if (iSelection == 6) {
printf("\nThanks for your purchase, you made an excellent choice, enjoy and don't forget your drink!\n");
}
if (iSelection == 7) {
printf("\nThanks for your purchase, you made an excellent choice, enjoy and don't forget your drink!\n");
}
if (iSelection == 8) {
printf("\nThanks for your purchase, you made an excellent choice, enjoy and don't forget your drink!\n");
}
if (iSelection == 9) {
printf("\nThanks for your purchase, you made an excellent choice, enjoy and don't forget your drink!\n");
}
if (iSelection == 10) {
printf("\nThanks for your purchase, you made an excellent choice, enjoy and don't forget your drink!\n");
}
if (iSelection < 11) { //User making a choice greater than number indicated is invalid
printf("\nThe Choice you have selected is currently invalid. ");
printf("Please Try Again: ");
scanf("%d%", &iSelection); }
fChangeDue=fAnySelection-1.00;{
if (fChangeDue>0.00);
printf("\nAmount of change owed to user $%.2f", fChangeDue);} //Shows change owed to customer, if any that is owed.
getchar();
}

citizen is right and also for longer codes your program will work more efficiently,even faster and your code will look more simple with that kind of simplizations

if I were you I would put a scanf statement at the end of your code but before getchar() function to ask the user if he or she wanna get another drink via a printf statement. After that I would put the whole main function except variable declarations into a while loop which controls the answer to the scanf statement that I put before "getchar()" in each iteration.

printf("\nPlease Enter $1.00 to view Various Soda Choices: ");
scanf("%f%", &fAnySelection);
if (fAnySelection < 1.00){ //$1 inserted is greater than any selection.
printf("\nInserting more money guarantees you a drink next time! "); //User has to insert more money to get a drink from vending machine
printf("Please Enter at the least $1.00: ");
scanf("%f%", &fAnySelection);}
if (fAnySelection >= 1.00){ //Any selection is greater than or equal to $1
printf("\nEnter 1. for Coca-Cola\n"); //Different types of soda's that the user gets a choice from. Some of these are still around but they have been since the 1970's or even earlier.
printf("\nEnter 2. for Pepsi-Cola\n");
printf("\nEnter 3. for RC Cola\n");
printf("\nEnter 4. for Diet Rite Cola\n");
printf("\nEnter 5. for Tab\n");
printf("\nEnter 6. for Big Red Soda\n");
printf("\nEnter 7. for Brookdale Orange Soda\n");
printf("\nEnter 8. for Fresca Soda\n");
printf("\nEnter 9. for Nehi Grape Soda\n");
printf("\nEnter 10. for Welch's Grape Soda\n");
printf("\nPlease Enter Your Selection:");
scanf("%d%", &iSelection);}

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

You have an extra semicolon there, which will cause the printf to always execute.

dwk

Seek and ye shall find. quaere et invenies.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

If you intend to print a different message for every drink, look up the switch statement.

dwk

Seek and ye shall find. quaere et invenies.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

if (iSelection < 11) { //User making a choice greater than number indicated is invalid
printf("\nThe Choice you have selected is currently invalid. ");
printf("Please Try Again: ");
scanf("%d%", &iSelection); }

Perhaps you meant iSelection < 0 || iSelection > 10?

dwk

Seek and ye shall find. quaere et invenies.

"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell

You know, board members are allowed to edit their posts for up to twenty-four (IIRC) hours after they make one. That means that all you need to do is press the button that says 'edit', and you can add those other thoughts, the ones you didn't think of the first time, rather than clutter up the thread with four posts in as many minutes...

How would I put into code where it asks the user for money(for example, if they insert .25. It will ask them for additional .75) because drinks cost $1.00. I am having the hardest time trying to figure that part of it out. Any help would be greatly appreciated. I also made all of the changes that everyone suggested and it works like a charm. Now all I need to figure out is what is mentioned above.