From: Frazell T. <fr...@fl...> - 2001-01-16 13:10:19
|
Im trying to add another feature to my primitive program :O) I was trying to add a regular calculator allowing a choice from the quadratic equation calculator and from a regular arithmetic calculator I keep getting two errors which I marked in the code below Im still a beginner so I as if what Im trying to do even possible if not can I have a program open either one (each in its own executable) if so how? Thanks Error summary 1. Parse error before else line 69 2. Parse error before } line 100 The errors are marked with a < ---------------- in red if you can read html mail ---------------------------------------------------------------------------S ORCE CODE (Errors are marked below in color which may require HTML email to see)------------------------------------------------------------------------ ------------------------------------ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <windows.h> char type; int a,b,c; float sroot, divide, answer_1, answer_2; double determinent; float calc1,calc2; int calc3; char typec; int main() { //Asks user which caculator does he/she want to start printf("What type of calcultor do you need? Please enter 'Q' for Quadratric Eqations \nand 'C' for a stadered calculator: "); scanf("%c" ,&type); // Determines which calculator user selected and uses the one chosen if(type=='Q'); { printf("This program is designed to do quadratic equations only.\n"); printf("You are free to use this software as stated under the GNU\n"); printf("Public License (Avalible at GNU.org).\n\n"); printf("Version: Beta 1.4 1/3/2001 6:00AM EST.\n"); printf("Programmer: Frazell Thomas\n"); printf("Programmer: Hoo Hong\n"); printf("Please visit http://www.frazellthomas.com\n\n"); // Input From User printf("Please enter the number used to represent varible A: "); scanf("%d", &a); // if statement to prevent the divide error if the var. a is zero if (a == 0) { printf("\nSorry you entered 0 this will result in an error try again."); printf("\nPlease enter the number used to represent varible A: "); printf("\nEnter 0 again to quit: "); scanf("%d", &a); if (a==0) { return 0; } } printf("\nPlease enter the number used to represent varible B: "); scanf("%d", &b); printf("\nPlease enter the number used to represent varible C: "); scanf("%d", &c); determinent = (pow(b,2) - 4*a*c); if (determinent < 0) { printf("\nSorry, The equation you entered returned no real result.\n"); printf("Please re-run the program entering an equation that will give you a real result."); system("Pause"); return 0; } sroot = sqrt(determinent); divide = 2 * a; answer_1 = (-b - sroot) / divide; answer_2 = (-b + sroot) / divide; // Prints the answer printf("\nThe Answer Is %.4f and %.4f\n ", answer_1, answer_2); system("Pause"); return 0; } else if(type=='C') < -----------------Parse error before else { printf("\nPlease input the first integer: "); scanf("%f" ,&calc1); printf("\nEnter the sign ('+','-','*','/'): "); scanf("%c" ,&typec); printf("\nPlease input the second integer: "); scanf("%f" ,&calc2); if(typec=='+') { calc3=calc1+calc2; } if(typec=='-') { calc3=calc1-calc2; } if(typec=='*') { calc3=calc1*calc2; } if(typec=='/') { calc3=calc1/calc2; } //Returns Answer From Standerd Calculator To User printf("\n%f %c %f = %f ",calc1,typec,calc2,calc3); system("PAUSE"); return 0; } } < ------------------Parse error before } |