For Programmers: Free Programming Magazines  


Home > Archive > Java Help > June 2007 > printing the "%" charcter









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author printing the "%" charcter
Roy Gourgi

2007-06-21, 10:08 pm

Hi,

I am trying to print out the "%" character but I get an error.
This is my statement:

System.out.printf("Odds same percentage Move " + sInteger15 + "%" + "\n",
iDirectionOdds);

I am trying to print out the number followed by the percentage (%) sign.

Example: 15%

How would I do it.

TIA

Roy


Flo 'Irian' Schaetz

2007-06-21, 10:08 pm

And thus spoke Roy Gourgi...

> System.out.printf("Odds same percentage Move " + sInteger15 + "%" + "\n",
> iDirectionOdds);


Use %%.

Flo
Jeff Higgins

2007-06-21, 10:08 pm


Roy Gourgi wrote:
> Hi,
>
> I am trying to print out the "%" character but I get an error.
> This is my statement:
>
> System.out.printf("Odds same percentage Move " + sInteger15 + "%" + "\n",
> iDirectionOdds);


Exception in thread "main" java.util.UnknownFormatConversionException:
Conversion = '%'

>
> I am trying to print out the number followed by the percentage (%) sign.
>
> Example: 15%
>
> How would I do it.


public class PrintPercentage
{
public static void main(String[] args)
{
int percent = 15;
System.out.print(percent + "%");
}
}

>
> TIA
>
> Roy
>



Nigel Wade

2007-06-21, 10:08 pm

Roy Gourgi wrote:

> Hi,
>
> I am trying to print out the "%" character but I get an error.
> This is my statement:
>
> System.out.printf("Odds same percentage Move " + sInteger15 + "%" + "\n",
> iDirectionOdds);
>
> I am trying to print out the number followed by the percentage (%) sign.
>
> Example: 15%
>
> How would I do it.
>
> TIA
>
> Roy


The reason you are getting the error is because you are using the
PrintStream.printf() method which prints formatted strings and % is a special
character in the format specifier. Read the documentation at
http://java.sun.com/javase/6/docs/a...rintStream.html
to see how to format a string.

Your argument list seems to be a little . Which variable are you trying
to have printed, sInteger15 or iDirectionOdds, or both? If you only want
sInteger15 followed by a percent use PrintStream.print() and drop the
unnecessary iDirectionOdds from the argument list. Better still use println()
and drop the "\n".

--
Nigel Wade, System Administrator, Space Plasma Physics Group,
University of Leicester, Leicester, LE1 7RH, UK
E-mail : nmw@ion.le.ac.uk
Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
Bluto Blutarsky

2007-06-21, 10:08 pm

Roy Gourgi wrote:
> Hi,
>
> I am trying to print out the "%" character but I get an error.
> This is my statement:
>
> System.out.printf("Odds same percentage Move " + sInteger15 + "%" + "\n",
> iDirectionOdds);
>
> I am trying to print out the number followed by the percentage (%) sign.
>
> Example: 15%
>
> How would I do it.
>
> TIA
>
> Roy
>
>

....i know shit but i'd try escaping it
System.out.printf("Odds same percentage Move " + sInteger15 + \% + "\n",
.... maybe

b
--
Sometimes I'm in a good mood.
Sometimes I'm in a bad mood.
When all my moods have cum to pass
i hope they bury me upside down
so the world can kiss me porcelain,
white, Irish bottom.
Lew

2007-06-21, 10:08 pm

Roy Gourgi wrote:

A question is indicated typographically by a question mark ('?') at the end of
a sentence.

Bluto Blutarsky wrote:[color=darkred]
> ...i know shit but i'd try escaping it
> System.out.printf("Odds same percentage Move " + sInteger15 + \% + "\n",
> ... maybe


And you would find that it didn't work.

Why speak from ignorance when you can look up
<http://java.sun.com/javase/6/docs/a...ter.html#syntax>
and know without doubt?

Or you could read the correct answer that was provided upthread.

--
Lew
Ck60

2007-06-22, 9:03 pm

Britney Spears and Tara Reid , Weird Lesbian Sex Act!
http://www.YourTubeAmp.com/watch?watch=726071

bald beaver britney spear con gratis perros putas video download lesbian video britney spear suv umbrella video de porn gratis
2 confession lyric usher musica instrumental gratis xxx free movies de foto gratis penes street fight video clip
video sexo gratis lesbianas paris sex video clip free rough sex video free hardcore movie porstar asian porn star video
one night in chyna video clip adult video universe free movie matura gallery vintage porn movie britney spears porn video

supprimer windows movie maker
rough movie pink
xxl hardcore movies
free game online poker video
gratis juegos quest
free hot porn video
cat fight video
ares espaƱol gratis
video porn gratis de travestis
free adult video clip sample
Skiller

2007-06-23, 4:38 am

Jessica Simpson and Halle Berry Lesbian XXXXing!
http://www.WatchingTheTube.com/watch?movie=1673286

Paris Hilton and Halle Berry Tormented By Cowgirls!
http://www.WatchingTheTube.com/Medi...cgi?vid=1673286

Alyson Hannigan and Mariah Carey Go Lesbian!
http://www.WatchingTheTube.com/Watch?clip=1673286

Sarah M. Gellar and Alyssa Milano Lesbian XXXXing!
http://www.WatchingTheTube.com/Play...mpeg?id=1673286

Paula Abdul and Christina Aguilera playing with each other on film!
http://www.WatchingTheTube.com/WatchTube?q=1673286

funny video clip mpeg video my funny valentine funny mobile video clip clip free funny online video funny pic and video
http://635-funny-video.info/funny-basketball-video.html http://635-funny-video.info/funny-sports-video.html http://635-funny-video.info/funny-c...video-clip.html http://635-funny-video.info/sexy-funny-video-naked.html http://635-funny-video.info/funny-h...-video-web.html
Callister

2007-06-25, 9:44 am

Cameron Diaz and Jessica Alba Tormented By Cowgirls!
http://www.eyrenet.com/Player?q=726648

Nikki Cox and Britney Spears Become Lesbians!
http://www.eyrenet.com/Play?vid=726648

Alyssa Milano and Mariah Carey Lesbian XXXXing!
http://www.eyrenet.com/d?q=726648

Pamela Anderson and Ashlee Simpson Licking Pussy!
http://www.eyrenet.com/WatchMovie?id=726648

Britney Spears and Jennifer Aniston In Pussy Cucumber!
http://www.eyrenet.com/WatchTube?clip=726648

free sex movie clip filme porn gratis ro gratis putas tirando paris hilton new pic gay ebony video clip
mature porn video amateur bbw porn video creator house usher sex movie free download funny google video
free xxx video sample download tube video x video clip xxx gratis asian xxx video boy movie gay
free mika tan video clip clip video youtobe bet music video porn xxx video sample foto sexo gratis video

asian lesbian porn video
free porn video free sex video
free hot porn video
bajar musica mp3 gratis
madonna true blue
free daily xxx video
free music spanish video
yahoo movie
hollywood video location
ebony xxx video clip
Adjo

2007-06-26, 9:06 am

Shania Twain and Paris Hilton Crazy On High Heels!
http://www.theillegalsite.com/PlayM...p?movie=1673286


funny site video flash funny video zelda best email funny video funny pic joke video funny flash video download
http://635-funny-video.info/free-fu...lip-online.html http://635-funny-video.info/christi...video-clip.html http://635-funny-video.info/clip-funny-hot-video.html http://635-funny-video.info/clip-funny-site-video.html http://635-funny-video.info/clip-funny-hot-video.html
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com