Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- #include <string.h>
- int main(void) {
- char form[25];
- char var[10];
- int a, h, k;
- int vertex;
- int upDown = 0;
- int oldK, oldH = 0;
- float aTwo, b, c;
- char parabola[10];
- float five = 0.0;
- float y, x;
- printf("Hello, would you like to use vertex form or standard form? \n");
- scanf("%s", form);
- printf("\n --------------------------------- \n \n");
- if(strcmp(form, "vertex") == 0) {
- printf("Vertex form is Y = a(x-h)² + k \n"); //PEMDAS
- printf("\n --------------------------------- \n \n");
- printf("Do you have the variables a, h, and k? Answer Yes or No.\n");
- scanf("%s", var);
- printf("\n --------------------------------- \n \n");
- if(strcmp(var, "yes") == 0) { //This program tells the user about the various things that their formula gives them
- printf("Please enter the variables in the following order: a, h, and then k \n");
- scanf("%d %d %d", &a, &h, &k);
- printf("\n --------------------------------- \n \n");
- //int oldKTwo = k;
- oldH = h;
- //Movement left and right
- if(h>0) { //so if H is positive, continue
- //H will go right
- printf("The X goes right by %d \n", h);
- }
- else { //So the H is negative here
- //H will go left
- printf("The X goes left by %d \n", abs(h));
- }
- //Movement up and down
- if(k>0) { //K is positive here
- //K goes up here
- printf("The Y will go up by %d \n", k);
- }
- else { //K is negative here
- //K will move down here
- printf("The Y will go down by %d \n", abs(k));
- }
- if(a>1) {
- printf("The parabola has been stretched by a factor of %d \n", a);
- }
- else {
- printf("The parabola has been compressed by a factor of %d, and has been flipped across the X axis. \n", abs(a));
- upDown = 1;
- }
- //Axis of symmetry; X = H
- printf("The Axis of Symmetry is X = %d \n", h);
- //Max or Min; if upDown == 1, then it's opening down, and it will have a Max
- if(upDown == 1) {
- printf("The maximum is %d \n", k);
- }
- else {
- printf("The minimum is %d \n", k);
- }
- //Domain & Range
- printf("The Domain is = all real numbers \n");
- if(upDown == 1) {
- printf("The Range is = all real numbers LESS than or EQUAL to %d \n", k);
- }
- else {
- printf("The Range is = all real numbers GREATER than or EQUAL to %d \n", k);
- }
- //Vertex
- printf("Vertex is (%d, %d) \n", h, k);
- printf("\n --------------------------------- \n \n");
- if(h<0) {
- if(k<0) {
- printf("Your vertex formula is Y = %d(x+%d)² - %d \n", a, abs(h), abs(k));
- }
- if(k>0) {
- printf("Your vertex formula is Y = %d(x+%d)² + %d \n", a, abs(h), k);
- }
- }
- if(h>0) {
- if(k<0) {
- printf("Your vertex formula is Y = %d(x-%d)² - %d \n", a, h, abs(k));
- }
- if(k>0) {
- printf("Your vertex formula is Y = %d(x-%d)² + %d \n", a, h, k);
- }
- }
- printf("\n --------------------------------- \n \n");
- //Vertex to Standard form
- //(a+b)² = a² + 2ab + b²
- /* Example
- Y = a(x-h)² + K >>> Y = Ax² + Bx + C
- (a+b)² = a² + 2ab + b²
- (x-h)² = x² + 2x*(-h) + (-h)² *
- Y = 2(x+3)² - 22
- (x+3)² = x² + 6x + 9
- Y = 2(x² + 6x + 9) -22
- Y = 2x² + 12x + 18 - 22
- Y = 2x² + 12x - 4
- Y = a(x-h)² + k
- Y = a(x² + 2x(-h) + (-h)²) + k
- Y = ax² + a*2x(-h) + a(-h)² + k
- Then ^ combine ^
- */
- if(h<0) {
- //printf("Y = %d(x-(%d))² + (%d) \n", a, h, k);
- int kaiser = 2 * h;
- int schibbe = pow(h, 2);
- //printf("(x+(%d))² = x² + %dx + (%d) \n", h, abs(kaiser), schibbe);
- //printf("Y = %d(x² + %dx + (%d) + %d \n", a, abs(kaiser), schibbe, k);
- int lacht = a * schibbe;
- int rein = a * abs(kaiser);
- int kurwa = lacht + k;
- printf("Your standard formula is Y = %dx² + (%d)x + (%d) \n", a, rein, kurwa);
- }
- if(h>0) {
- int kaiser = 2 * h;
- int schibbe = pow(h, 2);
- int lacht = a * schibbe;
- int rein = a * abs(kaiser);
- int kurwa = lacht + k;
- printf("Your standard formula is Y = %dx² - (%d)x + (%d) \n", a, rein, kurwa);
- }
- /*printf("Y = %d(x-(%d))² + (%d) \n", a, h, k);
- int kaiser = 2 * h;
- int schibbe = pow(h, 2);
- printf("(x+(%d))² = x² + %dx + (%d) \n", h, kaiser, schibbe);
- printf("Y = %d(x² + 2x(%d) + (%d)²) + %d \n", a, h, h, k);
- printf("Y = %dx² + %d * 2x(%d) + %d(%d)² + %d \n", a, a, h, a, h, k);*/
- //printf("Your standard formula is Y = ")
- }
- /*if(strcmp(var, "no") == 0) { //This program will write the formula for the user based on the things they input
- printf("Please enter the following: \n");
- //Enter vertex
- printf("Vertex \n");
- scanf("%d %d", &h, &k);
- //Does it open up or down
- //printf("Does it open or down? \n");
- //scanf("%s", parabola); //If up, the a will be positive. If down, the a will be negative
- //if the points move by something, you can find out what a is by putting Y/X and simplifying
- printf("What is another point? (x,y)\n");
- scanf("%d %d", &x, &y);
- printf("\n --------------------------------- \n \n");
- //printf("Your current two points are v(%d, %d) and (%d, %d) \n \n \n", h, k, x, y);
- float aa = y/x;
- printf("The formula is Y = %g(x - (%d)) + (%d) \n", aa, h, k);
- //Y = a(x-h)² + k
- }*/
- }
- if(strcmp(form, "standard") == 0) {
- printf("Standard form is Y = Ax² + Bx + C \n \n");
- printf("Please enter the variables in this order: a, b, c. \n \n");
- scanf("%g %g %g", &aTwo, &b, &c);
- printf("\n --------------------------------- \n \n");
- //Parabola opening
- if(aTwo>0) {
- printf("The parabola opens upward.\n ");
- }
- else {
- printf("The parabola opens downward.\n");
- }
- //Axis of Symmetry
- float psy = b * -1;
- float dave = 2*aTwo;
- float axis = b/dave;
- axis*=-1.0;
- printf("The Axis of Symmetry is X = %g \n", axis); //Axis of Symmetry
- //Y coordinate
- float one = pow(axis, 2);
- float two = one * aTwo;
- float three = b * axis;
- float four = c;
- float five = two + three + four;
- printf("The Y coordinate is %g \n", five); //Y coordinate
- printf("The vertex is (%g, %g) \n", axis, five); //vertex
- printf("The y-intercept is (0, %g) \n", c); //Y intercept
- //Max and Min
- if(aTwo>0) {
- printf("The minimum is %g \n", five);
- }
- else {
- printf("The maximum is %g \n", five);
- }
- //Range
- if(aTwo>0) {
- printf("The range is Y ≥ %g \n", five); //Minimum
- }
- else {
- printf("The range is Y ≤ %g \n", five); //Maximum
- }
- //Turn the standard form into vertex form using the vertex.
- //Vertex form is Y= a(x-h)² + K
- //standard form is Y= Ax² + Bx + C
- //aTwo=a, axis=h, five=k
- printf("The vertex form is Y = (%g)(x - (%g)) + (%g) \n", aTwo, axis, five);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement