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

How do I do this in java...?

Name: newfag 2008-02-06 11:02

  //grading
  float grade = -1.0F;
  do {
    System.out.print("Input your grade: ");
    grade = grade.nextFloat();
    if (grade < 0.0F || grade > 1.5F) {
      System.err.println("Error: The grade must be between 0.0 and 1.5!");
    }
  } while (grade < 0.0F || grade > 1.5F);

It's done, but I want it to deal with some cases, like... if the guy inputs a name or something... is it possible to this in java?

thanks

Name: Anonymous 2008-02-06 11:25

try {

    Float.parseFloat(grade)
} catch (NumberFormatException nfe) {

    System.out.println("FLOAT ONLY, NIGGER");

}

Name: Anonymous 2008-02-06 11:26

holy fucking christ fag shit cock.

(define (fag)
  ((lambda (f)
     (if (or (< f 0) (> f 1.5))
         (begin
           (display "Error: The grade must be between 0 and 1.5!")
           (fag))
         f)) (read)))

(define (main)
  (begin
    (display "Input your grade: ")
    (display (fag))))

Name: Anonymous 2008-02-06 11:31

dhtrthhtdhtg

Name: Anonymous 2008-02-06 11:43


grade = do
  putStrLn "Hello give me numbers"
  grade <- read getLine
  if grade > 1.5 or grade < 0
    then putStrLn "Learn to count, chink"
  else putStrLn ("Hey, your grade is" ++ grade ++ ", what do you want to do now?")

Name: Anonymous 2008-02-06 11:43

Also, grade :: IO()

Name: Anonymous 2008-02-06 11:56

>>1
grade = grade.nextFloat();
wat

Name: Anonymous 2008-02-06 12:10

>>5
Chk chk. ITYM "show grade" in there somewhere, as it cannot be a string and comparable to the default decimal type.

Name: Anonymous 2008-02-06 12:10

>>7
it's from java.util.random. OP is an idiot (or a troll)

Name: Anonymous 2008-02-06 12:33

>>9
Yeah, Random.nextFloat() is the only nextFloat() I know too, but that's not how you use it at all. His code doesn't even compile.

Name: Anonymous 2008-02-06 12:36

>>5
Failed indentation?

Name: Anonymous 2008-02-06 12:52

>>8
Like
  else putStrLn ("Hey, your grade is" ++ show grade ++ ", what do you want to do now?")
?

Name: Anonymous 2008-02-06 13:03

>>12
Yeth.

Name: newfag 2008-02-06 13:25

>>7

op here, sorry, it was a typo

Scanner scanner = new Scanner(System.in);
...

    grade = scanner.nextFloat();

>>9
I made a typo, so fuck you. if you're saying that there's only one nextFloat() then maybe you're the idiot, lol?

Name: Anonymous 2008-02-06 13:29

This thread is not about Haskell. It is about Java.

Name: Anonymous 2008-02-06 13:34

>>14
I made a typo, so fuck you. if you're saying that there's only one nextFloat() then maybe you're the idiot,
Look at angry man!
>, lol!
Look at the fool!

Name: Anonymous 2008-02-06 13:34

I HAVE CREATED A BBCODE BUG, FORGIVE ME, MASTER

Name: Anonymous 2008-02-06 14:31

>>14
You can't look for a String input while getting floats from Scanner. Use something else instead, like a BufferedReader wrapping an InputStreamReader combined with a parseFloat().
Don't forget to catch exceptions.

Name: Anonymous 2008-02-06 15:13

Yeah, use a factory factory with a decorator pattern. And you can throw in a visitor, for good measure.

This thread is now about design patterns.

Name: Anonymous 2008-02-06 15:16

>>18
Or you could just use JOptionPane.showInputDialog(), if you want to abstract Java's cancer away a bit, and add a graphical interface. The important part is that you're reading plain Strings, not parsed floats.

Name: Anonymous 2008-02-06 15:39

Just parse the fuckers yourself.

Name: Anonymous 2008-02-06 15:39

>>19
No, this thread is now about Haskell.

Name: Anonymous 2008-02-06 15:39

HASKELL.

HASKELL NOMADS.

Name: Anonymous 2008-02-06 15:39

HASKELL.

HASKELL NOMADS.

Name: Anonymous 2008-02-06 15:40

HASKELL.

HASKELL NOMADS.

Name: Anonymous 2008-02-06 15:40

HASKELL.

HASKELL NOMADS.

Name: Anonymous 2008-02-06 15:40

HASKELL.

HASKELL NOMADS.

Name: Anonymous 2008-02-06 15:40

HASKELL.

HASKELL NOMADS.

Name: Anonymous 2008-02-06 15:40

HASKELL.

HASKELL NOMADS.

Name: Anonymous 2008-02-06 15:40

HASKELL.

HASKELL NOMADS.

Name: Anonymous 2008-02-06 16:10

>>23-30
Samefag. What else is new?

Name: Anonymous 2008-02-06 16:28

>>31
Haskell... nomads?

Name: Anonymous 2011-02-04 11:32


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