Desperate Help!!!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Desperate Help!!!

  1. #1
    Join Date
    Oct 2002
    Posts
    15

    Desperate Help!!!

    I AM DESPERATELY NEEDING HELP ON THIS PROGRAM, IT IS DUE TODAY BY MIDNIGHT 12/28.... IF ANY ONE COULD HELP ME I WOULD BE VERY THANKFUL!...... THANK YOU

    -----------------------------------
    Assignment 6
    Due November 28th, 2002.

    Goal: More practice with control structures and math computations.

    Description: You will be writing a program to to find approximate value of
    the transcendental number 'e'. This number is expressed as an infinite sum
    of the type:

    1/1! + 1/2! + 1/3! + 1/4! + .... + 1/n!+...and so on. This is an infinite sum.

    Your program finds the sum of first few finitely many terms. The number of
    terms in your sum is to be obtained from the user. Your program should ask
    the use for the precision with which the user wants the value of 'e' to be
    computed. Your proigram should print the sum of those many terms! For your
    information, the value of e lies in between 2 and 3, and is taken to be equal
    to 2.7831, which is correct upto 4 decimal places.


    Here's a sample run of the program:



    enter the desired precision for e: 126
    value of e to using precision 12 is 2.71828
    normal termination!

    enter the desired precision for e: 2
    value of e to using precision 2 is 2.5
    normal termination!

    enter the desired precision for e: 3
    value of e to using precision 3 is 2.66667
    normal termination!

    enter the desired precision for e: 6
    value of e to using precision 6 is 2.71806
    normal termination!

    enter the desired precision for e: 8
    value of e to using precision 8 is 2.71828
    normal termination!


    Instructions:

    Your program should use at least 3 methods,
    Your program should not use the for statement,
    Your program should not use math library functions from java.math or java.lang

  2. #2
    Join Date
    Sep 2002
    Posts
    78
    post what code you have so far and ask specific questions concerning what you can't do or dont understand, then someone may help you.
    not trying to be mean but other people have lives too and they can't write a program for you every week.
    ¿Red Baron?
    [code] /* dont forget code tags! */ [/code]
    Come visit the Café!

  3. #3
    Join Date
    Oct 2002
    Posts
    15

    I just need help with a method

    Hi i finished my program . but i need to incorporate a third method,, because the program needs 2 other methods other than Main... i was thinking i could just make a method to print out the value?? but i cannot figure out how..... if anyone could help,, please reply... thank you!


    /*
    import java.io.*;

    public class CalculatingE
    {
    public static void main (String[] args) throws IOException
    {
    int n, x = 0;
    double answer = 1, i;

    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
    System.out.println("enter the desired value for E >");
    n = Integer.parseInt(input.readLine());
    i = n;



    while (x < n)
    {
    answer = answer + (1 / CalculatingE.computefact(i));
    i = i - 1;
    x = x + 1;
    }
    System.out.println(answer);
    }

    public static double computefact (double a)
    {
    double fact;
    if ((a == 1) || (a == 0))
    {
    fact = 1.0;
    }
    else
    {
    int i = 0; fact = 1;
    while (i < a)
    {
    fact = fact * (a-i);
    i = i + 1;
    }
    }
    return (fact);

    }
    }
    */

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center