Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

JAVA help

Name: Anonymous 2008-01-22 20:03

Hey, the &d is not working in this program.... anyone know why?   I am new to java.

import java.util.Scanner;


public class Circle {
   

    public static void main( String args[] )
    {

    Scanner input = new Scanner( System.in );

    double radius;
    double diameter;
    double circum;
    double area;
   
    //Get Radius
    System.out.println( "Enter Radius:" );
    radius = input.nextInt();

    //Figure Values
    diameter = radius * 2;
    circum = 3.14159 * diameter;
    area = 3.14159 * radius * radius;

    System.out.printf( "Diameter is %d\n: " , diameter );
    }
}

Name: Anonymous 2008-01-22 20:04

OP here, I ment the %d is not working...

Name: Anonymous 2008-01-22 20:14

Your troll level is maximum.

Name: Anonymous 2008-01-22 20:19

OP..    Um...  when I go to run it, it stops at the %d and says a buncha error shit.  Does the code look right?

Name: Anonymous 2008-01-22 20:26

Probably a rounding error. Use Math.PI for greater accuracy.

Name: Anonymous 2008-01-22 20:30

mm, I just tried that.   Can a double variable be presented with the %d format?    

Name: Anonymous 2008-01-22 20:33

Name: Anonymous 2008-01-23 5:07

This is the reason I come to /prog/, for the trolling and cheap laughs.

Name: Anonymous 2008-01-23 5:47

%d is for integers. You need to use %f.

Name: Anonymous 2008-01-23 8:45

SICPFLOOD

Name: Anonymous 2008-01-23 12:39

I thought pi was much longer than that.

Name: Anonymous 2008-01-23 18:21

3.14159265358979 is how much of Math.PI I remember. Lol

Name: Anonymous 2008-01-23 18:38

in Java you don't use printf. ever. it's System.out.print or System.out.println

Also, you just put in the damn variable. System.out.print("The Diameter is " + diameter);

There, I killed the joke

Name: Anonymous 2008-01-23 20:03

Name: Anonymous 2008-01-23 20:43

>>14
But printf() isn't nearly as ENTERPRISE as using the + operator

Name: Anonymous 2009-03-06 9:56

Of the application Thanks.

Name: Anonymous 2013-08-31 19:53


I liked the atmosphere of couple first episodes very much, then there were many rather uninteresting plot developments but overall very feel giving and satisfying experience.

Name: Anonymous 2013-08-31 21:24


Teach a man to fish, and you just eliminated your customer base idiot. Their ignorance was your job security as a restaurant owner ! Now you have to face a foreclosure! Are you proud of yourself? Are you?

Don't change these.
Name: Email:
Entire Thread Thread List