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

NOTE: ITS A PROGRAMMING SOLVING QUESTION SO HAVE TO DO IT BY C LANGUAGE. MAKE SU

ID: 3600271 • Letter: N

Question

NOTE: ITS A PROGRAMMING SOLVING QUESTION SO HAVE TO DO IT BY C LANGUAGE. MAKE SURE UPLOAD THE PROGRAM OUTPUT AS WELL.

3. An old bridge has only one lane and can only hold at most 3 cars at a time without risking collapse. Write a pthreads program that controls traffic so that at any given time, there are at most 3 cars on the bridge, and all of them are going the same direction. A car calls ArriveBridge when it arrives at the bridge and wants to go in the specified direction (0 or 1); ArriveBridge should not return until the car is allowed to get on the bridge. A car calls ExitBridge when it gets off the bridge, potentially allowing other cars to get on. Don't worry about starving cars trying to go in one direction; just make sure cars are always on the bridge when they can be. To assist your programming here are some suggestions Treat each car as a thread. When a car is on the bridge you can put the thread to sleep for a fixed amount of time (same time for all cars) to simulate the time for a car to drive across * Your program outputs the direction that traffic is moving on the bridge and the driver as each car enters the bridge

Explanation / Answer

import java.io.File; importjava.io.IOException; public class RenameFile { public static void main(String[] args) { try // Here F is the object of the Existing file named with Includehelp which is to be renamed. // { File F=new File("f:/Includehelp.txt"); // Here T is the object of the renamed file of Includehelp which is Include.txt. // File T=new File ("f:/Include.txt"); // Rename the file Includehelp.txt into Include.txt. // F.renameTo(T); // Print the result if file renamed. // System.out.println("File Rename Successfully..."); } // If any error occurs while renaming the file. // catch(Exception e) { System.out.println(e); } } }