Write a program that accepts an angle x in degrees and then

Write a program that accepts an angle, x, in degrees and then calculates the value of sin(x) and outputs it to the screen. Example input: x = 30, sin(30) = 0.5 Write a program which gets as input a time as a number of seconds after midnight and outputs it (with appropriate descriptions) hours minutes seconds. For if the input were 50000 the output should be 13 example hours: 53 minutes 20 seconds All programs that are assigned in this class will require, for full credit: An algorithm describing the plan of solution A hard copy of the program An electronic copy of the program in the form filename.cpp - sent as an attachment on an email sent to mewilliams@umes.edu The filename should include your name or initials and a Program number. The program should contain comments describing or explaining lines or sections or code. In particular, at the beginning of the program you (in comments) the name or the program, will put program does the name of the person who wrote the program, and a brief description of what the are Further into the program, you will use comments lo describe the purpose of variables that defined in the program. You should also describe the usage of control statements and decision making statements.

Solution

1.

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
    double pi, x, result, d;
  
    pi = acos(-1); //pi is cos inverse -1
    cout<<\"Enter degree: \";
    cin>>d; //data input
    x = d * pi /180; // degree to radian convertion
    result = sin(x); // get results using radian
    cout<<\"sin(\"<<d<<\") = \"<<result<<endl; //print
    return 0;
}


2.

#include <iostream>
int main()
{
    long seconds;
    int hr, min, sec;
    cout<<\"Enter seconds: \";
    cin>>seconds; //data input
    sec = seconds % 60; // sec is reainder we get after dividing total sec by 60
    min = seconds / 60; // and min is the quotient of the above division
    hr = min/60; //similarlly we get hour by dividing min by 60
    min = min%60; // and min is the remainder of the above division
    cout<<hr<<\"hours: \"<<min<<\"minutes: \"<<sec<<\"seconds\ \"; //print
    return 0;
}

 Write a program that accepts an angle, x, in degrees and then calculates the value of sin(x) and outputs it to the screen. Example input: x = 30, sin(30) = 0.5

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site