Results 1 to 3 of 3
Thread: Ignore Symbol
- 01-21-2009, 12:06 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 22
- Rep Power
- 0
Ignore Symbol
Hello everyone,
Alright, this is my 2nd day programming. I have a program where the user types a double into an input box. I'm telling the user to type a percent. How can I make it, so that if the user types
"15" OR "15%"
That they both equal 15?
In other words, eliminate the "%"?
Thanks!
-
this:
will return string with all percents removed. i.e.,Java Code:string.replaceAll("\\%", "");
Java Code:public class Fubar { public static void main(String[] args) { String string1 = "15"; String string2 = "15%"; System.out.println(stripPercent(string1)); System.out.println(stripPercent(string2)); int int1 = Integer.parseInt(stripPercent(string1)); int int2 = Integer.parseInt(stripPercent(string2)); System.out.println(int1 + int2); } private static String stripPercent(String string) { return string.replaceAll("\\%", ""); } }
- 01-21-2009, 12:24 AM #3
Member
- Join Date
- Jan 2009
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
cannot find symbol symbol :constructor Error. Please help! =(
By KalEl in forum New To JavaReplies: 9Last Post: 10-18-2008, 08:26 PM -
Need a pgeloading symbol
By jazz2k8 in forum Advanced JavaReplies: 1Last Post: 07-17-2008, 08:56 AM -
symbol not found error
By rmartyce in forum New To JavaReplies: 1Last Post: 05-23-2008, 05:58 AM -
cannot find symbol symbol : class Item location: package platypos.services.order
By officialhopsof in forum New To JavaReplies: 3Last Post: 05-01-2008, 08:30 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks