programming question @@?

2009-07-01 9:25 am
Write a program that takes the x-y coordinates of a point in the Cartesian plane and prints a message telling either an axis on which the point lies or the quadrant in which it is found.

Sample lines of output:
(-1.5,-2.7) is in quadrant 3.
(0.0,3.8) is on the Y-axis.
(0.0,0.0) is on the origin.


can anyone explain to me how to do this question?? i don understand what does the question want, so i don know how to write the code.


thanks =)

回答 (6)

2009-07-01 9:36 am
✔ 最佳答案
It's asking you to tell where on a cartesian graph a particular point would fall. You can tell this by what is negative and positive inside the point.


(+,+) quadrant one
(-,+)quadrant two
(-,-) quadrant three
(+,-)quadrant four

Using that information, you should be able to come up with an if-else type filter that can tell which quadrant a point is in, or whether it falls on an axis or the origin. Good luck!
2009-07-01 10:09 am
I'm guessing it's a basic input/output program? It sounds like they want to take user input, and based on that user input, determine what quadrant of axis it's on.

I don't know what language you're using, but I'm going to approach this in the language I know, which is c++.

Set it up to take in user data. Maybe prompt the user to put in two numbers for a coordinate system. Set up a series of if/else statements.

Here's a possible example to determine a quadrant (pseudocode, don't try to plug this into a program):

Using variables VarX, and VarY:

If(VarX > 0 && VarY > 0)
cout << "Point is in quandrant 1";

If(VarX > 0 && VarY < 0)
cout << "Point is in quandrant 4";

If(VarX < 0 && VarY > 0)
cout << "Point is in quandrant 2";

If(VarX < 0 && VarY < 0)
cout << "Point is in quandrant 3";


Or something to that effect. The question you were given is kind of vague, and it would help to know where you are in your curriculum and lesson to put things into better perspective. I hope that gives you an idea on how to write your program and helps you understand your project better.
2009-07-01 10:08 am
return x==0&&y==0 ? "is on the origin." :
x==0 ? "is on the X-axis." :
y==0 ? "is on the Y-axis." :
x>0&&y>0 ? "is in quadrant 1." :
x>0&&y<0 ? "is in quadrant 2." :
y<0 ? "is in quadrant 3." :
"is in quadrant 4.";
2009-07-01 9:36 am
include<stdio.h>
{
/* thoppi thoppi */
}
run this program it'll execute ........
2009-07-01 9:32 am
We're not going to do your homework for you, sorry.


收錄日期: 2021-04-25 13:28:16
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090701012526AAjjPQE

檢視 Wayback Machine 備份