Jump to content
Sign in to follow this  
alienA2

Error: Main method not found in class Account, please define the main method as:

Recommended Posts

I got this code that will not run. I took the code from a book for dummies. I understand what it is asking but I do not know why since the book shows this code as if it should work when it runs. Please advice. error:C:\java_prog\mywork\Account>java AccountError: Main method not found in class Account, please define the main method as: public static void main(String[] args) code: import java.text.NumberFormat;import static java.lang.System.out;class Account{ // variable declarations String naam; int dompas; double jousakie; void display() { NumberFormat moola = NumberFormat.getCurrencyInstance(); out.print("The account with last name "); out.print(naam); out.print(" and ID number "); out.print(dompas); out.print(" has balance "); out.println(moola.format(jousakie)); }}

Share this post


Link to post
Share on other sites

java command needs main() function to run import java.text.NumberFormat;import static java.lang.System.out; class Account {// variable declarationsString name;int dompas;double jousakie; /* Constructor here */Account(String n, int d, double j){this.name = n;this.dompas = d;this.jousakie = j;} static void display() {NumberFormat moola = NumberFormat.getCurrencyInstance();out.print("The account with last name ");out.print(name);out.print(" and ID number ");out.print(dompas);out.print(" has balance ");out.println(moola.format(jousakie));} public static void main(String[] args){// you need constructor or will get ClassNotFound exceptionAccount acc = new Account("test", 1, 5000);acc.display(); } }

Edited by smiles

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...