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.
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.
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
Code java:
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);
}
}
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.