Realized something today by accident. I am asking for a dollar amount in my program, and checking to make sure it is a valid amount above $0.
What I am not checking for is a character response. I have tried some stuff, and nothing seems to work. Can anyone look at this and offer any suggestions?

#include <stdio.h>  // standard input output library

//defines tax value for calculations
#define DelMar 7.25
#define Encinitas 7.5
#define LaJolla 7.75

char cAgain;  //variable for Y/N questions
char cValid;  // variable for validity check

float user_input() // week 4 addition for sales amount
{ //prompt, collect, and store sale amount
    float fAmount; //defines amount type as float
    printf("Enter Amount of Sale $ "); 
    scanf ("%f", &fAmount);
    return fAmount;
}

int iMenu()  //defines menu variable
{ // menu which prompts, collects, and stores store number
    int iSelection; //defines selection type as integer
    printf("Tax Calculation for Purchase\n\n"); //changed to reflect week 4 updates
    printf("1. Del Mar \n2. Encinitas \n3. La Jolla\n");
    printf("\n\nPlease Select Number of Store for Which to Calculate: ");

    scanf("%d",&iSelection);
    return iSelection;
}

int main() //main loop
{
   do // week 5 do/while loop to replace GOTO and STARTOVER 
    {				

    float fSales = 0.00; // Sales value for calculations
    int iStorenum; //defines store for main loop, menu will not work without
      
    fSales = user_input(); //new week 4 loop for sales total
    while (fSales <0.0 || cValid != ' ') //new week 4 loop to validate sales amount
    {
    printf("SALE AMOUNT CANNOT BE LESS THAN $0.00. Re-Enter: $ ");
        {
        scanf ("%f %c",&fSales, cValid); // scans new input for validity
        }
         
     } // ends while loop
     
    iStorenum = iMenu(); //displays menu created above
    
     while (iStorenum <1 || iStorenum >3) //if store number is not 1, 2 or 3
    {
    	printf("INVALID NUMBER ENTERED! Please enter 1,2 or 3: ");
    	   {
    	   scanf("%d", &iStorenum);  //scans input at INVALID prompt 
           }
    } // end while loop
    
    if (iStorenum == 1)
//Calculates and Displays Del Mar Store, Sales, Tax rate, and Tax
       printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, DelMar, fSales*DelMar/100, DelMar*fSales/100+fSales); 
    if (iStorenum == 2)
//Calculates and Displays Encinitas Store, Sales, Tax rate, and Tax
       printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, Encinitas, fSales*Encinitas/100, Encinitas*fSales/100+fSales); 
    if (iStorenum == 3)
 //Calculates and Displays La Jolla Store, Sales, Tax rate, and Tax
       printf("\nLa Jolla \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, LaJolla, fSales*LaJolla/100, LaJolla*fSales/100+fSales); 
                 
   
    

    printf("\n\tRun Calculator Again? (y/n) ");//prompts for repeat
            scanf("%c", &cAgain);//scans input at store number prompt   
            
       } while (cAgain == 'y' || cAgain == 'Y'); // week 5 do/while end
                            
  return 0; // successful main loop end

}

I don't understand what the problem is, can you be more specific? Where about's in the code are you talking about?

Hi Hiroshe,
I am trying to check for a character, any character because anything NOT a dollar amount would be an invalid entry.
If a character, any character is entered I want the WHILE loop to continue and prompt for a valid dollar amount.
This is the latest version of my attempts, I finally got something that compiles, but it does not work.

fSales = user_input(); //new week 4 loop for sales total
    while (fSales <0.0 || cValid != ' ') //new week 4 loop to validate sales amount
    {
    printf("SALE AMOUNT CANNOT BE LESS THAN $0.00. Re-Enter: $ ");
        {
        scanf ("%f %c",&fSales, cValid); // scans new input for validity
        }
         
     } // ends while loop

Read the user input as a string, validate the string according to the specific details for dollar amount entry. Such as, begins with dollar sign, is followed by nothing but digits until a possible decimal point, and then no more than two digits. Or whatever.

commented: thanks for the help +3

I gave you a clue to this issue in your thread titled "GOTO command -C". You need to "consume" the '\n' character left over from when scanning the store number. Read my post again in that thread.

In your iMenu() function, replace:

scanf("%d", &iSelection);

with this:

scanf("%d%c", &iSelection, &cAgain);

I'm just reusing your cAgain variable - you should probably use a more appropriately named variable for this purpose.

commented: patient guy. really here to help. +3

While I'm at it, you'll have to do the same thing with this code in your main

while (iStorenum < 1 || iStorenum > 3) //if store number is not 1, 2 or 3
        {
            printf("INVALID NUMBER ENTERED! Please enter 1,2 or 3: ");
            {
                scanf("%d", &iStorenum); //scans input at INVALID prompt
            }
        } // end while loop

Another reason why I'm not a great fan of scanf() most of the time.

Damn! Another brain malfunction. Sorry, I didn't read your original post correctly. The issue I was referring to was regarding the fact that your loop will terminate after one iteration after prompting for another calculation due to the '\n' not being consumed from the previous scanf.

Dave Sinkula's advice is the way to go for the issue you raised with this thread.

Hi Yellowsnow,
I do remember that. That instruction got me to where I am today. I think the extra <RETURN> I have to hit everytime I input has something to do with your comment about 'consume the '\n', but for the life of me I cannot figure out how to consume anything! lol

I am playing with it, but I completely do not know how to "consume" anything, or where it even comes from to begin with.

Can you provide some instruction as to how that happens?

Read the user input as a string, validate the string according to the specific details for dollar amount entry. Such as, begins with dollar sign, is followed by nothing but digits until a possible decimal point, and then no more than two digits. Or whatever.

Dave, that is so far beyond me I only vaguely understand what you are trying to say.

not sure if this qualifies as progress or not :)

but with this code my menu validity check appears to work. if i enter anything other than 1, 2, or 3 it prompts me to retry.
it does not work for my dollar prompt though. if i enter a character there it just accepts it and continues on to my menu, and returns
0s for all my amounts.

the extra <RETURN> is still needed after each entry for some reason.

#include <stdio.h>  // standard input output library

//defines tax value for calculations
#define DelMar 7.25
#define Encinitas 7.5
#define LaJolla 7.75

char cAgain;  //variable for Y/N questions
char cValid;  // variable for validity check

float user_input() // week 4 addition for sales amount
{ //prompt, collect, and store sale amount
    float fAmount; //defines amount type as float
    printf("Enter Amount of Sale $ "); 
    scanf ("%f%c", &fAmount, &cValid);
    return fAmount;
}

int iMenu()  //defines menu variable
{ // menu which prompts, collects, and stores store number
    int iSelection; //defines selection type as integer
    printf("Tax Calculation for Purchase\n\n"); //changed to reflect week 4 updates
    printf("1. Del Mar \n2. Encinitas \n3. La Jolla\n");
    printf("\n\nPlease Select Number of Store for Which to Calculate: ");

    scanf("%d%c",&iSelection ,&cValid);
    return iSelection;
}

int main() //main loop
{
   do // week 5 do/while loop to replace GOTO and STARTOVER 
    {				

    float fSales = 0.00; // Sales value for calculations
    int iStorenum; //defines store for main loop, menu will not work without
      
    fSales = user_input(); //new week 4 loop for sales total
    while (fSales <0.0) //new week 4 loop to validate sales amount
    {
    printf("SALE AMOUNT CANNOT BE LESS THAN $0.00. Re-Enter: $ ");
        {
        scanf ("%f%c" ,&fSales ,&cValid); // scans new input for validity
        }
         
     } // ends while loop
     
    iStorenum = iMenu(); //displays menu created above
    
     while (iStorenum <1 || iStorenum >3) //if store number is not 1, 2 or 3
    {
    	printf("INVALID NUMBER ENTERED! Please enter 1,2 or 3: ");
    	   {
    	   scanf("%d%c", &iStorenum ,&cValid);  //scans input at INVALID prompt 
           }
    } // end while loop
    
    if (iStorenum == 1)
//Calculates and Displays Del Mar Store, Sales, Tax rate, and Tax
       printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, DelMar, fSales*DelMar/100, DelMar*fSales/100+fSales); 
    if (iStorenum == 2)
//Calculates and Displays Encinitas Store, Sales, Tax rate, and Tax
       printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, Encinitas, fSales*Encinitas/100, Encinitas*fSales/100+fSales); 
    if (iStorenum == 3)
 //Calculates and Displays La Jolla Store, Sales, Tax rate, and Tax
       printf("\nLa Jolla \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, LaJolla, fSales*LaJolla/100, LaJolla*fSales/100+fSales); 
                 
   
    

    printf("\n\tRun Calculator Again? (y/n) ");//prompts for repeat
            scanf("%c", &cAgain);//scans input at store number prompt   
            
       } while (cAgain == 'y' || cAgain == 'Y'); // week 5 do/while end
                            
  return 0; // successful main loop end

}

In all honesty, I'm not sure what you're trying to achieve with the cValid variable in your scanf statements.

If you want basic (and I mean really basic) validation checking for your float variable using scanf, try this little code snippet out and see if you can incorporate something like it into your code (and read the warning after the code):

#include <stdio.h>

int main(void) {

    float f;
    char valid = 'N';

    printf("Enter a float value: ");
    while (valid == 'N') {
        if (scanf("%f", &f) == 1) {
            valid = 'Y';
        } else {
            // consume erroneous characters before prompting again
            while (getchar() != '\n') {;}
            printf("Enter a float value: ");
        }
    }

    printf("float is %.2f", f);
    return 0;
}

Warning: this is very basic validation with scanf. If you enter "AB12", it won't validate, however if you enter "12.34AB", it will validate as correct and set the float variable to 12.34. Please understand this and the misgivings of the scanf function. As I stated earlier, Dave Sinkula's advice is the way to go for more bulletproof validation. I have only provided you with this sample as you have stated that validation as suggested by Dave Sinkula is beyond your capabilities at this stage.

The line of code that "consumes" extra characters should be used elsewhere in your code where this issue exists - i.e. ignore my suggestion in an earlier post about scanning for the additional character in the scanf statements.

Great. I will see what I can do with this example.
I will work on it tonight and tomorrow and let you know how I do.

I appreciate the help. :)

wow.
I have never had anything that I just flat out could not get if I tried long enough ... until now.
YellowSnow, I tried your code every which way I could, and just could not get it to work for me. The closest I got was when my program would hang at open and never even ask me for my sale amount.
I did manage to get the menu to re-prompt if a character was entered, but if it is not a character I have to hit enter an extra time.
I tried using that consume function above in different forms, but again I could not get it to work.
What I am left with is this, and it is so ugly and ineffective I am probably just going to take out everything associated with this attempt and just validate incorrect integers and floats I guess.

I feel like I have wasted your time, sorry if that is the case, but I thought it would be such a simple thing to invalidate a character when a float is requested and my inability to grasp this is really getting to me.

#include <stdio.h>  // standard input output library

//defines tax value for calculations
#define DelMar 7.25
#define Encinitas 7.5
#define LaJolla 7.75

char cAgain;  //variable for Y/N questions
char cValid;

float user_input() // week 4 addition for sales amount
{ //prompt, collect, and store sale amount
    float fAmount; //defines amount type as float
    printf("Enter Amount of Sale $ "); 
    scanf ("%f", &fAmount);
    return fAmount;
}

int iMenu()  //defines menu variable
{ // menu which prompts, collects, and stores store number
    int iSelection; //defines selection type as integer
    printf("Tax Calculation for Purchase\n\n"); //changed to reflect week 4 updates
    printf("1. Del Mar \n2. Encinitas \n3. La Jolla\n");
    printf("\n\nPlease Select Number of Store for Which to Calculate: ");

    scanf("%d%c",&iSelection ,&cValid);
    return iSelection;
}

int main() //main loop
{
   do // week 5 do/while loop to replace GOTO and STARTOVER 
    {				

    float fSales = 0.00; // Sales value for calculations
    int iStorenum; //defines store for main loop, menu will not work without
        
    fSales = user_input(); //new week 4 loop for sales total
    while (fSales <0.0) //new week 4 loop to validate sales amount
    	
    	{
    printf("SALE AMOUNT CANNOT BE LESS THAN $0.00. Re-Enter: $ ");
        {
        scanf ("%f",&fSales); // scans new input for validity
        }
       } // ends while loop
     
    iStorenum = iMenu(); //displays menu created above
    
     while (iStorenum <1 || iStorenum >3) //if store number is not 1, 2 or 3
    { 
    	printf("INVALID NUMBER ENTERED! Please enter 1,2 or 3: ");
    	   { 
    	   scanf("%d%c", &iStorenum ,cValid);  //scans input at INVALID prompt 
           }
    } // end while loop
    
    if (iStorenum == 1)
//Calculates and Displays Del Mar Store, Sales, Tax rate, and Tax
       printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, DelMar, fSales*DelMar/100, DelMar*fSales/100+fSales); 
    if (iStorenum == 2)
//Calculates and Displays Encinitas Store, Sales, Tax rate, and Tax
       printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, Encinitas, fSales*Encinitas/100, Encinitas*fSales/100+fSales); 
    if (iStorenum == 3)
 //Calculates and Displays La Jolla Store, Sales, Tax rate, and Tax
       printf("\nLa Jolla \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, LaJolla, fSales*LaJolla/100, LaJolla*fSales/100+fSales); 
                 
   
    

    printf("\n\tRun Calculator Again? (y/n) ");//prompts for repeat
            scanf("%c", &cAgain);//scans input at store number prompt   
            
       } while (cAgain == 'y' || cAgain == 'Y'); // week 5 do/while end
                            
  return 0; // successful main loop end

}

I have taken an exact copy of the code you posted and except for a missing '&' in your scanf statement for that blasted cValid variable, everything seems to "work as expected" - as far as I know.

Besides ignoring advice on how to improve your code from others besides me, it seems to work fine.

Perhaps you need to post a "blow by blow" run down of your output for us to get a better understanding of what you think is wrong.

I will try and get you a run down before I finish up today. I was frustrated last night when I posted that, and I am back inside trying some stuff today.

It is not that I am ignoring advice, but I have almost 0 C experience at this point, and an not really able to understand and impliment everything at this point.

I want to learn, and will as time progresses, but I have to focus on one problem at a time or else I get even more confused, so when working on validity for my float I tend to get tunnel vision.

Thanks for your help again, and I will try and post my progress later this evening for you to see.

"What I am not checking for is a character response."

You can look into ASCII character values; in order to make sure that something is an integer (or is not a character), you would compare the character to a range of ASCII values which can be found on the table. This advice is less detailed than a lot of the other responses I see in this thread, so be warned that it isn't a solution but a useful thing to know that can help you build a solution.

I feel like I am so close. I know I have not done as some have suggested, but a lot of that is simply above me, and I am trying to do this as simply as possible so that I understand what I am doing.
Can somebody look at this and suggest something.
It kicks to the error if you enter a character, but only after in the loop.
It is strange, it seems to work, but I have to enter several times sometimes.

#include <stdio.h>  // standard input output library

//defines tax value for calculations
#define DelMar 7.25
#define Encinitas 7.5
#define LaJolla 7.75

char cAgain;  //variable for Y/N questions

float user_input() // week 4 addition for sales amount
{ //prompt, collect, and store sale amount
    float fAmount; //defines amount type as float
    printf("Enter Amount of Sale $ "); 
    scanf ("%f", &fAmount);
    return fAmount;
}

int iMenu()  //defines menu variable
{ // menu which prompts, collects, and stores store number
    int iSelection; //defines selection type as integer
    printf("Tax Calculation for Purchase\n\n"); //changed to reflect week 4 updates
    printf("1. Del Mar \n2. Encinitas \n3. La Jolla\n");
    printf("\n\nPlease Select Number of Store for Which to Calculate: ");

    scanf("%d",&iSelection);
    return iSelection;
}

int main() //main loop
{
STARTOVER://start again point
{				

    float fSales = 0.00; // Sales value for calculations
    int iStorenum; //defines store for main loop, menu will not work without
      
    fSales = user_input(); //new week 4 loop for sales total
    //while (fSales <=0.0) //new week 4 loop to validate sales amount
    while ((scanf ("%f", &fSales) != 1) || (fSales <=0.0))
    {
    printf("SALE AMOUNT CANNOT BE LESS THAN $0.00. Re-Enter: $ ");
        {
        getchar();
       // scanf ("%f",&fSales); // scans new input for validity
        }
         
     } // ends while loop
     
    iStorenum = iMenu(); //displays menu created above
    
     while (iStorenum <1 || iStorenum >3) //if store number is not 1, 2 or 3
    {
    	printf("INVALID NUMBER ENTERED! Please enter 1,2 or 3: ");
    	   {
    	   scanf("%d", &iStorenum);  //scans input at INVALID prompt 
           }
    } // end while loop
    
    if (iStorenum == 1)
//Calculates and Displays Del Mar Store, Sales, Tax rate, and Tax
       printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, DelMar, fSales*DelMar/100, DelMar*fSales/100+fSales); 
    if (iStorenum == 2)
//Calculates and Displays Encinitas Store, Sales, Tax rate, and Tax
       printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, Encinitas, fSales*Encinitas/100, Encinitas*fSales/100+fSales); 
    if (iStorenum == 3)
 //Calculates and Displays La Jolla Store, Sales, Tax rate, and Tax
       printf("\nLa Jolla \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, LaJolla, fSales*LaJolla/100, LaJolla*fSales/100+fSales); 
                 
   
    

    printf("\n\tRun Calculator Again? (y/n) ");//prompts for repeat
            scanf("%c", &cAgain);//scans input at store number prompt   
            
               if (cAgain == 'y'|| cAgain == 'Y')//repeats calculator
               {
               goto STARTOVER;  //back to top
               }
               else if (cAgain == 'n' || cAgain == 'N')//end
                            
  return 0; // successful loop end
}
}

Here is another way you might want to try. Its in c++ though.
You could try to convert it into c.

float GetFloat()
{
	std::cout<<"Enter a number please : ";
	float num(0);
	cin >> num;

	while(!cin)
	{
		cin.clear();
		while(cin.get() != '\n')
			continue;

		cout<<"\nPlease enter a number : ";
		cin >> num;
	}

	return num;
}

use it like this :

int main()
{
    float num = GetFloat();
   return 0;
}

@firstPerson
Besides this being a C forum, I don't think it helps that much to post C++ code and then suggest to the OP that he/she should try to convert it to C based on the relative skill/experience level of the OP (no offense intended to the OP).

@no1zson
OK. I feel that you've really been trying to nut this problem out. It also appears that you have gone a tad backwards with your last code posting in relation to the discussions we've had on this thread. So at the risk of getting blasted by other forum members, please try the code below out. And please read my comments after the code!

#include <stdio.h>
#include <ctype.h>

//defines tax value for calculations
#define DelMar 7.25
#define Encinitas 7.5
#define LaJolla 7.75

char cAgain; //variable for Y/N questions

float get_sales_amount() {

    float fAmount;

    printf("Enter Amount of Sale $ ");

    while ((scanf("%f", &fAmount) != 1) || (fAmount <= 0.0)) {

        while (getchar() != '\n') {;}

        printf("SALE AMOUNT CANNOT BE LESS THAN $0.00.\n");
        printf("It must be a valid decimal value. Re-enter: $ ");
    }

    while (getchar() != '\n') {;}
    return fAmount;
}

int get_store_number() {

    int iSelection;

    printf("Tax Calculation for Purchase\n\n");
    printf("1. Del Mar \n2. Encinitas \n3. La Jolla\n");
    printf("\n\nPlease Select Number of Store for Which to Calculate: ");

    scanf("%d", &iSelection);
    while (getchar() != '\n') {;}

    while (iSelection < 1 || iSelection > 3) {
        printf("INVALID NUMBER ENTERED! Please enter 1,2 or 3: ");
        scanf("%d", &iSelection);
        while (getchar() != '\n') {;}
    }

    return iSelection;
}

void calc_tax_details(int store_number, float sales_amount) {

    if (store_number == 1)
        //Calculates and Displays Del Mar Store, Sales, Tax rate, and Tax
        printf(
                "\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f\tTotal= \t$%.2f\t\n\n",
                sales_amount, DelMar, sales_amount * DelMar / 100, DelMar * sales_amount
                        / 100 + sales_amount);
    if (store_number == 2)
        //Calculates and Displays Encinitas Store, Sales, Tax rate, and Tax
        printf(
                "\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f\tTotal= \t$%.2f\t\n\n",
                sales_amount, Encinitas, sales_amount * Encinitas / 100, Encinitas
                        * sales_amount / 100 + sales_amount);
    if (store_number == 3)
        //Calculates and Displays La Jolla Store, Sales, Tax rate, and Tax
        printf(
                "\nLa Jolla \tSale $%.2f\tRate %.2f%%\tTax $%.2f\tTotal= \t$%.2f\t\n\n",
                sales_amount, LaJolla, sales_amount * LaJolla / 100, LaJolla * sales_amount
                        / 100 + sales_amount);
}

int main(void) {

    float sales_amount;
    int store_number;

    do {
        sales_amount = get_sales_amount();
        store_number = get_store_number();
        calc_tax_details(store_number, sales_amount);

        printf("\n\tWould you like to calculate for another store? (y/n) ");//prompts for repeat
        scanf("%c", &cAgain);//scans input at store number prompt

    } while (toupper(cAgain) == 'Y');

    return 0;
}

