Thread: Am stuck, need an expert?

  1. #1
    Registered User
    Join Date
    Dec 2019
    Posts
    46

    Am stuck, need an expert?

    Hello,

    I have two assignments and they want you to write code to determine the distance of how far an individual will go with velocity known.

    1)

    Yikes the clown is going to be shot out of a cannon and needs to know where to put the safety net. Your mission is to write a C++ program to help him do this.
    Yikes will enter his velocity in miles per hour, and the cannon angle in degrees. Your program will give him the distance (range) that he travels measured in feet.
    Assume the following:
    R = (v2 / g) sin(2Θ)
    R = distance in feet
    v = velocity in feet per second
    Θ=cannon angle

    2)


    Clown Skateboard


    Given the success of his last stunt, Yikes the Clown is now going to attempt the following. He will ride down a hill on a skateboard and off a ramp at the bottom. He wants to know how fast he will be travelling when he leaves the ramp.
    The formula for this is:
    V=sqrt (2 g (h1 h2))
    V is his velocity at the end of the ramp
    g is acceleration due to gravity (either 9.8 m/s2 or 32 f/s2 depending on if you are using English or Metric).
    h1 is the height of the hill in either meters or feet.
    H2 is the height of the ramp in either meters or feet.
    You may choose which unit of measure to do this assignment in.

    :::::::::



    I am attempting, but I have no idea. None. Professor wasn't much help.



  2. #2
    Registered User
    Join Date
    Dec 2017
    Posts
    928
    Can you do question 1 on a calculator?
    What is the answer if v is 50 miles per hour and theta is 20 degrees?
    If you want the truth to stand clear before you, never be for or against. - Sent-ts'an

  3. #3
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by john.c View Post
    Can you do question 1 on a calculator?
    What is the answer if v is 50 miles per hour and theta is 20 degrees?
    I don't think he wants us to do it that way.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,723
    That's a pretty common approach though: figure out a mathematical formula, then write a program to implement and hence automate it. If that's not the way your professor intends, then what is intended? If you don't know and can't find out because your professor isn't helping, then you have a choice: either do something that works even if it isn't what you think your professor intended (in which case you have a fighting chance of a passing grade), or do nothing at all (and therefore definitely fail).
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by laserlight View Post
    That's a pretty common approach though: figure out a mathematical formula, then write a program to implement and hence automate it. If that's not the way your professor intends, then what is intended? If you don't know and can't find out because your professor isn't helping, then you have a choice: either do something that works even if it isn't what you think your professor intended (in which case you have a fighting chance of a passing grade), or do nothing at all (and therefore definitely fail).
    Ok, do you know how to use putty? I don't have a clue...where to write the code...etc.

    the equation I have is d= v^2/g * sin(2theta)

  6. #6
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by john.c View Post
    Can you do question 1 on a calculator?
    What is the answer if v is 50 miles per hour and theta is 20 degrees?
    Is the answer 190.1mph?

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,723
    Quote Originally Posted by solidusMGS
    Ok, do you know how to use putty?
    Yes.

    Quote Originally Posted by solidusMGS
    I don't have a clue...where to write the code...etc.
    That's something you have to sort out with the professor or other members of the teaching team. The forum members here cannot help you with the specifics beyond "write your code in an editor or IDE".
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by laserlight View Post
    Yes.


    That's something you have to sort out with the professor or other members of the teaching team. The forum members here cannot help you with the specifics beyond "write your code in an editor or IDE".
    Ok, what is x-ming for? I tried to install it and it says error code 5.

  9. #9
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    The X-ming says can't be deleted because x-ming is open on x-ming server..oh boy...

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    27,723
    If you don't know what is it for, why are you trying to install it?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  11. #11
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by laserlight View Post
    If you don't know what is it for, why are you trying to install it?
    I had it in my notes, so I googled it. Am going to go the system restore way now. Sucks.

  12. #12
    Registered User
    Join Date
    Dec 2017
    Posts
    928
    Quote Originally Posted by solidusMGS View Post
    I don't think he wants us to do it that way.
    I'm asking if you even understand the question.
    Last edited by john.c; 01-25-2020 at 02:21 PM.
    If you want the truth to stand clear before you, never be for or against. - Sent-ts'an

  13. #13
    Registered User
    Join Date
    Dec 2017
    Posts
    928
    Quote Originally Posted by solidusMGS View Post
    Is the answer 190.1mph?
    The answer should be in feet, not miles per hour.
    Last edited by john.c; 01-25-2020 at 02:34 PM.
    If you want the truth to stand clear before you, never be for or against. - Sent-ts'an

  14. #14
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by john.c View Post
    I'm asking if you even understand the question.
    No, I don't understand the question.

  15. #15
    Registered User
    Join Date
    Dec 2019
    Posts
    46
    Quote Originally Posted by john.c View Post
    The answer should be in feet, not miles per hour.

    You need to convert the given miles per hour into feet per second.
    You need to convert the angle in degrees to the angle in radians (because the C library sin function takes radians).
    So I think this is correct. The 32 is the acceleration due to gravity (g) in feet per second per second.

    v = 50 miles per hour
    angle = 20 degrees

    fps = v * 5280 / 3600 = 73.333 fps
    rad = angle * pi / 180 = 0.3491 rads
    R = fps * fps / 32 * sin(2 * .3491) = 108.032 feet
    How do I write that in C++? Like this?:

    Code:
    #include<iostream>
    #include<cmath>
    
    constant double g=9.8;
    
    int main()
    
    {
    
    double velocity=12;
    cout<<"Enter a velocity?";
    cin>>velocity;
    
    double v=v*5280/3600
    double rad= theta* m.PI/180

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. i need a c expert..
    By riel in forum C Programming
    Replies: 7
    Last Post: 01-27-2008, 07:19 AM
  2. need some expert help here!
    By magix24 in forum C Programming
    Replies: 1
    Last Post: 04-11-2006, 10:36 PM
  3. the ask an expert is down!?
    By fmchrist in forum C Programming
    Replies: 3
    Last Post: 12-29-2005, 04:19 PM
  4. c++ expert
    By febrian81 in forum C++ Programming
    Replies: 2
    Last Post: 07-01-2002, 10:27 PM

Tags for this Thread