• November 4th, 2013, 08:01 AM
Joud Mahayni
In an orthogonal system, given a point, a line from that point to the origin forms an angle with the positive x-axis. The line is said to terminate, either in one of the four quadrants or to coincide with the positive x-axis, positive y-axis, negative x-axis, or negative y-axis.

Write a java program that prompts the user for a given angle and determines the location of the line, whether it is in one of the four quadrants or it lies on the positive x-axis, positive y-axis, negative x-axis or negative y-axis. For example, if the input angle is 90°, then the line lies on the positive y-axis. If the angle is -30°, then the line lies in the fourth quadrant and so forth. Your program must be able to handle angles of any values, such as -783.87.
• November 4th, 2013, 08:43 AM
Norm
• November 4th, 2013, 09:03 AM
Joud Mahayni
Quote:

Originally Posted by Norm

i am still a beginner in java
i cant think of a way to begin
scanner scan= new scanner (system.in);
i am visualizing the code
but i cant write it
i need to figure out a way to to put in if the multiples of (0,90 180 and 360)
we can use switch but i dont know how
thank u
• November 4th, 2013, 09:19 AM
Norm
Quote:

i am visualizing the code
Use a piece of paper to write down your raw thoughts about how to solve the problem. Then refine the thoughts into a design. When you have a design, the start writing the code. Code and test the code in small steps. Use println statements to print out results to check if the code is doing what you want.
If you get errors, copy the full text and paste it here.
• November 4th, 2013, 09:30 AM
Joud Mahayni
import java.util.Scanner;
public class Angle
{
public static void main(String []args)
{
double a;
Scanner scan=new Scanner (System.in);
system.out.println("Enter the value for an angle");
a=scan.nextDouble();
if(a>0 && a<90)
system.out.println("The line is located in quadrant 1")
else
if (a==0)
System.out.println("The line is located on positive x-axis")
.
.
.
.
.
.
.
.
.
If i continue in this manner i will finish in a couple of years
how can i condense my code
• November 4th, 2013, 09:35 AM
Norm
Quote:

how can i condense my code
I don't see where the code could be condensed.
What happens when you compile and execute the code?
If there are error messages, copy the full text and paste it here.

[code=java]
[/code]
to get highlighting and preserve formatting.
• November 4th, 2013, 10:09 AM
Joud Mahayni
import java.util.Scanner;
public class Angle {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
double a;
Scanner scan=new Scanner (System.in);
System.out.println("Enter a value for an angle");
a=scan.nextDouble();
if (a>0 && a<90)
System.out.println("The line is located in Quardrant I");
else
if (a>90 && a<180)
System.out.println("The line os located in Quadrant II");
else
if (a>180 && a<270)
System.out.println("The line is located in Quadrant III");
else
if (a>270 && a<360)
System.out.println("The line is located in Quadrant IV");

else
if (a==0)
System.out.println("The line lies on the positive x-axis");
else
if (a==90)
System.out.println("The line lies on the positive y-axis");
else
if (a==180)
System.out.println("The line lies on the negative x-axis");
else
if (a==270)
System.out.println("The line lies on the negative y-axis");

how can i put in the negative value....
ALMOST DONE
• November 4th, 2013, 10:21 AM
Norm