Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

/* * TicketMachine models a ticket machine that issues * flat-fare tickets. */ I

ID: 3616474 • Letter: #

Question

/* * TicketMachine models a ticket machine that issues
* flat-fare tickets. */
I want to make this to compile in Java. Please help


public class TicketMachine{
private int price;
private int balance;
private int total;
   public TicketMachine(int ticketCost)//constructor
    { price = ticketCost;
        balance = 0;
        total =0;    }
    public int getPrice()
    {       return price;    }
    public int getBalance()
    { return balance;    }
public int getTotal()
    { return total;    }

public void insertMoney(int amount)
    {
        if(amount > 0)
           balance = balance + amount;
        else {
           System.out.println(“This is not positive "+amount);        }
    }
  
    public int refundBalance()
       {   intamountToRefund;
          amountToRefund = balance;
          balance = 0;
           returnamountToRefund;
       }
// continued on the next page

TicketMachine’s end
    public void printTicket()
    {       if(balance >= price) {
           // Simulate the printing of a ticket.
           System.out.println("##################");
           System.out.println("# The BlueJ Line");
           System.out.println("# Ticket");
           System.out.println("# " + price + " pence.");
           System.out.println("##################");
           System.out.println();

           total = total + price;    // Update the total
           balance = balance - price; // Update the balance
        }
        else {System.out.println("You must insert at least: " +
                              (price - balance) + " more pence.");    }
    }
   }//end of class

Explanation / Answer

please rate - thanks it now compiles, other then a few "cosmetics", the public had to beremoved form the class /* * TicketMachine models a ticket machine that issues * flat-fare tickets. */ class TicketMachine{ private int price; private int balance; private int total;     public TicketMachine(int ticketCost)//constructor     { price = ticketCost;         balance = 0;         total =0;    }     public int getPrice()     {       return price;    }     public int getBalance()     { return balance;    } public int getTotal()     { return total;    } public void insertMoney(int amount)     {         if(amount > 0)            balance = balance + amount;         else {            System.out.println("This is not positive"+ amount);        }     }        public int refundBalance()        {   intamountToRefund;           amountToRefund = balance;           balance = 0;            returnamountToRefund;        } // continued on the next page //TicketMachine’s end     public void printTicket()     {       if(balance >= price) {            // Simulate the printing of a ticket.            System.out.println("##################");            System.out.println("# The BlueJ Line");            System.out.println("# Ticket");            System.out.println("# " + price + " pence.");            System.out.println("##################");            System.out.println();            total = total + price;    // Update the total            balance = balance - price; // Update the balance         }         else {System.out.println("You must insert at least: " +                               (price - balance) + " more pence.");    }     }    }//end of class