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

Java programming.using NetBeans. data structure required and print ticket, displ

ID: 3881259 • Letter: J

Question

Java programming.using NetBeans. data structure required and print ticket, displaying the input information

Here is the list of ticket (s) Ticket No:1 Car Make Honda Car Model: Accord Car Year 2013 Car License No HDD-3333 Car State Teas Car Color Green ViolationType: Other Car Sucks Date: 2-2-2018 Time: 3:33PM Issuer John Martinez Location: SETB Payment Information Tickets can be paid at Business Office, Tandy 107 Monday Thru Thursday 8:00am to 5:00pm 25 Dollars Per Citation, other fees may apply $100 for Boot Removal Ticket No:2 Car Make: Chevy Car Model: Cruze Car Year 2010 Car License No: 33H-DHE3 Car State Teas Car Color: Purple ViolationType: FL-Vehicle Parked in a Fire Lane Date 1-2-2004 Time 7:22 AM Issuer: Greg P Location: LSHB Payment Information Tickets can be paid at Business Office, Tandy 107 Monday Thru Thursday 8:00am to 5:00pm 25 Dollars Per Citation, other fees may apply $100 for Boot Removal

Explanation / Answer

import java.util.*;

public class MyClass {
  
public static void main(String args[]) {
  
int ticketNo = 1; // initializing the variable which will generate ticket Numbers
List<HashMap> tickets = new ArrayList(); // This data-structure List will store all the Tickets.Each ticket will be stored as Map object.
Scanner reader = new Scanner(System.in); // Scanner object will help to take user input
  
String decision = "Y"; // This variable willl store the decision of the user , if he wants to continue or not
do
{
System.out.println(" Choose the operation 1. Issue a ticket 2. Print all tickets 3. Exit "); //Message to user to choose operation
int op = reader.nextInt(); // Store the user input in this variable
  
switch(op) //staring aswitch case
{
case 1 :
{
HashMap<String, String> hm = new HashMap<String, String>();
// storing the ticket no and then increaing it by one
hm.put("Ticket No", Integer.toString(ticketNo));
ticketNo++;
  
String str = null;
// Input other details from the user and store into the Hash Map one by one
System.out.print(" Enter Car Make : ");
str = reader.next();
hm.put("Car Make", str);
  
System.out.print(" Enter Car Model : ");
str = reader.next();
hm.put("Car Model", str);
  
System.out.print(" Enter Car Year : ");
str = reader.next();
hm.put("Car Year", str);
  
System.out.print(" Enter Car License No : ");
str = reader.next();
hm.put("Car License No", str);
  
System.out.print(" Enter Car State : ");
str = reader.next();
hm.put("Car State", str);
  
System.out.print(" Enter Car Color : ");
str = reader.next();
hm.put("Car Color", str);
  
System.out.print(" Enter Violation type : ");
str = reader.next();
hm.put("Violation type", str);
  
System.out.print(" Enter Date : ");
str = reader.next();
hm.put("Date", str);
  
System.out.print(" Enter Time : ");
str = reader.next();
hm.put("Time", str);
  
System.out.print(" Enter Issuer : ");
str = reader.next();
hm.put("Issuer", str);
  
System.out.print(" Enter Location : ");
str = reader.next();
hm.put("Location", str);
  
System.out.print(" Enter Payment Information : ");
str = reader.next();
hm.put("Payment Information", str);
  
str="Business Office , Tandy 107 Monday thru Thrusday 8:00am to 5:00pm $25 Dollars Per Citation , other fees may apply $100 for Boot Removal";
hm.put("Tickets can be paid at", str);
  
tickets.add(hm); // Adding the Ticket map to list of tickets
  
}
break;
case 2 :
{
System.out.println("Here is the List of Ticket(s)");
  
// Iterating over the List of Tickets and display details of each ticket
for(HashMap hm : tickets){
System.out.println("Ticket No : "+hm.get("Ticket No"));
System.out.println("----------------------");
System.out.println("Car Make : "+hm.get("Car Make"));
System.out.println("Car Model : "+hm.get("Car Model"));
System.out.println("Car Year : "+hm.get("Car Year"));
System.out.println("Car License No : "+hm.get("Car License No"));
System.out.println("Car State : "+hm.get("Car State"));
System.out.println("Car Color : "+hm.get("Car Color"));
System.out.println("Violation type : "+hm.get("Violation type"));
System.out.println("Date : "+hm.get("Date"));
System.out.println("Time : "+hm.get("Time"));
System.out.println("Issuer : "+hm.get("Issuer"));
System.out.println("Location : "+hm.get("Location"));
System.out.println("Payment Information : "+hm.get("Payment Information"));
System.out.println("Tickets can be paid at : "+hm.get("Tickets can be paid at"));
System.out.println("----------------------");
}
}
break;
case 3:
System.exit(0);
break;
default :
System.exit(0);
break;
}
  
System.out.println("Press 'Y' to continue and 'N' to exit"); // Message to user if he wants to continue or not
decision = reader.next(); // Store the user input in this variable
}
while(decision.equalsIgnoreCase("Y")); // Condition for do while loop
  
  
  
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote