daniel_lawson9999

Daniel Lawson Quadrant Problem

Apr 18th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.13 KB | None | 0 0
  1. /**
  2.  * Created by Daniel on 4/18/2016.
  3.  */
  4.  
  5. import java.util.*;
  6. import java.awt.*;
  7. public class quadrantFinder {
  8.     public static void main(String[] args){
  9.         Scanner c = new Scanner(System.in);
  10.         System.out.println("What are your two coordinates?");
  11.         System.out.print("x?");
  12.         double x = c.nextDouble();
  13.         System.out.print("y?");
  14.         double y = c.nextDouble();
  15.         calc(x,y);
  16.         System.out.println("Would you like to graph your point?");//pseudo code does not cover bonus
  17.         String answer = c.next();
  18.         if(answer.equals("yes") || answer.equals("yeah") || answer.equals("sure") || answer.equals("yea") || answer.equals("ok") || answer.equals("okay") || answer.equals("Yes")){//check
  19.             DrawingPanel panel = new DrawingPanel(200,200);
  20.             Graphics g = panel.getGraphics();
  21.             g.drawLine(100,0,100,200);
  22.             g.drawLine(0,100,200,100);
  23.             g.setColor(Color.BLUE);
  24.             g.setFont(new Font("Monospaced",Font.PLAIN,8));
  25.             int j = -100;
  26.             for(int i = 0; i < 3;i++){
  27.                 String js = "" +j;
  28.                 g.drawString(js,15+ 80*i,110);
  29.                 j+=100;
  30.             }
  31.             j = 100;
  32.             for(int i = 0; i < 2;i++){
  33.                 String js = "" +j;
  34.                 g.drawString(js,105,10+ 180*i);
  35.                 j-=200;
  36.             }
  37.             g.setColor(Color.RED);
  38.             g.fillRect(100 + (int)x , (int)y*-1 +100,2,2);
  39.         }
  40.  
  41.     }
  42.  
  43.     public static void calc(double x, double y) {
  44.         int q;
  45.         if (x > 0 && y > 0) {
  46.             System.out.println("The point is in quadrant one");
  47.         } else if (x < 0 && y < 0) {
  48.             System.out.println("The point in in quadrant three");
  49.         } else if (x < 0 && y > 0) {
  50.             System.out.println("The point in in quadrant two");
  51.         } else if (x > 0 && y < 0) {
  52.             System.out.println("The point in in quadrant four");
  53.         } else {
  54.             System.out.println("Point is not in a certain quadrant");
  55.         }
  56.  
  57.     }
  58.     public static void graph(double x, double y){
  59.  
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment