Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a public static integer field named nextTicket and initialize nextTicket with 4 0 0 public class Order { private String food; private int ticket;

Create a public static integer field named nextTicket and initialize nextTicket with 400 public class Order {
private String food;
private int ticket;
public Order(String newFood){
food = newFood;
ticket = nextTicket;
nextTicket -=4;
}
public void print(){
System.out.println(food +"'s ticket is "+ ticket +".");
}
} import java.util.Scanner;
public class NewOrders {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
System.out.println("Next available ticket is "+ Order.nextTicket +".");
Order order1= new Order(scnr.next());
Order order2= new Order(scnr.next());
Order order3= new Order(scnr.next());
order1.print();
order2.print();
order3.print();
System.out.println("Next available ticket is "+ Order.nextTicket +".");
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Use formula (2) to find the value of each combination. C(15, 15)

Answered: 1 week ago