basically I have to ask the user to enter two points and then display the equation in point slope form using those points, then I have to code in a graph that displays those points. I have already done and coded the first part which looks like this:
import java.util.*;
import java.text.*;
public class Proj3 {
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
String input;
double xOne = 0;
double yOne = 0;
double xTwo = 0;
double yTwo = 0;
double slope;
DecimalFormat df = new DecimalFormat("#0.00");
System.out.print("Enter x1: ");
input = s.nextLine();
xOne=Double.parseDouble(input);
System.out.print("Enter y1: ");
input = s.nextLine();
yOne=Double.parseDouble(input);
System.out.print("Enter x2: ");
input = s.nextLine();
xTwo=Double.parseDouble(input);
System.out.print("Enter y2: ");
input = s.nextLine();
yTwo=Double.parseDouble(input);
slope=((yTwo-yOne)/(xTwo-xOne));
System.out.println("y = " + (df.format(slope)) + "x + " + (df.format(yOne-slope*xOne)));
for(){
}
}
}
But I don't know how to do the graph part, I'm pretty sure my instructor wants me to use for and if loops but I'm not sure how to go about it. it has to be coded in using simple java code I'm only in my first semester of java.
any help with this would be greatly appreciated thanks, my goal is to get this done tonight.