I have been working on a simple c program using miracle C as my compiler. I have been able to get to this point:
However, now I am trying to get a loop with a case statement for a menu prompt and this is where I stumble. Here is the code so far:Code://// Brian Sirrine //// POS 370 #include <stdio.h> int main(void) { //// Define sales tax for locations float DELMAR = .0725; float ENCINITAS = .0750; float LAJOLLA = .0775; //// Define purchase price float PURCHASE = 0.00; //// Define a restart point Start: printf("***********************************************************************\n") ; printf(" Kudler Fine Foods Purchase Price w/tax\n"); printf("***********************************************************************\n\n") ; printf("Please type the purchase price and then press enter.\n\n"); scanf("%f", &PURCHASE); //// Start of if statements if(PURCHASE<=0.0) { printf("Please enter a number greater than Zero\n"); //// This will redirect the program back to the Start: goto Start; } else { ////if (typeof(PURCHASE) == typeof(int)) { //// Display to the user the tax calculations from all three locations printf("***********************************************************************\n") ; printf("Purchase Price -----> $%.2f\n" , (PURCHASE) ); printf("Delmar's Tax -----> + $%.2f\n" , (DELMAR*PURCHASE) ); printf(" =======\n") ; printf("Total With Tax -----> $%.2f\n" , (DELMAR*PURCHASE)+PURCHASE ); printf("***********************************************************************\n") ; printf("Purchase Price -----> $%.2f\n" , (PURCHASE) ); printf("Encinita's Tax -----> + $%.2f\n" , (ENCINITAS*PURCHASE) ); printf(" =======\n") ; printf("Total With Tax -----> $%.2f\n" , (ENCINITAS*PURCHASE)+PURCHASE ); printf("***********************************************************************\n") ; printf("\n") ; printf("Purchase Price -----> $%.2f\n" , (PURCHASE) ); printf("Lajolla's Tax -----> + $%.2f\n" , (LAJOLLA*PURCHASE) ); printf(" =======\n") ; printf("Total With Tax -----> $%.2f\n" , (LAJOLLA*PURCHASE)+PURCHASE ); printf("***********************************************************************\n\n\n") ; } } printf("Press any key to quit") ; getchar(); return 0 ; }
I cant figure out where I am messing up. Any help would be great. ThanksCode://// Brian Sirrine //// POS 370 #include <stdio.h> int main(void) { //// Define sales tax for locations float DELMAR = .0725; float ENCINITAS = .0750; float LAJOLLA = .0775; //// Define purchase price float PURCHASE = 0.00; //// Define a restart point Start: printf("***********************************************************************\n") ; printf(" Kudler Fine Foods Purchase Price w/tax\n"); printf("***********************************************************************\n\n") ; printf("Please type the purchase price and then press enter.\n\n"); printf("Press Q to End Program \n\n") ; scanf("%f", &PURCHASE); //// Start of Do While statement if (PURCHASE <=0.0) { pintf("enter a number Greater than 0 \n") ; goto Start; } else { if (PURCHASE >=0) ////if (typeof(PURCHASE) == typeof(int)) { char menu; printf("A: --> Delmar \n") ; printf("B: --> Encinitas \n") ; printf("C: --> LAJOLLA \n") ; printf("Choose a location. A, B, or C? \n"); scanf(" %c", &menu); menu = toupper(menu); /* case */ switch (menu) { case 'A': printf("You have selected A \n"); printf("***********************************************************************\n") ; printf("Purchase Price -----> $%.2f\n" , (PURCHASE) ); printf("Delmar's Tax -----> + $%.2f\n" , (DELMAR*PURCHASE) ); printf(" =======\n") ; printf("Total With Tax -----> $%.2f\n" , (DELMAR*PURCHASE)+PURCHASE ); printf("***********************************************************************\n") ; break; case 'B': printf("You have selected B \n"); printf("Purchase Price -----> $%.2f\n" , (PURCHASE) ); printf("Encinita's Tax -----> + $%.2f\n" , (ENCINITAS*PURCHASE) ); printf(" =======\n") ; printf("Total With Tax -----> $%.2f\n" , (ENCINITAS*PURCHASE)+PURCHASE ); printf("***********************************************************************\n") ; break; case 'C': printf("You have selected C \n"); printf("\n") ; printf("Purchase Price -----> $%.2f\n" , (PURCHASE) ); printf("Lajolla's Tax -----> + $%.2f\n" , (LAJOLLA*PURCHASE) ); printf(" =======\n") ; printf("Total With Tax -----> $%.2f\n" , (LAJOLLA*PURCHASE)+PURCHASE ); printf("***********************************************************************\n\n\n") ; break; default: Printf("Invalid selection \n"); } /* end case */ } } } else printf("Press any key to quit") ; getchar(); return 0 ; }



LinkBack URL
About LinkBacks



