Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: How to graph the following code. I got the code but not the graph. ty for your time!

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How to graph the following code. I got the code but not the graph. ty for your time!

    hey guys I understand the programming before the graph but i just cant figure how to graph it like the code all through command lone by the way...

    Thanks for your help!

    import java.util.*;
    import java.text.*;
    public class Proj3 {
    public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    DecimalFormat df = new DecimalFormat("0.00");
    System.out.print("Enter x1: ");
    double x1 = Double.parseDouble(s.nextLine());
    System.out.print("Enter y1: ");
    double y1 = Double.parseDouble(s.nextLine());
    System.out.print("Enter x2: ");
    double x2 = Double.parseDouble(s.nextLine());
    System.out.print("Enter y2: ");
    double y2 = Double.parseDouble(s.nextLine());
    double m = (y2-y1)/(x2-x1);
    double b = y1 - m*x1;
    System.out.println("y = " + df.format(m) + "x + " + df.format(b));
    }
    }
    Last edited by neontiger; February 10th, 2012 at 09:39 PM.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How to graph the following code. I got the code but not the graph. ty for your ti

    how to graph it
    Please explain what you mean by "graph it". Do you want to draw on a GUI or print characters on the console?

    Edit your post and wrap your code with[code=java]<YOUR CODE HERE>[/code] to get highlighting

Similar Threads

  1. problem in my code java code graph editeur
    By kisokiso in forum Java Theory & Questions
    Replies: 5
    Last Post: January 6th, 2012, 08:36 AM
  2. Scaling a graph in console
    By mysticCHEEZE in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 8th, 2011, 03:31 PM
  3. Java Bar graph takes user input to create graph?
    By kenjiro310 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 31st, 2011, 07:37 AM
  4. How to make a graph like this
    By sugarhigh in forum AWT / Java Swing
    Replies: 1
    Last Post: August 27th, 2010, 09:05 AM
  5. Replies: 1
    Last Post: October 7th, 2008, 07:35 AM