I have refactored the code from one of your previous posts where you were close to a solution (and had got rid of the goto). So you may have to make some minor changes to suit your latest needs. You'll also notice that I have renamed some of your variables and functions to more meaningful names and added a new function for your tax calculations. You'll see that your main() function is far more cleaner and easier to understand now.

One of your main issues is that you were performing some functionality in your function and then trying to perform validation related to data in the function in main(). I think this was confusing you (and it's not good design anyway). For example, your function for getting a sales amount from the user should perform the validation of the amount field in the function - not in main!

Whilst on the topic of validation (of your float), I have used really basic validation which I alluded to in my previous posts. So read those posts again to understand the consequences of such basic validation "techniques".

I have also added code to "consume" unwanted or erroneous characters. Study the code - you'll see where I've used it.

A point on style - comments are a good thing if they are used correctly. You have gone way overboard with your comments and you are commenting things like:

int main() //main loop

Well - that's obvious - NO COMMENT REQUIRED - or another example:

int iSelection; //defines selection type as integer

Well that's what the int is for!!

I also sincerely hope your instructor is not teaching you that Hungarian naming notation crapola (e.g. iSelection, fSales). If so, then perhaps you'll get lucky and your teacher will see the light someday. I know some people swear by it, but personally it drives me to drink (a lot). I left these field names as you posted in the function definitions - change them if you wish.

Anyway, I hope you have luck with what I have provided you. I have tested it (a little ;) )

I really have yellowSnow, I love the term 'nutted it out", used that alot in the Marine Corps! lol

I did go back to a previous version of my code with a GOTO still in it just because I did not want to mess up my "good version"

I am going to go through this today and let you know how I do.

I appreciate you sticking with me on this.

yellowSnow:
I like that code. It is so close to what I was trying to do that I understand it, and once I get it doing exactly what I want and become refined enough to improve on it I will have the base from which to build.

One question, why do I have to hit so many times after input?
For example, I input sale amount 10.00 and <enter>,
my prompt goes to the next line, but nothing happens.
I hit <enter> one more time and it continues to menu.
I select 1 as my menu option and hit <enter>.
Prompt goes to the next line, but I have to hit <enter> again to get calculations.

I had this same issue before, and never worked it out.

yellowSnow:
I like that code. It is so close to what I was trying to do that I understand it, and once I get it doing exactly what I want and become refined enough to improve on it I will have the base from which to build.

One question, why do I have to hit so many times after input?
For example, I input sale amount 10.00 and <enter>,
my prompt goes to the next line, but nothing happens.
I hit <enter> one more time and it continues to menu.
I select 1 as my menu option and hit <enter>.
Prompt goes to the next line, but I have to hit <enter> again to get calculations.
I had this same issue before, and never worked it out.

Did you use an exact copy of the code I posted? When I run the code (in either my IDE or in the DOS command shell), this is what I get:

Enter Amount of Sale $ 100
Tax Calculation for Purchase

1. Del Mar
2. Encinitas
3. La Jolla


Please Select Number of Store for Which to Calculate: 1

Del Mar         Sale $100.00    Rate 7.25%      Tax $7.25       Total=  $107.25


        Would you like to calculate for another store? (y/n) y
Enter Amount of Sale $ 200
Tax Calculation for Purchase

1. Del Mar
2. Encinitas
3. La Jolla


Please Select Number of Store for Which to Calculate: 2

Encinitas       Sale $200.00    Rate 7.50%      Tax $15.00      Total=  $215.00


        Would you like to calculate for another store? (y/n) y
Enter Amount of Sale $ 300
Tax Calculation for Purchase

1. Del Mar
2. Encinitas
3. La Jolla


Please Select Number of Store for Which to Calculate: 3

La Jolla        Sale $300.00    Rate 7.75%      Tax $23.25      Total=  $323.25


        Would you like to calculate for another store? (y/n) n

If you know how to use a debugger, then debug your code and see if you can find the reason why you need to "hit" <ENTER> more than once.

Sorry, that's all I have for you. The code I posted is pretty average but it should not be behaving the way you have described.

That is what I will do. I have never used a debugger before, so now is as good a time as anyone.

I did not really code your example verbatim, more I was trying to read it as I would mine, see what you had done, make sure I understood what you did and why, so that I could compare your logic to mine, and then try and alter my code to solve the same problem.
I probably didn't do it right.

I appreciate your help, and I am going to close this thread. You have given me more than enough information torwards solving this problem, and if I cannot do it on my own at this point then shame on me.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.