Total members 11890 |It is currently Thu Apr 25, 2024 2:04 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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


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) ((- 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("*");
            }
        }
        
    
}    
} 





Author:
Newbie
User avatar Posts: 1
Have thanks: 0 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : compute maximum and minimum values, also scaling factor.
 Get factor of number using C- find a prime factor     -  
 Scaling 2D     -  
 Setting maximum height of paragraph -P tag     -  
 Factor of number using C++ code     -  
 compute area of the circle.     -  
 compute binomial coefficients     -  
 Compute FFT (Fourier Transform) in ITK for a 2d image     -  
 loop to compute the tuition in ten years     -  
 compute number of files in directory     -  
 Program to compute commission using two methods     -  



cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com