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

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 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;
          }
      }

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