Results 1 to 5 of 5
  1. #1
    maximumammo is offline Banned
    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    Default diving distance program

    Ok so I had to write a program that displays increase in pressure per every 100 meters up to X meters based on the density of the water as we go down. X is the diving distance that needs to be read from the keyboard. Pressure increase rate per 100 meters for various water densities are given below
    Level 1 : 20 per 100 meters
    Level 2 : 30 per 100 meters
    Level 3 : 50 per 100 meters

    it should look like this :

    Please enter the density level : 1
    Please enter the diving distance X (in meters): 300

    Pressure increase after 100 meters : 20
    Pressure increase after 200 meters : 40
    Pressure increase after 300 meters : 60



    PROBLEM::::: Ok so this is probably a simple question but how do I get pI(pressure increase) to change with the depth? i.e at 100 m pI is 20, at 200 m pI is 40




    Java Code:
    import java.util.Scanner;
    public class Lab8 {
    	
    public static void main(String[] args)
    {
    	
    Scanner scan = new Scanner(System.in);
    
    
    int densityLevel;
    double divingDistance, pI = 0;
    
    System.out.println("Welcome");
    
    System.out.println(" Please enter the density level :");
    densityLevel = scan.nextInt();
    
    
    System.out.println("Please enter the diving distance X (in meters) : ");
    divingDistance = scan.nextDouble();
    
    
    
    
    int count = 100;
    while (count <= divingDistance)
    {
    
    	
    
    
     if ( densityLevel ==1 ) {
    	pI = 20;
     
     System.out.println(" Density Level : " + densityLevel);
     System.out.println(" Diving Distance : " + divingDistance);
     System.out.println( " Preassure increase after " + count + " meters is " + pI);
     count += 100;
     
    	 
    }
    
    
    
    
    else if (densityLevel ==2) 	{
    	pI = 40;
    
    	System.out.println(" Density Level : " + densityLevel);
    	 System.out.println(" Diving Distance : " + divingDistance);
    	 System.out.println( " Preassure increase after " + count + " meters is " + pI);
    	 count += 100;
    }
    	
    
    
    else if (densityLevel == 3) {
    	pI = 60;
    
    	System.out.println(" Density Level : " + densityLevel);
    	 System.out.println(" Diving Distance : " + divingDistance);
    	 System.out.println( " Preassure increase after " + count + " meters is " + pI);
    	 count += 100;
    	
    }
    }
    }
    }

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: diving distance program

    Quote Originally Posted by maximumammo View Post
    PROBLEM::::: Ok so this is probably a simple question but how do I get pI(pressure increase) to change with the depth? i.e at 100 m pI is 20, at 200 m pI is 40
    Are you serious? Even a blind person can see the relationship between depth and pressure. What happens to the pressure every 100 metres?

  3. #3
    maximumammo is offline Banned
    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    Default Re: diving distance program

    no sh*t sherlock, I understand how it works, im not using this forum because I have trouble with basic math Im using it because I am new to JAVA. My question, is how do you express that in JAVA terms. Thanks for your helpful reply

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,423
    Rep Power
    20

    Default Re: diving distance program

    Quote Originally Posted by maximumammo View Post
    My question, is how do you express that in JAVA terms.
    First off, the word is Java, not JAVA. It's not an acronym.

    Check out the tutorial on Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    maximumammo is offline Banned
    Join Date
    Apr 2012
    Posts
    13
    Rep Power
    0

    Default Re: diving distance program

    Quote Originally Posted by DarrylBurke View Post
    First off, the word is Java, not JAVA. It's not an acronym.

    Check out the tutorial on Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

    db

    Thank you, and I know it is not "JAVA" I was using that for emphasis on the term and understand it is not an acronym. Thanks again and I will check out the link

Similar Threads

  1. Diving into Java Web Services from .NET world
    By mhalabi in forum New To Java
    Replies: 0
    Last Post: 02-12-2012, 07:59 PM
  2. Distance Between Two Points
    By HSKrustofsky in forum New To Java
    Replies: 6
    Last Post: 09-08-2011, 06:23 AM
  3. Set distance from border to component
    By Josep_16 in forum AWT / Swing
    Replies: 1
    Last Post: 08-22-2011, 12:21 AM
  4. need some advice before diving into struts 2
    By kulangotski in forum Web Frameworks
    Replies: 8
    Last Post: 04-26-2011, 04:52 AM
  5. What Method and loops to get the distance
    By sirdonclemo in forum New To Java
    Replies: 2
    Last Post: 09-05-2010, 03:21 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •