no1zson 24 Posting Whiz in Training

Remember if you have a scanf in a loop condition, you need to have a getchar inside and outside the loop. Here's the runtime after the modification's:

Thanks for that tip. I did not know that was a rule.
I will play with that when I get home again tonight. I have them inside, but did not know they needed to be outside as well.
I am guessing just a simple

getchar();

for the outside is what you are referring to, to balance what I already have inside.

no1zson 24 Posting Whiz in Training

Thanks again, I really do appreciate your efforts, and I am glad you are not aggravated.
I have gone to great lenghts to NOT copy your code because it is so well written (at least to me it is) and it does work. I just would not feel right with it.

It may look like I am not listening all the time, but I promise you I have studied EVERYTHING you guys have said, and tried most of it many times over. At the moment though I am just trying to stay as simple as I can and get through this class with code I can read and explain back to my instructor. Even if I do not use what you told me, it may have been a stepping stone to what I did use, as ugly as it ended up being! lol

What I have here works, and I have all the GOTOs out of it, but in my Miracle C is forces me to <ENTER> twice after I put in a number.

The code you wrote did the same thing for me, so I am assuming it is just Miracle C.

Again, thanks for your time and help, I am sorry I could not apply more of what you tried to teach me.

no1zson 24 Posting Whiz in Training

yellowSnow -
Are you really aggravated that I did not take your code and post it in my program verbatim? I thought the idea out here was NOT to do that.

I am not IGNORING your advice. I simply do not understand it all, or want to try something on my own.
I do not want free code handed out to me. I never asked for it, and I told you that. I also thanked your for your time, and I appreciate the effort you gave on the problem, but you also continually ignore what I am asking and simply gave me code. I loved the code, and it was a great help, but I still want to write and turn in my own work.

I ask for help in understanding, NOT free fixes to problems that I did not write. Your code was great, but I did not write it, and I do not want credit for it.
I am working on trying to understand problems and come up with my own fixes to things. I am never going to learn anything if I just take your code and put it in a program.
I know my fixes are not as smooth as yours, but I have been coding for 4 weeks now, I do not think they would be. If I just take your code, put it in my program and move on I am never going to learn anything.

tux4life commented: You're welcome :) +19
no1zson 24 Posting Whiz in Training

What is MinGW port of gcc?

no1zson 24 Posting Whiz in Training

That is what I have heard, but it is required for class.
I looked for a debugger today just to help me troubleshoot so that maybe I can quit bothering you guys with this silly stuff, but I cannot find anything that seems useful.

no1zson 24 Posting Whiz in Training

Thanks Dave.
I tried playing with those a few weeks ago when I first started, but just got confused.
I have been using scanf simply because it is a shorter command and easier to understand.

It confuses me how Hiroshe and yellowSnow both run the same code as me without having to hit <Enter> extra times but I do.

Could that be a Miracle C issue as well?

no1zson 24 Posting Whiz in Training

I need those for character validation. Without them, if a user puts in an A instead of 10.00 it freaks out.
I know there are better ways to do that, but right now that is simple and it works for me.

i will play with the getch(); and see what I can come up with.
Thanks

no1zson 24 Posting Whiz in Training

I have to hit <Enter> twice after inputting my dollar amount and store selection
I think I am just missing something simple somewhere, but am going stupid looking for it.

Went to the internet to try and find a good debugger, but have no idea how or where to even begin that process.

any suggestions are welcome

#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 $ "); 
    while ((scanf("%f", &fAmount) != 1) || (fAmount <= 0.0)) //week 5 character validation addition
		{         
		while (getchar() != '\n') {;}     // week 5 character validation    
		printf("PLEASE ENTER POSITIVE DOLLAR AMOUNT:");        
		}     
			while (getchar() != '\n') //week 5 character validation
			{;}    
			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); 
    while (getchar() != '\n') // week 5 character validation
	{;}     
	while (iSelection < 1 || iSelection > 3) //integer validation
	{        
	printf("INVALID NUMBER ENTERED! Please enter 1,2 or 3:");
	scanf("%d", &iSelection);        
		while (getchar() != '\n') //week 5 character …
no1zson 24 Posting Whiz in Training

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.

no1zson 24 Posting Whiz in Training

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.

no1zson 24 Posting Whiz in Training

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.

no1zson 24 Posting Whiz in Training

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 …
no1zson 24 Posting Whiz in Training

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.

no1zson 24 Posting Whiz in Training

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 …
no1zson 24 Posting Whiz in Training

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. :)

no1zson 24 Posting Whiz in Training

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 = …
no1zson 24 Posting Whiz in Training

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.

no1zson 24 Posting Whiz in Training

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?

no1zson 24 Posting Whiz in Training

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
no1zson 24 Posting Whiz in Training

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 …
no1zson 24 Posting Whiz in Training

never knew such a thing existed. I will give it a try.
Thanks again for all your help.

no1zson 24 Posting Whiz in Training

Thanks Yellow Snow, I am going to give that a try.
Can you help me on something stupid real quick? I have two copies of my code saved, one works and one does not (as you pointed out). For the life of me I cannot see the difference.
Can you look as this working version and tell me what is different?
I have gone through line by line and both versions look identical 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

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
    {
    printf("SALE AMOUNT CANNOT …
no1zson 24 Posting Whiz in Training

Here is the type of program I am talking about. It is not a nested loop or anything like that, but once I get to the end, if they user enters Y I would like to send them back to the top and start all over.
I am still not even sure how I would do this with the loop-inside-loop suggestion.

#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
    {
    printf("SALE AMOUNT CANNOT BE LESS THAN $0.00. Re-Enter: $ ");
        {
        scanf ("%f",&fSales); // scans new input for validity …
no1zson 24 Posting Whiz in Training

No.
Try to think about the real loop control and a better loop construct will come to mind.
---
http://en.wikipedia.org/wiki/Goto#Criticism_of_goto_usage

This suggestion intrigues me. Putting my main loop inside another loop. I am not sure I understand how to do it, and it sounds almost more complicated than the problems it might potentially avoid, but if anyone can expand on this thought I would appreciate it.
Again, my limited experience hinders my understanding at this point.

no1zson 24 Posting Whiz in Training

I am new to C programming and have been using the GOTO all over the place until today when I was informed it is not preferred practice, and due to its adverse affects on debugging and maintenance should only be used in the rarest of cases.

I can understand that I guess,.

Would an "acceptable" use of GOTO be to rerun the entire main loop? If I make it all the way through my logic, and simply want to start over at the top, would not a simple GOTO back to the top be the best option?

no1zson 24 Posting Whiz in Training

Thanks.
I was hoping that was well planned logic! lol

Shows what I know.

no1zson 24 Posting Whiz in Training

Meaning if it was not misused there is no issue?

Perhaps it is my lack of experience, but I would think a sharp mind might also weigh the possibility of future POTENTIAL issues against this program's simplicity and the cost of re-coding something that already works and find no real reason to remove it.

no1zson 24 Posting Whiz in Training

9868,
I am going to give that a try and see what happens. Thanks for the tips.
What is wrong with GOTO? What would you suggest in its place?

no1zson 24 Posting Whiz in Training

Adding to jephthah's reply, return 0 is optional in C99 standards. So you can remove it.

If I remove it my program does not compile. That is why I was asking. Was not sure what it was for, but I know it had to be there.

Thanks guys.

no1zson 24 Posting Whiz in Training

Thanks
I thought it was some kind of error deal.
What do you mean exactly, "It's on main()"

no1zson 24 Posting Whiz in Training

Sorry
Here is the entire program. Notice the last two loops. Return 0; completes them both. What does that accomplish?

#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

int displayMenu()  //defines menu variable
{ // menu 
    int selection; //defines selection variable
    printf("Tax Calculation for $125 Purchase\n\n");
    printf("1. Del Mar \n");
    printf("2. Encinitas \n");
    printf("3. La Jolla \n");
    printf("\n\nPlease Select Store for Which to Calculate [1-3]:");

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

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

    float sales = 125.00; // Sales value for calculations
    int store; //defines store for main loop, menu will not work without
      
    store = displayMenu(); //displays menu created above
    
    if (store == 1)
//Calculates and Displays Del Mar Store, Sales, Tax rate, and Tax
        printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, DelMar, sales*DelMar/100); //values are correct so I am leaving it this way. ahead of schedule here.
    if (store == 2)
//Calculates and Displays Encinitas Store, Sales, Tax rate, and Tax
        printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, Encinitas, sales*Encinitas/100);
    if (store == 3)
 //Calculates and Displays La Jolla Store, Sales, Tax rate, and Tax
        printf("\nLa Jolla \tSale $%.2f\tTax %.2f%%\tTax $%.2f%\t\n\n",sales, LaJolla, sales*LaJolla/100);
  
    if (store <1 || store >3) //if store number is not 1, 2 or 3
    {
    	printf("\nPlease enter 1,2 or 3\n");
    	
    	printf("\n\tINVALID NUMBER ENTERED! Would you like to try again? (y/n) ");//allows retry 
          scanf("%c", &cAgain);  //scans input at INVALID prompt 
            
               if (cAgain …
no1zson 24 Posting Whiz in Training

What exactly does the "Return 0;" indicate in this function?
I know my code will not even compile without it, but I have just been putting it in out of habit without realizing that I do not even know what it does. I was under the assumption that it meant this particular function returned a value of 0, or contained no parameters, but in this case that does not make sense to me.

Can somebody help me out?

if (store <1 || store >3) //if store number is not 1, 2 or 3
    {
    	printf("\nPlease enter 1,2 or 3\n");
    	
    	printf("\n\tINVALID NUMBER ENTERED! Would you like to try again? (y/n) ");//allows retry 
          scanf("%c", &cAgain);  //scans input at INVALID prompt 
            
               if (cAgain == 'y' || cAgain == 'Y')//repeats calculator
               {
               goto YES;  //back to top
               }
               else if (cAgain == 'n' || cAgain == 'N')//end
                           
    return 0;  
    }
no1zson 24 Posting Whiz in Training

Thanks guys. Eliminating the switch ended up being the way to go. It was quicker than playing with the whole IF mess.
I still have a little syntax stuff to work out but your help is much appreciated.
I will post final code if you even care to see it. Otherwise I will just close the thread.

no1zson 24 Posting Whiz in Training

PetuniaRose, you and me both. I am no C programmer by a long shot.
You were right about the second IF, but my problem appears to be in my switch statement. If I take it out

{ 	
  	switch (storenum) // simple switch which responds to corresponding menu choice with output
    }

I go straight through the program executes, but goes straight to the INVALID NUMBER error no matter what I input. Leave it in and my parse error is on that line.

no1zson 24 Posting Whiz in Training

Brilliant suggestion Hiroshe,
I took that out altogether, did a few quick adjustments and eliminated a lot of unneeded code.
Trouble is, now I get no output! lol
No matter what I enter I end up at INVALID NUMBER.

Any suggestions?

if (storenum == '1')
//Calculates and Displays Store, Sales, Tax rate, Tax for Del Mar
        printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, DelMar, sales*DelMar/100); //values are correct so I am leaving it this way. ahead of schedule here.
    else if (storenum == '2')
//Calculates and Displays Store, Sales, Tax rate, and Tax for Encinitas
        printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, Encinitas, sales*Encinitas/100);
    else if (storenum == '3')
 //Calculates and Displays Store, Sales, Tax rate, and Tax for La Jolla
        printf("\nLa Jolla \tSale $%.2f\tTax %.2f%%\tTax $%.2f%\t\n\n",sales, LaJolla, sales*LaJolla/100);
  
    else if (storenum <'1' || storenum >'3')
    {
    fflush(stdin);
    	printf("\nPlease enter 1,2 or 3\n");
    	
    	printf("\n\tINVALID NUMBER ENTERED! Would you like to try again? (y/n) ");//allows repeat 
            scanf("%c", &cAgain);  //scan input to repeat program
            
               if (cAgain == 'y' || cAgain == 'Y')//repeats calculator
               {
               goto YES;  //back to menu
               }
               else if (cAgain == 'n' || cAgain == 'N')//sends to end
                           
   return 0;  
    }
no1zson 24 Posting Whiz in Training

I caught that too PetuniaRose, I am still getting a parse error on that line though, and it seems like it should work to me.

if (storenum >=1 && if storenum <=3)     //While Loop to Request Input of 1,2,or 3, still working on this
    {
 	
  	switch (storenum) // simple switch which responds to corresponding menu choice with output
    }
no1zson 24 Posting Whiz in Training

Sorry MosaicFuneral, I do not even know what that means.
If I could I would like to get it working correctly as I have it in my mind and then refine from there. I also have a few ideas in that arena, but first want to execute to see how this works.

I have adjusted my code, I think I am close but it will not compile.

if (storenum >=1 && if storenum <=3)     //While Loop to Request Input of 1,2,or 3, still working on this
    {
 	
  	switch (storenum) // simple switch which responds to corresponding menu choice with output
  }
    {
    case 1:
//Calculates and Displays Store, Sales, Tax rate, Tax for Del Mar
        printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, DelMar, sales*DelMar/100); //values are correct so I am leaving it this way. ahead of schedule here.
        break;
    case 2:
//Calculates and Displays Store, Sales, Tax rate, and Tax for Encinitas
        printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, Encinitas, sales*Encinitas/100);
        break;
    case 3:
//Calculates and Displays Store, Sales, Tax rate, and Tax for La Jolla
        printf("\nLa Jolla \tSale $%.2f\tTax %.2f%%\tTax $%.2f%\t\n\n",sales, LaJolla, sales*LaJolla/100);
        break;
    } //Storenum switch end
    }
    else
    {
    fflush(stdin);
    	printf("\nPlease enter 1,2 or 3\n");
    	
    	printf("\n\tINVALID NUMBER ENTERED! Would you like to try again? (y/n) ");//allows repeat 
            scanf("%c", &cAgain);  //scan input to repeat program
            
               if (cAgain == 'y' || cAgain == 'Y')//repeats calculator
               {
               goto YES;  //back to menu
               }
               else if (cAgain == 'n' || cAgain == 'N')//sends to end
                           
   return 0;  
    }

This is the …

no1zson 24 Posting Whiz in Training

Hiroshe,
I started with a While loop and decided to change.

What I am now trying to do is IF 1 2 or 3, go to the appropriate CASE statement,
ELSE go to my INVALID error statement.

no1zson 24 Posting Whiz in Training

Sorry. You are right. I am just having one of those days.

If the user selects 1, 2 or 3 then they should be sent to the CASE switch, otherwise down to the INVALID error message and forced to reenter the correct number.

Right now I am getting a compile error.
'if storenum >=1 || if storenum <=3 { switch (storenum) { case 1: printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, 7.25, sales*7.25/100)'
aborting compile

no1zson 24 Posting Whiz in Training

Hey guys, maybe I am just worn out today, but can somebody look at my IF loop (the first one for selcting 1-3) and see where I am going wrong?
Everything else seems to be pretty good I think, but this is aggravating me to no end.
Thanks

#include <stdio.h>  // standard input output library
#include <string.h> // basic string handling library added for cAgain option

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

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

int displayMenu()  // creates menu
{
    int choice;
    printf("Tax Calculation for $125 Purchase\n\n");
    printf("1. Del Mar \n");
    printf("2. Encinitas \n");
    printf("3. La Jolla \n");
    printf("\n\nPlease Select Store for Which to Calculate [1-3]:");

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

int main()
{
YES:
{				
// Sales value for calculations
    float sales = 125.00;
    int storenum;
   

    storenum = displayMenu();
    if storenum >=1 || if storenum <=3     //While Loop to Request Input of 1,2,or 3, still working on this
    {
 	
  	switch (storenum) // simple switch which responds to corresponding menu choice with output
    {
    case 1:
//Calculates and Displays Store, Sales, Tax rate, Tax for Del Mar
        printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, DelMar, sales*DelMar/100); //values are correct so I am leaving it this way. ahead of schedule here.
        break;
    case 2:
//Calculates and Displays Store, Sales, Tax rate, and Tax for Encinitas
        printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\t\n\n",sales, Encinitas, sales*Encinitas/100);
        break;
    case 3:
//Calculates and Displays Store, Sales, Tax rate, and Tax for La Jolla …
no1zson 24 Posting Whiz in Training

I am one of the people helped through this recently.
Search on my name, there should be more than enough detail in those posts to answer any question for this assignment.
I am pretty sure I asked them all! :o)

no1zson 24 Posting Whiz in Training

Hey Catgirl. Search on my name.
Some of the guys helped me work through this exact assignment some months back.

no1zson 24 Posting Whiz in Training

Thanks Ezzaral, that is exactly what I needed to know.

no1zson 24 Posting Whiz in Training

So any child class of Super is going to begin with a height of 1 and width of 2.
You could then add things such as area, volume and other attributes from that base.

Could you also change one of the original attributes? Say if I wanted to call Super, but make the newest object have a height of 2.

no1zson 24 Posting Whiz in Training

The people looking for help are as varied as those offering.
I too am a very visual learner, and need examples, and found NO real help until this forum.
It does seem that some "helpers" only want to help those that do not need help at all.
While this post is a little silly and just looks like someone looking for answers, there is no need to berate the OP and make them feel stupid. If you do not want to help, then do not help, but if you are only here to push it in other peoples face how inept they are as compared to you, then who really needs the help?
I know I have asked ALOT of stupid questions, but I do try, and I keep trying, and sometimes I just do not get it. Ezzaral in particular turned the light on in my head more than once, and was more helpful than my first instructor. So, where some people would see my post as just lame or dumb, he took the time to walk through some very basic concepts with me and I am a better programmer today because of it.

no1zson 24 Posting Whiz in Training

I really do not understand why some people even reply. It seems like they want to do anything BUT be helpful.

no1zson 24 Posting Whiz in Training

That was cool. The red reallyhelps me follow what you are talking about as well.

no1zson 24 Posting Whiz in Training

I used the book from Deitel (still do), and have found that the best way for me too learn is to just start coding.
I had very little COBOL programming experience years and years ago, so this was really my first modern language, and it is so vast that it takes time.
Peter is absolutley right about the IDE. I tried using NetBeans at first, but when you do not know exactly what is going on, the "help" NetBeans tries to offer you is even beyond understanding and just ends up confusing.

no1zson 24 Posting Whiz in Training

That is what I did. Simple little projects that did only one or two things. After I had a basic understanding of how the classes worked, I then started more complicated (to me) things.
This is where I learned the most. Implimenting arrays, Jlists, GUI and all that. I spent most of my time out here working through my problems, but once on the other side and could look back at how I started, how the problems were solved, and how it all works, I have such a better understanding.
That has always been my process for learning though, yours may be different.

no1zson 24 Posting Whiz in Training

Not that I really have a firm grasp on it yet, but the best way for me to pick up the logic and uses of the language is just to start coding and working through the errors I get.
The logic I can usually pick up after a short time, but working through the errors (with the help of the guys out here) helped with my syntax more than anything.