It is currently Thu Mar 11, 2010 10:49 am


All times are UTC [ DST ]


Ask on Codemiles community and get answers Free and Fast :

Java is a high level programming language .Here ask your java questions ,and get answers free. Read java articles.

Our guest share with us your code snippets , your programming problems , your open source projects ,read articles and post yours .



Registration to Codemiles.com is FAST and FREE. Join Now!





Post new topic Reply to topic  [ 1 post ] 
  Print view Previous topic | Next topic 
Author Message
 Post subject: java loop at end of code ... soooo close i hope
PostPosted: Fri Feb 05, 2010 1:23 am 
Offline
Newbie
User avatar

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;
   
      x= a + i * dx;
      y= x*x*x;
      max=y;
      min=y;
      
      for(i=0; i<=n; i++)
      {
         x= a + i * dx;
         y= x*x*x;
            if(y>max)
            {
               max=y;
               }
               else if(y<min)
               {
               min=y;
            }
            
            
      }
      sf = 120/(max - min);
      System.out.println(dx);
      System.out.println(max);
      System.out.println(min);
      
      for(i=0; i>n; i++)
      {
         x = a + i * dx;
         y = x*x*x;
         nSpaces = (int) ((y - min) * sf);

/**************
i think this is where things go wrong
**************/

         int j = 0;
         if(j<nSpaces)
         {
            System.out.print(" ");
         }
         else if(j>=nSpaces)
         {
            System.out.println("*");
         }
      }
      
   }   
}




TOP
 Profile Send private message  
 
| More
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 


 Similar topics
 Topic title   Forum   Author   Replies 
 How to create a file in java script using FireFox  Scripting Language  danyrouss  0
 need a java program from system to mobile  Java  sudhar  0
 Need help getting started on a small java game?  Java  xmortumx  1
 here how to increase java heap size  Java  msi_333  6
 Java Chess  Finished Projects  msi_333  7

All times are UTC [ DST ]


Who is online

Users browsing this forum: Yahoo [Bot] and 6 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

Jump to:  









Home
General Talks
Finished Projects
Code Library
Games
Tutorials
Programming help
Java
C/C++
C-sharp
Web Development
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
SEO
Google SEO
Others
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2009
mileX v1.0 designed by codemiles team