Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-26-2007, 08:33 PM
Yaglana Yaglana is offline
Newbie
 
Join Date: Apr 2007
Posts: 1
Rep Power: 0
Yaglana is on a distinguished road
Default Having a problem with a relatively easy problem...

I'm not sure how I should ask questions about this program, so if this thread frustrates you do to the load of text, I'm sorry >.> Just tell me how to do it. I read the FAQ and it didn't really say anything...

Well, basically, I am in a basic Computer Science class, and we're working on just learning the basics of tokenizing/arrays/etc. I have completed every project with nearly no complications at all except for one. This one project is becoming extremely frustrating because I'm having a hard time comprehending it...


Here is the link to the assignment:

http://www.ecs.csun.edu/~cov/comp110.../project05.pdf


I thought I had it down correctly, but when I "finished" it, everything was completely wrong. Here is what I have so far:


PHP Code:
import java.util.*;

public class 
PolyAreaThree
{

    public static 
void main(String [] args)
    {
        
Scanner scan = new Scanner(System.in);        
        
System.out.print ("Degree of polynomial: ");
        
int n scan.nextInt();
        
        
double w[] = new double[n+1];
            
        while(
>= 0)
        {
            
System.out.print("Enter coefficient " ": ");
            
w[n] = scan.nextDouble();
            
n--;
        }
        
        
System.out.print("Enter starting value: ");
        
double a scan.nextDouble();
        
        
System.out.print ("Enter stopping value: ");
        
double b scan.nextDouble();
        
        
System.out.print("Enter number of steps: ");
        
int nsteps scan.nextInt();
        
        
        
double y[] = evalintegral(w);
        
double first evalarea(yabnsteps);
        
        
//double second = evalarea(y, a, b, nsteps);
        
                
        //System.out.println(y);
            
    
}


    public static 
double evalpoly(double[] cdouble x)
         {
                
int n c.length 1;
                
double r c[n];
                
int i n;
                
                    while (
i>0)
                    {
                        
r*c[i-1];
                        
i--;
                    }
                    
                    return 
r;
        }
        
             
 
    public static 
double evalarea(double[] cdouble adouble bint nsteps)
        {
            
double area 0;
            
double x a;
            
int steps 0;
            
int sMult 0;
            
double s = (a) / nsteps;
            
            while(
steps nsteps)
            {
                
double h evalpoly(ca);
                
area + (sMult);
                
                
//System.out.println("x = " + x + "; f(x) = " + h);
                
s;
                
steps++;
                
sMult++;
            }
            
            
area area s;
            
            return 
area;
            
        }
        
        public static 
double[] evalintegral(double[] c)
        {
            
//create and return a new array of coefficients
                
int n c.length 1;
                
int m n+1// degree of g is m
                
double[] = new double[m+1]; // coeffs for g(x) stored in d[]
                
int im;
                while (
i>0)
                {
                    
d[i] = (c[i-1] / i);
                    
System.out.println(d[i]); // d[i] is c[i-1] / i
                    
i--; // decrement i by 1
                
}
                
d[0] = 0// constant term is 0
                
                
return d;
        }
    
    } 



Any suggestions?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Peculiar UI Problem Needs Tackling adriyel C# Programming 2 04-06-2008 08:46 AM
i have a problem please help me!!!???? stack Java Help 8 09-22-2007 04:17 PM
[C] Comparison problem Alhazred C and C++ 1 08-29-2007 05:58 AM
Connectionstring Problem mohamedsaleh70@hotmail.co Visual Basic Programming 3 04-15-2007 12:57 PM
A small problem in the output The_Master C and C++ 3 12-13-2006 01:04 PM


All times are GMT -5. The time now is 12:11 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads