Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Pls I need help on these questions that are making me go crazy

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Angry Pls I need help on these questions that are making me go crazy

    1. Write a program in Java that takes as input two integers from the command-line, and
    outputs true if they are divisible either by 7 or by 11, and outputs false otherwise.

    2. Write a program in Java that takes as input a positive integer n from the command-line,
    and outputs all the powers of 3 that are less than or equal to n. State the limitations, if
    any, of your program.

    and

    3. Write a program in Java that computes the trigonometric function sin(x) given by the
    series
    sin(x) = x x3/3! + x5/5! x7/7! + .
    The program should take as input a number from the command-line, and output the sine
    value of that number.


  2. #2
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,104
    Thanks
    169
    Thanked 780 Times in 726 Posts
    Blog Entries
    5

    Default Re: Pls I need help on these questions that are making me go crazy

    Welcome to the forums. While we would like to help, simply posting a homework assignment is what we call a 'homework dump', and makes it look as if you are asking someone to do this for you - which is not what we are going to do. If you wish to make full use of the forums, I recommend posting what you have tried, and asking a specific question. I also recommend reading the forum rules - I have had to move your post to a more appropiate forum because of this.

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Pls I need help on these questions that are making me go crazy

    Now I've got these codes for my number 3 but can I get someone to help me correct the error in my codes pls?
    Here they are

    import java.util.Scanner;
    import java.Math;
    public class trig
    {
    Scanner input = new Scanner(System.in);
    public static void main(String[] args)
    {
    int angle, sineangle;
    System.out.println("Enter the angle you wish to convert");
    angle = input.nextInt();
    sineangle = Math.sin(Math.toRadians(angle));
    System.out.print("The sine is " + sineangle);
    }
    }
    Last edited by helloworld922; September 27th, 2012 at 03:01 AM. Reason: please use [code] tags

  4. #4
    Super Moderator pbrockway2's Avatar
    Join Date
    Jan 2012
    Posts
    939
    Thanks
    6
    Thanked 202 Times in 178 Posts

    Default Re: Pls I need help on these questions that are making me go crazy

    What's wrong with the code?

    Specifically, does it compile? If not, and you can't understand the compiler's messages, post them

    Or does it compile but do something unintended when you run it? In that case describe the actual program behaviour.

    ---

    [Edit] Also I think you may have misinterpreted the question. You aren't supposed to use the Math.sin() method, but rather you should use the series provided. Ie add up a whole bunch of terms in 1-x^3/3!+x^5/5!-... to get the sine.
    Last edited by pbrockway2; September 27th, 2012 at 02:30 AM.

Similar Threads

  1. Going crazy
    By rmedford in forum Object Oriented Programming
    Replies: 2
    Last Post: September 15th, 2012, 02:39 PM
  2. its crazy
    By chonch in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 17th, 2011, 02:26 PM
  3. Very basic program but its making me crazy
    By craig carl in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 2nd, 2011, 02:16 PM
  4. Crazy array
    By javapenguin in forum What's Wrong With My Code?
    Replies: 18
    Last Post: June 26th, 2010, 03:02 AM
  5. [SOLVED] NullPointerException in Poker's program
    By dean_martin in forum Exceptions
    Replies: 10
    Last Post: April 21st, 2009, 06:40 AM