Question
I NEED HELP!!! I have my code working properly but now i want it to get the information from a document i created in word.
I NEED HELP!!! I have my code working properly but now i want it to get the information from a document i created in word. Below is my code. how can i get my program to get the information from the document and provide a ticket if the time is surpassed.
By the way this is all in Java.
public class ParkedCar { private String make; private String model; private String color; private String licenseNumber; private int minutesParked;
public ParkedCar(String make, String model, String color, String licenseNumber, int minutes) { this.make = make; this.model = model; this.color = color; this.licenseNumber = licenseNumber; this.minutesParked = (minutes > 0) ? minutes : 0; }
public ParkedCar(ParkedCar other) { this.make = other.make; this.model = other.model; this.color = other.color; this.licenseNumber = other.licenseNumber; this.minutesParked = other.minutesParked; }
public String getMake() { return make; } public String getModel() { return model; } public String getColor() { return color; } public String getLicenseNumber() { return licenseNumber; } public int getMinutesParked() { return minutesParked; } public String toString() { return "Make: " + make + " " + "Model: " + model + " " + "Color: " + color + " " + "License Number: " + licenseNumber + " " + "Minutes Parked: " + minutesParked; } }
public class ParkingMeter { private int minutesPurchased;
public ParkingMeter(int minutes) { minutesPurchased = (minutes > 0) ? minutes : 0; } public ParkingMeter(ParkingMeter other) { this.minutesPurchased = other.minutesPurchased; }
public int getMinutesPurchased() { return minutesPurchased; } public String toString() { return "Minutes Purchased: " + minutesPurchased; } }
public class PoliceOfficer { private String name; private String badgeNumber;
public PoliceOfficer(String name, String badgeNumber) { this.name = name; this.badgeNumber = badgeNumber; }
public PoliceOfficer(PoliceOfficer other) { this.name = other.name; this.badgeNumber = other.badgeNumber; } public ParkingTicket patrol(ParkedCar car, ParkingMeter meter) { if (car.getMinutesParked() > meter.getMinutesPurchased()) { return new ParkingTicket(this,car,meter); } return null; } public String toString() { return "Officer Name: " + name + " " + "Badge Number: " + badgeNumber; } }
import java.text.DecimalFormat;
public class ParkingTicket { private static int count = 0; private PoliceOfficer officer; private ParkedCar car; private ParkingMeter meter; private int fine;
public ParkingTicket(PoliceOfficer officer, ParkedCar car, ParkingMeter meter) { ++count; this.officer = officer; this.car = car; this.meter = meter; int hoursOver = (int)Math.ceil((car.getMinutesParked() - meter.getMinutesPurchased())/60.0); fine = 25 + 10*(hoursOver-1); }
public String toString() { DecimalFormat df = new DecimalFormat("$###.00"); return "Parking Ticket #" + count + " " + car + " " + meter + " Fine: " + df.format(fine) + " " + officer; } }
public class ParkingSimulator { public static void main(String [] args) { ParkedCar car = new ParkedCar("Ferrari","F50","Red","Too Fast",60); ParkingMeter meter = new ParkingMeter(100); PoliceOfficer officer = new PoliceOfficer("Mary MeterReader","ABC123"); ParkingTicket ticket = officer.patrol(car,meter); if (ticket != null) { System.out.println(ticket + " "); } else { System.out.println("No ticket! "); } ParkedCar car2 = new ParkedCar("Tesla","Roadster","Blue","What Gas",75); ParkingMeter meter2 = new ParkingMeter(60); PoliceOfficer officer2 = new PoliceOfficer("Peter MeterReader","XYZ789"); ParkingTicket ticket2 = officer2.patrol(car2,meter2); if (ticket2 != null) { System.out.println(ticket2); } else { System.out.println("No ticket!"); } } }
The document i want my program to get the information from is the following:
Its called: car.txt
looks like this:
Chevrolet | Camaro | RV946 | 83 | 120 |
Kia | Soul | QY229 | 72 | 196 |
Toyota | Camry | PM506 | 50 | 126 |
Ford | Focus | FC938 | 112 | 91 |
Ford | Explorer | BA916 | 36 | 171 |
Ford | Everest | UQ848 | 57 | 195 |
Kia | Sorrento | BW108 | 55 | 108 |
Toyota | Corolla | PD527 | 103 | 107 |
Toyota | Rav4 | XS146 | 68 | 175 |
Toyota | Yaris | FY445 | 103 | 121 |
Chevrolet | Spark | QU405 | 87 | 144 |
Chevrolet | Malibu | FT808 | 37 | 129 |
Kia | Optima | CV035 | 93 | 170 |
Kia | Sedona | FT949 | 67 | 144 |
Honda | Civic | QA648 | 116 | 91 |
Honda | Accord | DL815 | 93 | 119 |
Honda | CR-V | BM519 | 88 | 125 |
Mazda | MX-5 | XB118 | 31 | 143 |
Mazda | CX-5 | VB048 | 64 | 108 |
Subaru | Legacy | XD416 | 105 | 153 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started