• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Nov 23, 2011 at 12:26 AM by Eric5h5 for the following reason:

Question is off-topic or not relevant

avatar image
0
Question by Brotoss · Nov 22, 2011 at 11:54 PM · errorjava

class, interface or enum exptected java program

Hello!

So i get this errormessage when i try to compile my java code in CMD to check it you know. I get the Class, interface or enum expected error as feedback. What to do? I am new to programming and I dont see where i did wrong! Would love if someone could take a quick look and help me, cant see the issue! :(

Code:

package ex ;

public static void main(String[] args) { Scanner keyboard = new Scanner(System.in); int amount = 0; int choice = 0; int[] transactions = new int[10]; int sum = 0; int balance = 0;

     while(choice != 4)
     {
         choice = menu();
         switch(choice)
         {
         case 1:
             System.out.print("Vilken summa vill du sätta in? ");
             sum = keyboard.nextInt();
             if(sum == 0)
             {
                 System.out.print("Du har angett ett felaktigt belopp");
                 System.out.println();
                 System.out.println();
             }
             else
             {
                 amount = (int) + sum;
                 makeTransactions(amount, transactions);
             }
             break;
         case 2:
             System.out.print("Vilken summa vill du ta ut? ");
             sum = keyboard.nextInt();
             if(sum == 0)
             {
                 System.out.print("Du har angett ett felaktigt belopp");
                 System.out.println();
                 System.out.println();
             }
             else
             {
                 amount = (int) - sum;
                 makeTransactions(amount, transactions);
             }
             
             break;
         case 3:
             showTransactions(transactions, balance);
             break;
         case 4:
             System.out.println("Du valde att avsluta!");
             break;
             
         }
         
     }
     
 }
 
     public static int menu()
     {
         Scanner keyboard = new Scanner(System.in);
         int choice = 0;
         
         System.out.println("Enkel Bankomat");
         System.out.println();
         System.out.println("1. Insättning");
         System.out.println("2. Uttag");
         System.out.println("3. Saldobesked");
         System.out.println("4. Avsluta");
         System.out.println();
         System.out.print("Ditt val: ");
         
         choice = keyboard.nextInt();
         
         return choice;
         
     }
     
     
     public static void showTransactions(int[] transactions, int balance)
     {
         System.out.println();
         System.out.println("Tidigare transaktioner: ");
         System.out.println();
         
         for(int i = 0; i < transactions.length; i++)
         {
             if(transactions[i] == 0)
             {
                 System.out.print("");
             }
                 
             else
             {
                 System.out.print(transactions[i] + "\n");
                 balance = balance + transactions[i];
             }
             
         }
         System.out.println();
         System.out.println("Saldo: " + balance + " kr" + "\n");
         System.out.println();
         
     }
     
     public static void makeTransactions(int amount, int[] transactions)
     {
         
         int position = findNr(transactions);
         if (position == -1)
         {
             moveTrans(transactions);
         }
         else
         {
             
             transactions[position] = amount;
         }
     }
     
     public static int findNr(int[] transactions)
     {
         int position = -1;
         
         for(int i = 0; i < transactions.length; i++)
         {
             if (transactions[i] == 0)
             {
                 position = i;
                 break;
             }
         }
         return position;
     }
     
     public static void moveTrans(int[] transactions)
     {
         for(int i = 0; i < transactions.length; i++)
         
             transactions[0] = transactions[i + 1];
     }
     

}

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Eric5h5 · Nov 23, 2011 at 12:27 AM 0
Share

Unity Answers is for Unity (which doesn't use Java). This isn't GenericCodeAnswers.

0 Replies

  • Sort: 

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Getting Android build errors. 2 Answers

erorr in building scene ????? 0 Answers

script error missingfeildexception 1 Answer

ClassNotFoundException on UnityPlayerProxyActivity on some devices 0 Answers

Error with trigger PLZ HELP!!!! 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges