Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a simple computer program that asks the user for a coordinate value in a c

ID: 3527504 • Letter: W

Question

write a simple computer program that asks the user for a coordinate value in a certain form, and then reports the number in all three forms. This will be repeated for input coordinates of all three forms. 1) explain to the user what the program does. 2) Your program should then ask the user to enter a coordinate in decimal degrees. After performing the necessary calculations it should report the value of the coordinate in all three forms. For example, if the user entered 42.87157, then your program might report: 42.87157 degrees is equal to 42 degrees 52.294 minutes, which is also equal to 42 degrees 52 minutes 17.64 seconds. 3) Next your program should ask for another coordinate, this time in degree decimal minute form. ( Two values will need to be read in, first the degrees and then the decimal minutes, using separate printf statements to ask for the input and separate scanf statements to read in the answers. ) This should also be reported in all three forms, starting with the user's input, e.g.: 42 degrees 52.294 minutes is equal to 42.87157 degrees, which is also equal to 42 degrees 52 minutes 17.64 seconds. 4) Finally the program should ask for a third coordinate in degree minute second form, which it converts and reports back in all three forms in a similar manner.

Explanation / Answer

/*100% working code*/ Please Rate me

#include <stdio.h>
#include <stdlib.h>

int main()
{
    float degree,minute, second;
    int newDegree;
    printf(" *****Demonstration-1*****");
    printf(" Enter the coordinate in Decimal Degree:");
    scanf("%f",&degree);
    minute=60*(degree-(int)(degree));
    second=60*(minute-(int)(minute));
    printf(" %f degree is equal to %d degree %f minutes",degree,(int)degree,minute);
    printf(" which is equal to %d degree %d minute %.2f second.",(int)degree,(int)minute,second);

    printf(" *****Demonstration-2*****");
    printf(" Enter the coordinate in Decimal Degree:");
    scanf("%f",&degree);
    printf(" Enter the coordinate in Decimal Minute:");
    scanf("%f",&minute);
    second=60*(minute-(int)(minute));
    printf(" %d degree %f minutes is equal to ",(int)degree,minute);
    degree=(float)degree+(float)(minute/60);
    printf("%f degree",degree);
    minute=60*(degree-(int)(degree));
    second=60*(minute-(int)(minute));
    printf(" which is also equal to %d degree %d minute %.2f second.",(int)degree,(int)minute,second);

    printf(" *****Demonstration-3*****");
    printf(" Enter the coordinate in Decimal Degree:");
    scanf("%f",&degree);
    printf(" Enter the coordinate in Decimal Minute:");
    scanf("%f",&minute);
    printf(" Enter the coordinate in Decimal Second:");
    scanf("%f",&second);
    printf(" %d degree %d minutes %f second is equal to ",(int)degree,(int)minute,second);
    minute=minute+(float)(second/60);
    degree=(float)degree+(float)(minute/60);
    printf("%f degree",degree);
    minute=60*(degree-(int)(degree));
    printf(" which is also equal to %d degree %f minute",(int)degree,minute);
    return 0;
}