Advertisement
Guest User

Line graphing program

a guest
Feb 14th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.82 KB | None | 0 0
  1. // ROWS 9
  2. // COLUMNS 9
  3.  
  4. import java.util.*;
  5. import java.text.*;
  6.  
  7. public class Proj3 {
  8.  
  9. public static void main(String[] args) {
  10. Scanner input = new Scanner(System.in);
  11.  
  12.  
  13.  
  14. System.out.print("Enter x1:   ");
  15. double x1 = input.nextInt();
  16. System.out.print("Enter y1:   ");
  17. double y1 = input.nextInt();
  18. System.out.print("Enter x2:   ");
  19. double x2 = input.nextInt();
  20. System.out.print("Enter y2:   ");
  21. double y2 = input.nextInt();
  22. double slope = (y2-y1) / (x2-x1);
  23. double intercept = y1-slope*x1;
  24. System.out.printf("y = " + "%.2f" + "x" + " + " + "%.2f\n", slope,intercept    );
  25. System.out.println();
  26. int i;
  27. int j;
  28.  
  29. for (i=9; i>=0; i--) {
  30. for (j=13; j>=0; j--) {
  31. if (j==i+4) {
  32. System.out.print(j-4);
  33. }
  34.  
  35. }
  36.  
  37.  
  38. System.out.println();
  39.  
  40. }
  41.  
  42. }
  43.  
  44.  
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement