Post subject: java loop at end of code ... soooo close i hope
Posted: Fri Feb 05, 2010 1:23 am
Joined: Fri Feb 05, 2010 1:16 am Posts: 1 Has thanked: 0 time Have thanks: 0 time
++++++here is the assignment:
Program 1 Assigned: (Out of class program assignment due 1 lab after next: 2/8 -001, 2/3 -002, 2/5 -003) Create a simple plotter (x-axis runs vertically, y -axis runs horizontally) using command line arguments for a (left end point), b (right end point), and n (number of sub-intervals of [a, b].) Plot.pdf Steps:
compute maximum and minimum values of the function on [a, b]. compute scaling factor sf. For example, does the following accomplish all we need? sf = graphPageWidth/(max - min). construct for each point in the interval the required number of spaces (one for each column) preceding the plot (an *) #cols = sf ( f(a +idx) - min ). Points breakdown 0 - doesn't compile 20 - Input and output a, b, & n 40 - Calculate and print dx 60 - Find and print the max & min on [a, b] 80 - Find and print the scale factor 100 - Plot the function x3 on [a,b] in one program and 1 - x2 on [-1, 1] in another. You will be required to demonstrate your program using a test function provided in class on the date delivery is due. Sample output: a, b, c, d. 110 - Plot with x-axis running horizontally and y-axis running vertically
++++++here is a link to the flow chart with the problem area circled: http://img222.imageshack.us/img222/1374/javaloop.png
++++++here is my code:
Code:
public class ProjectOneTwo {
public static void main(String[] args) { double a = Double.parseDouble(args[0]); double b = Double.parseDouble(args[1]); int n = Integer.parseInt(args[2]); System.out.println(" "+args[0]+" "+args[1]+" "+args[2]);
double dx = (b-a)/n; double x, sf, y; double max; double min; double nSpaces; int i = 0;
Users browsing this forum: Ask Jeeves [Bot] and 4 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum