Results 1 to 5 of 5
Thread: diving distance program
- 04-05-2012, 03:09 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 13
- Rep Power
- 0
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; } } } }
- 04-05-2012, 06:27 AM #2
- 04-05-2012, 06:29 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 13
- Rep Power
- 0
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
- 04-05-2012, 08:00 PM #4
Re: diving distance program
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)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-05-2012, 08:09 PM #5
Member
- Join Date
- Apr 2012
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
Diving into Java Web Services from .NET world
By mhalabi in forum New To JavaReplies: 0Last Post: 02-12-2012, 07:59 PM -
Distance Between Two Points
By HSKrustofsky in forum New To JavaReplies: 6Last Post: 09-08-2011, 06:23 AM -
Set distance from border to component
By Josep_16 in forum AWT / SwingReplies: 1Last Post: 08-22-2011, 12:21 AM -
need some advice before diving into struts 2
By kulangotski in forum Web FrameworksReplies: 8Last Post: 04-26-2011, 04:52 AM -
What Method and loops to get the distance
By sirdonclemo in forum New To JavaReplies: 2Last Post: 09-05-2010, 03:21 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks