Hi I am working on a calculator and I have choices on what to solve. First, you will be asked how many given you have. For this code, I just made 3 given. So by default, input 3. Next, I have a list of 11 given in order to solve all the equations. The user will chose 3 numbers from 1-11... I have started a case using number 1,3,9 and 1,3,10, and 1,3,11. So my problem is that when I choose 1,3,10 randomly, for example I change the order in my input in the choice,choice2,choice 3 by choosing 3,10,1 instead of 1,3,10...
So let's say I will choose 1,3,10 but I inputted it in this order... 10,3,1.. but still must go to the action that it will implement.
I used the following line for my if statement... if(choice==1,3,10 && choice2==1,3,10 &7 choice3==1,3,10) then execute action...
and
if( (choice== 1 || 3 || 10) && (choice2== 1 || 3 || 10) && (choice3== 1 || 3 || 10)) then execute action...
I've tried those above but it won't execute the statements below it... But it will execute the one above...
#include<stdio.h>
#include<conio.h>
#include<math.h>
#define PI 3.14159265
int main(){
double length, angle, radius, tangent, chord, midordinate, external, degree;
double pcurve,ptan,pintersect;
double ulength, udegree, uangle, uradius, utangent, uchord, umidordinate, uexternal;
int choice, choice2, choice3, given;
//For sin, cos, tan
double x, ret, val;
val = PI / 180;
printf("Enter number of given: ");
scanf("%d",&given);
if(given==3){
choice:
printf("[1] - Angle\n");
printf("[2] - Degree\n");
printf("[3] - Radius\n");
printf("[4] - Length of Curve\n");
printf("[5] - Tangent\n");
printf("[6] - Chord\n");
printf("[7] - Midordinate\n");
printf("[8] - External Distance\n");
printf("[9] - Point of Intersection\n");
printf("[10] - Point of Curve\n");
printf("[11] - Point of Tangent\n");
printf("\n");
printf("Enter 1st given: ");
scanf("%d",&choice);
printf("Enter 2nd given: ");
scanf("%d",&choice2);
printf("Enter 3rd given: ");
scanf("%d",&choice3);
printf("\n-----------------------------------\n");
if(choice==1,3,9 && choice2==1,3,9 && choice3==1,3,9){
printf("Enter angle: ");
scanf("%lf",&angle);
printf("Enter radius: ");
scanf("%lf",&radius);
printf("Enter Point of Intersection (Point of Curve Value): ");
scanf("%lf",&pcurve);
printf("Enter Point of Intersection (Tangent Value): ");
scanf("%lf",&tangent);
printf("-----------------------------------\n");
printf("\nGIVEN:\n");
printf("-----------------------------------\n");
printf("Angle = %lf\n",angle);
printf("Radius = %lf\n",radius);
printf("Point of Intersection (PI) = %lf + %lf\n", pcurve,tangent);
uangle = angle/2;
printf("-----------------------------------\n");
printf("\nRESULTS:\n");
printf("-----------------------------------\n");
length=(radius*angle*PI)/180;
tangent = radius * (tan(uangle*val));
chord = 2*radius*(sin(uangle*val));
midordinate = radius - (radius*(cos(uangle*val)));
external = radius *( (1/(cos (uangle*val) ) ) - 1 ) ;
pintersect = pcurve + tangent;
pcurve = pintersect - tangent;
ptan = pcurve + length;
printf("Radius = %lf\n",radius);
printf("Length of Curve = %lf\n",length);
printf("Tangent = %lf\n",tangent);
printf("Chord = %lf\n",chord);
printf("Mid Ordinate = %lf\n",midordinate);
printf("External Distance = %lf\n",external);
printf("Point of Intersection = %lf\n",pintersect);
printf("Point of Curve = %lf\n",pcurve);
printf("Point of Tangent = %lf\n",ptan);
}
else
if( (choice== 1 || 3 || 10) && (choice2== 1 || 3 || 10) && (choice3== 1 || 3 || 10)){
printf("Enter angle: ");
scanf("%lf",&angle);
printf("Enter radius: ");
scanf("%lf",&radius);
printf("Enter Point of Curve (Point of Intersection Value): ");
scanf("%lf",&pintersect);
printf("Enter Point of Curve (Tangent Value): ");
scanf("%lf",&tangent);
printf("-----------------------------------\n");
printf("\nGIVEN:\n");
printf("-----------------------------------\n");
printf("Angle = %lf\n",angle);
printf("Radius = %lf\n",radius);
printf("Point of Curve (PC) = %lf - %lf\n", pintersect,tangent);
uangle = angle/2;
printf("-----------------------------------\n");
printf("\nRESULTS:\n");
printf("-----------------------------------\n");
length=(radius*angle*PI)/180;
tangent = radius * (tan(uangle*val));
chord = 2*radius*(sin(uangle*val));
midordinate = radius - (radius*(cos(uangle*val)));
external = radius *( (1/(cos (uangle*val) ) ) - 1 ) ;
pintersect = pcurve + tangent;
pcurve = pintersect - tangent;
ptan = pcurve + length;
printf("Radius = %lf\n",radius);
printf("Length of Curve = %lf\n",length);
printf("Tangent = %lf\n",tangent);
printf("Chord = %lf\n",chord);
printf("Mid Ordinate = %lf\n",midordinate);
printf("External Distance = %lf\n",external);
printf("Point of Intersection = %lf\n",pintersect);
printf("Point of Curve = %lf\n",pcurve);
printf("Point of Tangent = %lf\n",ptan);
}
if(choice==1,3,11 && choice2==1,3,11 && choice3==1,3,11){
printf("Enter angle: ");
scanf("%lf",&angle);
printf("Enter radius: ");
scanf("%lf",&radius);
printf("Enter Point of Tangent (Point of Curve Value): ");
scanf("%lf",&pintersect);
printf("Enter Point of Tangent (Length Value): ");
scanf("%lf",&length);
printf("-----------------------------------\n");
printf("\nGIVEN:\n");
printf("-----------------------------------\n");
printf("Angle = %lf\n",angle);
printf("Radius = %lf\n",radius);
printf("Point of Curve (PC) = %lf + %lf\n", pcurve,length);
uangle = angle/2;
printf("-----------------------------------\n");
printf("\nRESULTS:\n");
printf("-----------------------------------\n");
length=(radius*angle*PI)/180;
tangent = radius * (tan(uangle*val));
chord = 2*radius*(sin(uangle*val));
midordinate = radius - (radius*(cos(uangle*val)));
external = radius *( (1/(cos (uangle*val) ) ) - 1 ) ;
pintersect = pcurve + tangent;
pcurve = pintersect - tangent;
ptan = pcurve + length;
printf("Radius = %lf\n",radius);
printf("Length of Curve = %lf\n",length);
printf("Tangent = %lf\n",tangent);
printf("Chord = %lf\n",chord);
printf("Mid Ordinate = %lf\n",midordinate);
printf("External Distance = %lf\n",external);
printf("Point of Intersection = %lf\n",pintersect);
printf("Point of Curve = %lf\n",pcurve);
printf("Point of Tangent = %lf\n",ptan);
}
}
getch();
return 0;
}
Aucun commentaire:
Enregistrer un commentaire