Web Analytics Made Easy -
StatCounter C++ programming exercise. Need help. - CodingForum


No announcement yet.

C++ programming exercise. Need help.

  • Filter
  • Time
  • Show
Clear All
new posts

  • C++ programming exercise. Need help.

    Hey guys, I'm new here, and am new to computer programming. I'm in my first C++ class, and our teacher gave us this exercise. It seems a bit ahead of where we are currently in our studies, and I'm completely lost as to how to even get started. I understand that you cannot give answers to homework questions, but I thought maybe I could possibly get enough good help/support here to at least get me going in the right direction. This is more of an exercise than an assignment, but I suppose you have to treat all things like assignments. I'll provide the full instructions below and then perhaps we can discuss it:

    Develop an algorithm that will take an angle,
    measured in degrees, between ¬90° and +90° ( ¬90 <
    x < 90 ) and calculate the sin, cos and tan of the
    angle, and implement the algorithm in C++.
    Your program should validate the input for the
    angle, making sure it falls within the given range
    and notifying the user if it does not. Your angle
    and sin, cos, tan and all numbers should be doubles.
    The output should be formatted this way:
    Following the input, there should be a line of 40
    asterisks then a table of outputs, then another line
    of 40 asterisks, with blank lines between the
    asterisks and outputs:
    ^Angle sin cos tan
    The headings "Angle, sin," etc. are right justified
    over their columns. The angle is typed out with two
    decimal places. The sine, cosine & tangent have 4
    decimal places and are right justified under their
    column headings. There are 3 spaces between the
    fields for each number. (If the outputs are too big
    or too small to fit in this format, don't worry
    about that.)
    For example, if the angle was ¬65.5°, the output
    would be:
    Angle sin cos tan
    ¬65.50 ¬0.9100 0.4147 ¬2.1943
    Note that C++ expects angles to be given in radians.
    Your algorithm will need to convert that inputted
    angle from degrees to radians for the calculations.
    For full credit you need to use a "constant
    variable" for the value of pi &/or the value of the
    conversion factor between degrees and radians.

    I appreciate any and all help. Whether or not I get it right, I have to turn something in tonight.


  • #2
    This is an exercise in including header files, getting user input, verifying it (get user to re-submit if it does not comply with the rules) and outputting processed values based on that input.

    It does not require anything advanced, just basic input output (standard input / output) and maybe some extra maths functions.

    You will have been taught what you need to know.


    • #3
      this isn't hard, just use what you already learned. use your textbook to assist.

      use cin function to get angle.
      then output the calculation using c++ math sin function. be sure to include necessary header
      have a if condition to check if angle is valid in between.

      just take the problem one step at a time at a time. hopefully, this will point you int he right direction without giving too much away.