Extremely simple question from an extremely simple high-school java student.
I've gathered user input and created an object "AccountOne". I must pass AccountOne into class printcode and use the printaccount method to print "myaccount.name, myaccount.address, myaccount.type, myaccount.balance". My teacher has been trying to explain inheritance and she's just losing me more and more with each day. From what I understood, object myaccount of type AccountOne should now "have" myaccount.name, myaccount.address, myaccount.type, myaccount.balance" within itself. And because I passed the object into the method, the method inherits whatever is in the object. Ergo, method printaccount should be able to find symbols "myaccount, my account.name, myaccount.address, myaccount.type, myaccount.balance". I've researched and everything doesn't make sense to me, it all appears to be about way more advanced stuff that I haven't even begun to grasp yet. If there's a duplicate question please point me to it.
When compiling i get 10+ errors saying "not a statement" or "cannot find symbol myaccount". At this point i'll just take the zero, I'm beyond frustrated. It's most likely something stupidly simple that i keep glancing over.
I've tried defining the variables within printcode before the main statement. Defined variables in AccountOne. Attempted to research different ways of define a method and couldn't find anything that made sense to me.
import java.util.Scanner;
public class AccountOne
{
public String name;
public String address;
public String type;
public double balance;
public static void main(String args[])
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter Name ");
String name=keyboard.nextLine();
System.out.println();
System.out.print("Enter Address ");
String address=keyboard.nextLine();
System.out.println();
System.out.print("Enter type ");
String type=keyboard.nextLine();
System.out.println();
System.out.print("Enter Balance ");
double balance=keyboard.nextDouble();
System.out.println();
AccountOne myaccount=new AccountOne();
myaccount.name=name;
myaccount.address=address;
myaccount.type=type;
myaccount.balance=balance;
printcode.printaccount(myaccount);
}
}
Second Class - printcode:
public class printcode
{
public static void main(String args[])
{
public static printaccount(AccountOne myaccount)
{
System.out.println("My Account = " + myaccount.name + " " + myaccount.address + " " + myaccount.type + " $" + myaccount.balance);
}
}
}