So, I'm making a program where the user makes a choice between 5 algorithms, so far it compiles just fine, and the components do the math perfectly, but I can't get the statements to execute just one chosen algorithm.
I tried a switch statement at first but I thought this would be easier, but instead of running just one component of the code, it just files through all the code sections, can anyone help?
Code:
#include <stdio.h>
#include <math.h>
int main()
{
double x,y,z,a,fusum,presum; //values for case 1
double choice;
printf("\nPlease choose which calculation to preform accordning to the number infront of the option:\n-------------------------------------------\n1.Single Payment Compount Ammount Formula.\n2.Single Payment Present Worth Formula.\n3.Uniform Payment Series A.\n4.Uniform Payment Series B.\n5.Uniform Payment Series C.\n\n");
scanf("%lf",&choice);
if (choice<=5) { printf("You chose:%1.0f\n",choice); }
else if (choice>5) {printf("Input not an option, please try again\n"); }
if(choice==1);
{
printf("Enter APR percent in decimal form, then number of years.\n"); //requesting inputs
scanf("%lf",&x); //assigning inputs
scanf("%lf",&y); // to be used for the APR and years passed
z = pow(x+1,y); //assigning number to be multiplied by current payment
printf("Enter current ammount sum:"); //requesting current payment
scanf("%lf",&a);
fusum = z * a;
printf( "%3.3f percent APR over %1.0f years, with current ammount of %.2f dollars is %.2f\n",x,y,a,fusum);
//expressing outputs along with terating base and power to eliminate mistakes.
}
if (choice==2);
{
printf("Entire APR percent in decimal form, then number of years.\n");
scanf("%lf",&x); //assigning inputs
scanf("%lf",&y); //to be used for the APR and years passed
z = pow(x+1,-y); //assigning number to be multiplied by current payment
printf("Enter future ammount wanted:");
scanf("%lf",&a);
presum = z * a;
printf("With %3.3f percent APR over %1.0f years, to get %.2f dollars a deposit of %.2f will be required\n",z,y,a,presum);
}
}