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

Pages: 1-

Java won't work

Name: Anonymous 2010-09-23 19:47

why?

import java.text.DecimalFormat;
public class Internetcosts
{
    public static void main(String[] args)
    {
        int hours = 10;
        double packa = 9.95;
        double packb = 13.95;
        double packc = 19.95;
       
        DecimalFormat formatter = new DecimalFormat("#00.00");
       
        System.out.print("Hours     Pack A     Pack B     Pack C");
        System.out.print("-----------------------------");
       
process_hours:
        System.out.print(formatter.format(packa + 2));
        System.out.print(formatter.format(packb + 1));
        System.out.print(formatter.format(packc);
        ++hours;
        if(hours <= 50)
            goto process_hours;
    }
}

Name: Anonymous 2010-09-23 19:48

because you touch yourself at night

Name: Anonymous 2010-09-23 19:53

because you touch yourself at night

Name: Anonymous 2010-09-23 19:55

If only you were capable of reading compiler error messages.

Name: Anonymous 2010-09-23 20:01

>>4
what's that? I'm new to programming and the stuff i use is just a button click

Name: Anonymous 2010-09-23 20:15

>>5
No wonder you get errors. Your grammar fails my parser.

Name: Anonymous 2010-09-23 20:32

>>1
$ javac Internetcosts.java
Internetcosts.java:19: ')' expected
        System.out.print(formatter.format(packc);
                                                ^
Internetcosts.java:22: illegal start of expression
                             goto process_hours;
                             ^
Internetcosts.java:22: not a statement
                             goto process_hours;
                                  ^
3 errors


   1. You forgot a ).
   2,3. Java does not support the goto statement.

Here, apply this:
16a17
      while (true) {
19c20
<         System.out.print(formatter.format(packc);
---
          System.out.print(formatter.format(packc));
21,22c22,25
<                        if(hours <= 50)
<                            goto process_hours;
---
          if(hours <= 50) {
              break process_hours;
          }
      }

Name: Anonymous 2010-09-23 20:40

>>7
obligatory You Helped Him!!!

Name: Anonymous 2010-09-23 20:46

But i want to use gotos. They are alot better.

Name: Anonymous 2010-09-23 20:53

process_hours:
...
goto process_hours;

You are either a troll or a student of a better world than this one (on the other hand, "GOTO Considered Harmful").

One obvious problem is that you forgot to close the 19th line's parentheses.  Changing the does-not-work goto into a loop ...
do
{
   System.out.print(formatter.format(packa + 2));
   System.out.print(formatter.format(packb + 1));
   System.out.print(formatter.format(packc));
   ++hours;
}
while(hours <= 50);

allows Java to accept the source code, though its output is still sad.

Future concerns: packa packb do not stack the addition of 2 and 1, respectively, each print as I am assuming that is what you want.  They discard the results of the addition after the print statement.

And we're done here.  All future posts on this thread should include sage and, optionally, " >>7 YHBT."

Name: Anonymous 2010-09-23 20:55

>>9
Java doesn't recognize a literal goto statement.

Name: Anonymous 2010-09-23 21:00

>>11
I now see why people say Java sucks then.

Name: Anonymous 2010-09-23 21:07

>>12
There are many reasons why Java sucks, a lack of a goto statement isn't really one of them.

Name: Anonymous 2010-09-23 21:08

>>12
There are many reasons why Java is a bad language but not supporting a goto statement is a new one on me.

Name: Anonymous 2010-09-23 21:09

>>14
We should post an article about it to make it known

Name: Anonymous 2010-09-24 0:51

Java made goto popular by not having it

Name: Anonymous 2010-09-24 7:55

The next version of Java will include CallWithCurrentEnterpriseContinuation(new FunctionWrapper(x)) where x is an object of class ContinuationReceiver which implements the ContinuationCallee interface which requires you to define methods isAvailable(), isItReallyAvailable(), aboutToCallIt(), targetCalleeMethod() and itsDoneJustSoYouKnow(), but don't worry because you can inherit two of them from BaseContinuationReceiver.

Name: Anonymous 2010-09-24 7:56

java considered harfmul

Name: New, related topic 2010-09-24 8:16

My University course involves lots of Java. This makes me sad.
On the other hand, my library has the Wizard book and I can program whatever I want outside of my course.

Name: Anonymous 2010-09-24 8:27

>>17
Terrible!

Name: Anonymous 2010-09-24 8:28

>>19
Interesting, I should go see if I can find the Wizard book as well in my own uni library, maybe I'll find it at a good price.

Name: Anonymous 2010-09-24 10:55

>>21
I don't think you even know what a library is.

Name: Anonymous 2010-09-24 11:59

>>22
+1

Name: Anonymous 2010-09-24 12:02

>>23
Why so sagefault

Name: Anonymous 2010-09-24 12:02

>>22
A collection of subroutines or classes used to develop software?

Name: Anonymous 2010-09-24 12:19

>>24
Because of Zarn, you ungrateful shitbillower.

Name: Anonymous 2010-09-25 0:47

Zarn
Cretin.

Name: Anonymous 2010-09-27 0:11

because you goto yourself at night

Name: Anonymous 2011-02-04 15:34


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