java - solving all y values for equations of the format y = mx+c -
i creating program in enter equation in format of y = mx+c
it give y values -2 +2.
an example of user may enter y = 2x+5.
how solve this? want input integer values x don't know or how start.
if want input integers value of x can use following method below... method allows chose value of gradient , y-intercept.
you use method:
public static void rangecalculator(int startpoint, int endpoint){ scanner input = new scanner(system.in); system.out.print("enter gradient:"); double gradient = input.nextdouble(); system.out.print("\nenter intercept:"); double intercept = input.nextdouble(); for(int i=startpoint; i<=endpoint; i++){ system.out.println("y="+gradient+"x + " +intercept+"\t" + "input:"+i + " output:" + (gradient*i + intercept)); } }
Comments
Post a Comment