Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Daniel on 4/18/2016.
- */
- import java.util.*;
- import java.awt.*;
- public class quadrantFinder {
- public static void main(String[] args){
- Scanner c = new Scanner(System.in);
- System.out.println("What are your two coordinates?");
- System.out.print("x?");
- double x = c.nextDouble();
- System.out.print("y?");
- double y = c.nextDouble();
- calc(x,y);
- System.out.println("Would you like to graph your point?");//pseudo code does not cover bonus
- String answer = c.next();
- if(answer.equals("yes") || answer.equals("yeah") || answer.equals("sure") || answer.equals("yea") || answer.equals("ok") || answer.equals("okay") || answer.equals("Yes")){//check
- DrawingPanel panel = new DrawingPanel(200,200);
- Graphics g = panel.getGraphics();
- g.drawLine(100,0,100,200);
- g.drawLine(0,100,200,100);
- g.setColor(Color.BLUE);
- g.setFont(new Font("Monospaced",Font.PLAIN,8));
- int j = -100;
- for(int i = 0; i < 3;i++){
- String js = "" +j;
- g.drawString(js,15+ 80*i,110);
- j+=100;
- }
- j = 100;
- for(int i = 0; i < 2;i++){
- String js = "" +j;
- g.drawString(js,105,10+ 180*i);
- j-=200;
- }
- g.setColor(Color.RED);
- g.fillRect(100 + (int)x , (int)y*-1 +100,2,2);
- }
- }
- public static void calc(double x, double y) {
- int q;
- if (x > 0 && y > 0) {
- System.out.println("The point is in quadrant one");
- } else if (x < 0 && y < 0) {
- System.out.println("The point in in quadrant three");
- } else if (x < 0 && y > 0) {
- System.out.println("The point in in quadrant two");
- } else if (x > 0 && y < 0) {
- System.out.println("The point in in quadrant four");
- } else {
- System.out.println("Point is not in a certain quadrant");
- }
- }
- public static void graph(double x, double y){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment