Find Jobs
Hire Freelancers

Rail Java program

$10-30 USD

Completed
Posted about 8 years ago

$10-30 USD

Paid on delivery
In this project, you will be implementing a rail road yard simulation program. The user will provide a set of incoming cars, and then a desired outgoing order. Your program will determine if the given incoming cars can be rearranged to the desired outgoing order or not. Background: This is an example of a control/management system: in order to deliver specific resources to specific destinations, we have to guarantee that those resources are available at their destinations. Consider: the easiest car to distinct from a train transporting materials is the back most one. Thus, it would ideal to arrange the train's cars in such a way that the order of destinations visited, matches the order of the cars. If the required car is in the middle of the train, there will be trouble! Our goal is to address this by trying to arrange the cars into the order of the destinations they will visit ("desired outgoing order"). Problem: Imagine that the rail yard looks like this: Incoming cars Outgoing cars (based on destination order) >-----------------------------------------------------------------------------------> A B C D E E D C B A >-----------------------------\ /-----------------------------------> \ / | | | | | | | | -------- Waiting Line In this example, the incoming cars come in the order E, D, C, B and A. The desired outgoing order (since the track moves only to the right) is A, B, C, D and E. Our program considers the first incoming car, vs the desired outgoing car. Since E != A, E must go into the waiting line. Now our program will consider both the car at the top of the waiting line (since it is blocking all the others cars) as well as the incoming car each time. Again, E != A but also D != A, so D gets put in the waiting line, blocking E in the process. This will continue until A is the only car left in the incoming line, and it will be sent out. This leaves nothing incoming, but B would be the top car in the waiting line. Since B == B, B gets taken from the waiting line and sent out. This will repeat until all cars are gone, meaning the input was successfully matched to the output. An example that does NOT match is UGTA to UTGA. A, T and G would go into the waiting line. U would be sent out, but then the next required outgoing car is T. There would be nothing left in the incoming line, and the top car in the waiting line would be G. So, the match fails. Program Features: You must take in incoming cars from the user until they input "DONE". You must take in outgoing cars from the user until they have given as many cars as they did in step 1. You must print out whether or not the given input cars can be matched to the given output. Requirements and Notes: You must implement your own linked structure(s) for this. In addition, you may not import anything other than Scanner. You may not ask the user to specify the number of cars ahead of time. The user must provide at least one incoming car. Print a message if they don't and then allow the user to type in incoming cars again. "Cars" is a loose term. The user should be allowed to type in anything as a car. An example of three incoming cars might be: A, honda, 10101 You may not reorder the incoming, outgoing or waiting line. Cars cannot go from the waiting line back to the incoming line.
Project ID: 9741977

About the project

3 proposals
Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
Awarded to:
User Avatar
$26 USD in 2 days
4.9 (379 reviews)
6.2
6.2
3 freelancers are bidding on average $33 USD for this job
User Avatar
Hello. How are u. I saw your description . I understood it and can do it well. I have done several project like this. I'm an expert in Data Structures and Algorithms. And I know Java ,C/C++,C# and Python well. I'm interested this project. I want to discuss with you about this project. If it's possible,please contact me and explain more detail. I wait your good reply. Bye.
$49 USD in 1 day
5.0 (3 reviews)
3.1
3.1

About the client

Flag of UNITED STATES
Boca Raton, United States
5.0
2
Payment method verified
Member since Apr 16, 2015

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.