Results 1 to 3 of 3
- 07-16-2011, 08:15 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 18
- Rep Power
- 0
this wont run again and again?? why?
i made a program it runs correctly but it wont repeat as i set a do while loop why?? here is the code
Java Code:import java.util.Scanner; public class main { static String af = "0"; static String bf = "0"; static String ff = "0"; static String mn = "0"; public static void main(String args[]) { do { final double R = 1.0967 * (10000000); double lowest = Double.parseDouble(af); double highest = Double.parseDouble(bf); double answer = Double.parseDouble(ff); Scanner obj = new Scanner(System.in); System.out.println( "Insert the lowest Energy level"); lowest = obj.nextDouble(); System.out.println("Now,Insert Highest Energy level"); highest = obj.nextDouble(); answer = R * (1 / (lowest * lowest) - 1 / (highest * highest)); System.out.println("Wave Length is " + 1 / answer); System.out.println("Do you wish to continue? y ? or n?"); mn = obj.next(); } while (mn == "n"); } }
-
Don't compare Strings with ==. Instead use the equals(...) method.
The reason that this is important is that == checks if one object is the same as another object, and that's not what you care about here. Rather you want to check if one String has the same characters as another String and that's what the equals method does.
- 07-16-2011, 08:30 AM #3
Member
- Join Date
- Jul 2011
- Posts
- 43
- Rep Power
- 0
Similar Threads
-
.jar wont run?
By stevenpalomino in forum New To JavaReplies: 1Last Post: 06-30-2011, 10:11 AM -
Why Wont This Work???
By Billywizz in forum New To JavaReplies: 11Last Post: 03-09-2011, 02:33 AM -
why wont the %.2f work here?
By jjth39347 in forum New To JavaReplies: 2Last Post: 03-06-2011, 05:55 AM -
Able to compile OK, But wont run..Help
By subiedude101 in forum New To JavaReplies: 2Last Post: 02-20-2011, 08:37 PM -
Why wont this compile?
By Student101 in forum New To JavaReplies: 8Last Post: 11-18-2010, 05:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks