Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Method for a table for calculation - help!

  1. #1
    Junior Member
    Join Date
    Oct 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Method for a table for calculation - help!

    I am making a calculator for divers as an assignment for school, for one of the calculations I am meant to make a table which should look similar to the following.

    Which calcuation do you wish to perform (Help/MOD/SMOD/BM/PP/PPT/EAD/EADT)? EADT
    Generating Equivalent Air Depths Table
    Enter a start and end percentage of Oxygen: 21 25
    Enter a start and end depth (in metres): 3 31
    Equivalent Air Depth Table for 21 to 25 percent Oxygen and depths of 3 to 31 metres
    ================================================== =================================
    n 21 22 23 24 25
    3 3 3 3 3 2
    6 6 6 6 5 5
    9 9 9 9 8 8
    12 12 12 11 11 11
    15 15 15 14 14 14
    18 18 18 17 17 17
    21 21 21 20 20 19
    24 24 24 23 23 22
    27 27 27 26 26 25
    30 30 29 29 28 28

    So the user will input two numbers for percentage and two for depth which will make up this table and the insides will be created by the equation (i'm assuming) and i can't figure out how to make this. what i've come up with so far is:

    public static double printEADT() {
            double eadt;
            Scanner scan = new Scanner (System.in);
            System.out.println("Generating Equivalent Air Depths Table");
            System.out.println("Enter a start and end percentage of Oxygen: ");
            double startpercentage = scan.nextDouble();
            double endpercentage = scan.nextDouble();
            System.out.println("Enter a start and end depth (in metres): ");
            double startdepth = scan.nextDouble();
            double enddepth = scan.nextDouble();
            eadt = ((1-(1.4/startdepth)*100)*((startpercentage/100)*((startdepth/10)+1))/0.79);
            System.out.println("Equivalent Air Depth Table for " + startpercentage + " to " + endpercentage + " percent Oxygen and depths of " + startdepth + " to " + enddepth + " metres");
            do {
                System.out.print("\t" + startpercentage);
                startpercentage+=1;
                startdepth+=1;
            } while (startpercentage <= endpercentage);
            System.out.println("");
            do {
                System.out.println(startdepth + "\n");
                startdepth+=1;
            } while (startdepth <= enddepth);
            return eadt;
        }

    it makes the first line but not the second and i'm not sure why.
    i've attached the entire file if you want to see all the code.

    please please help i'm desperate.
    Attached Files Attached Files


  2. #2
    Member
    Join Date
    Oct 2011
    Posts
    36
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: Method for a table for calculation - help!

    As I know, to print such table in the screen, you need nested do-while loops,such as
    do{
    do{
    }while();
    }while();

Similar Threads

  1. final calculation after if statment
    By spongyballs in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 23rd, 2011, 01:47 PM
  2. Shape Calculation Program
    By TH1 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 29th, 2011, 03:54 PM
  3. I need calculation
    By Swiss518 in forum Loops & Control Statements
    Replies: 7
    Last Post: January 27th, 2011, 01:26 PM
  4. RPM Calculation
    By fobos3 in forum Algorithms & Recursion
    Replies: 2
    Last Post: September 21st, 2010, 08:53 AM
  5. SQL Time Calculation
    By r12ki in forum JDBC & Databases
    Replies: 3
    Last Post: July 31st, 2009, 03:54 AM