Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Diving Calculator - Please Help!
 User Name Remember Me? Password

Before you post, read our: Rules & Posting Guidelines

 Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
 10-21-2011, 12:01 PM PM User | #1 terripwilliams New to the CF scene   Join Date: Oct 2011 Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts Diving Calculator - Please Help! I am supposed to be making a program to help divers calculate things. I have made methods to calculate a few different equations (I have only really just started) but i can't figure out how to call them to print the answer and things. here's my code I don't know what i'ev done wrong i've looked up a bunch of different things and this is what i've found but it isn't compiling. Code: ```import java.util.*; public class Program { double percentage; double pressure; double standard = 1.4; double depth; String input; public Program() { Scanner scan = new Scanner (System.in); System.out.println ("Which calculation do you wish to perform (Help/MOD/SMOD/BM/PP/EAD)? "); input = scan.nextLine(); if (input == "mod" || input == "MOD") { System.out.println("Calculating the MOD"); System.out.println("Enter the percentage of Oxygen: "); percentage = scan.nextDouble(); System.out.println("Enter the partial pressure of Oxygen (between 1.1 and 1.6 inclusive): "); pressure = scan.nextDouble(); System.out.println("Maximum Operation Depth for a dive with " + percentage + " with a partial pressure of " + pressure + " is " + printMOD() + " metres."); } else if (input == "smod" || "SMOD") { System.out.println("Calculating the SMOD"); System.out.println("Calculating the MOD for the standard 1.4 partial pressure"); System.out.println("Enter the percentage of Oxygen: "); percentage = scan.nextDouble(); int result = printSMOD(); System.out.println("Maximum Operation Depth for a dive with " + percentage + " with a partial pressure of " + pressure + " is " + result + " metres."); } } public static void printMOD() { int mod; mod = ((pressure/percentage)-1)*10; return mod; } public static void printSMOD (double percentage, double standard) { double smod; smod = ((1.4/percentage)-1)*10; return smod; } public static void printBM (double pressure, int depth) { double bm; bm = (pressure/depth)*100; return bm; } }```
 10-21-2011, 03:19 PM PM User | #2 Fou-Lu God Emperor     Join Date: Sep 2002 Location: Saskatoon, Saskatchewan Posts: 16,606 Thanks: 4 Thanked 2,598 Times in 2,567 Posts Strings cannot be compared like this: `if (input == "mod" || input == "MOD") {`. This (and a similar one further down) must be written as `if (input.equals("mod") || input.equals("MOD")){`.

 Bookmarks

 Tags calculate, calculation, calling, java, methods

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 08:36 PM.

 AdvertisementLog in to turn off these ads.