Hey guys. I'm having so much trouble understanding setters and getters. I've read the setter/getter chapter for our testbook multiple times and have looked up many things online but can't get it to work. It doesn't help that there are very few completed examples in my book so its hard to actually see how anything is applied in a finished state. This is one of our programs we have to do for class. We were supposed to use setters and getters, but I couldn't figure it out, so desperately created the program below to at least get the end result, albeit not with the method required. Utilizing my program below, can someone explain the basics of setters and getters and how I would apply them? Not asking for someone to do my work for me, just thought it'd give a good example for me to understand. My program basically shows a menu, a user enters how many of each product they want through keyboard input, and then the program calculates the subtotal before tax, the tax amount, and then the grand total (subtotal + tax). Pretty simple.
public class CateringOrderApp {
public static void main(String\[\] args) {
Scanner keyboard = new Scanner(System.in);
//Declares tax rate constant.
double SALES\_TAX\_RATE = .0875;
//Declares calculation variables.
double subtotalCost;
double taxAmount;
double totalCost;
//Sets constant prices for items.
double VEGGIE\_SANDWICH\_PRICE = 2.75;
double HAM\_AND\_CHEESE\_SANDWICH\_PRICE = 3.25;
double SPAGHETTI\_PRICE = 35.00;
double SALAD\_PRICE = 18.00;
//Declares order count for items
double veggieSandwichCount = 0;
double hamAndCheeseSandwichCount = 0;
double spaghettiCount = 0;
double saladCount = 0;
//Displays menu
System.out.println("Food Item Price");
System.out.println("--------------------------------------------------------");
System.out.println("Veggie Sandwich $2.75");
System.out.println("Ham and Cheese Sandwich $3.25");
System.out.println("Spaghetti (tray serves 20) $35.00");
System.out.println("Salad (tray serves 20 $18.00");
System.out.println("--------------------------------------------------------");
//Begins to ask customer about the number of orders for each specific item.
System.out.println("Please enter the amount of Veggie sandwiches that yo