So im trying to write a simple java program for college and I\'m a complete newbie at this java stuff. I keep getting an error when I compile, \"error - could not find symbo
The variables you are passing are visible only inside main. The function printReceipt() is unable to see the variables because they are out of its scope of visibility.
Here you have few options you can try and the program will work:
Declare the variables as the data members of the public class Order rather than keeping them as members of the main() function (best option).
public class Order{ static String clubcard; static double clubcard_discount; static double special_discount; static double balance; static double final_balance; static int apples; static int oranges; static int apples_cost; static int oranges_cost; //main() and other functions... }
OR
Pass the data members as arguments to the PrintReceipt() function (though this may make you function a bit messy).
public static void printReceipt(int apples, int oranges, .... .... ){
//...defining your function
}
Hope this helps!