Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8757947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:25:28+00:00 2026-06-13T14:25:28+00:00

I get an error that says expected. It is in this section of the

  • 0

I get an error that says ” expected”. It is in this section of the code I get it here (*****).

Why do i get this? im a beginner and am stuck on this issue and would like to know how i can solve this. why do i get a identifier expected error where i have *. what does that mean ad how can i resolve this? thankssss

/**
* TicketMachine models a ticket machine that issues
* flat-fare tickets.
* The price of a ticket is specified via the constructor.
* Instances will check to ensure that a user only enters
* sensible amounts of money, and will only print a ticket
* if enough money has been input.
*/
public class TicketMachine
{
// The price of a ticket from this machine.
private int price;
// The amount of money entered by a customer so far.
private int balance;
// The total amount of money collected by this machine.
private int total;

/**
* Create a machine that issues tickets of the given price.
*/
public TicketMachine(int cost)
{
if (cost > 0) 
{
price = cost;
balance = 0;
total = 0;
}
else
{ 
System.out.println("can not be minus");
}
}

/**
* @Return The price of a ticket.
*/
public int getPrice()
{
return price;
}

/**
* Return The amount of money already inserted for the
* next ticket.
*/
public int getBalance()
{
return balance;
}

/**
* Receive an amount of money from a customer.
* Check that the amount is sensible.
*/
public void insertMoney(int amount)
{
if(amount > 0) {
balance = balance + amount;
}
else {
System.out.println("Use a positive amount rather than: " +
amount);
}
}

/**
* Print a ticket if enough money has been inserted, and
* reduce the current balance by the ticket price. Print
* an error message if more money is required.
*/
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 + " cents.");
System.out.println("##################")…
System.out.println();

// Update the total collected with the price.
total = total + price;
// Reduce the balance by the prince.
balance = balance - price;
}
else {
System.out.println("You must insert at least: " +
(price - balance) + " more cents.");

}
}

/**
* Exercise printtickettwo
*/
public void printTicketTwo();
int amountLeftToPay;
amountLeftToPay (***********) = price - balance;

if (amountLeftToPay > 0) 
{
// Simulate the printing of a ticket.
System.out.println("##################")…
System.out.println("# The BlueJ Line");
System.out.println("# Ticket ");
System.out.println("# " + price + " cents.");
System.out.println("##################")…
System.out.println();
}
else
{
System.out.println.("Amount Still Required);
} 
}

/**
* Return the money in the balance.
* The balance is cleared.
*/
public int refundBalance()
{
int amountToRefund;
amountToRefund=balance;
balance = 0;
return amountToRefund;
}

/**
* Exercise empty machine money
*/ 
public int emptyMachine()
{
int emptyMachine;
emptyMachine = total;
total = 0;
return total;
}

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:25:30+00:00Added an answer on June 13, 2026 at 2:25 pm

    This line public void printTicketTwo();

    Instead needs to be

    public void printTicketTwo() { *method body* }

    Edit – generally debugging advice; When you get an error like this there is generally a line number if you have an error or errors find the smallest line number and look at the code there. Often times the syntax error is in a line above the on mentioned for example if you have int myInt = 5 and int mySecondInt = 7; on the following line the error will likely reference the second line even though it was caused by omitting a semi colon on the line before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get that error with the following code. anyone know why? function validateAdminInput(){ var
I get an error that says Parse error: syntax error, unexpected T_PRIVATE in E:\PortableApps\xampp\htdocs\SN\AC\ACclass.php
I am new to Python. I get an error that says undefined Variable. I
How do I unit test my code that has LTS Datacontext. I get error
I see that many people get this error, but their situations all appear a
Here is the complete error message that I get in the Package Manager Console
I have some code like: try: do_the_first_part() except SomeError: do_the_next_part() I get an error
while executing the following query, i get an error that there's an error in
A quick question regarding the java.lang.VerifyError exception. Suppose I get an error that looks
When I add a ChildPanel to a page, I get an error that states:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.