Question

In: Computer Science

Given the following: - One bus can carry 20 passengers. - One car can carry 2...

Given the following:

- One bus can carry 20 passengers.

- One car can carry 2 passengers.

Provide an application using PHP that calculates the number of buses and cars needed based on a number of passengers entered. You need to also calculate how many passengers will be left after all the full vehicles are determined.

Solutions

Expert Solution

PHP file :

<!DOCTYPE html>

<html lang="en">

    <head>

        <!-- title for web page -->

        <title>passengers</title>

        <meta charset="UTF-8">

        <meta name="viewport" content="width=device-width, initial-scale=1">

    </head>

    <body>

        <!-- html form -->

        <form action="passengers.php" method="post">

    Enter number of passengers :

    <!-- textbox for passengers -->

    <input type="text" name="numberOfPassengers"/>

    <br><br>

    <!-- butoon to submit form  -->

    <input type="submit" name="btnSubmit"/>

    </form>

    <?php

        if(isset($_POST['btnSubmit']))

        {

            //taking number of passengers entered by user

            $numberOfPassengers=$_POST['numberOfPassengers'];

            //display passengers

            echo "<h3>Number of Passengers : ".$numberOfPassengers."</h3></br>";

            //checking buses required

            echo "<p>Number of buses required : ".floor($numberOfPassengers/20)."</p>";

            echo "<p>Number of passengers left : ".($numberOfPassengers%20)."</p>";

             //checking cars required

             echo "<p>Number of cars required : ".floor($numberOfPassengers/2)."</p>";

             echo "<p>Number of passengers left : ".($numberOfPassengers%2)."</p>";

        }

?>

    </body>

</html>

==================================

Output :


Related Solutions

Question 2 Suppose the waiting time of a bus follows a uniform distribution on [0, 20]....
Question 2 Suppose the waiting time of a bus follows a uniform distribution on [0, 20]. (a) Find the probability that a passenger has to wait for at least 12 minutes. (b) Find the mean and interquantile range of the waiting time. Question 3 Each year, a large warehouse uses thousands of fluorescent light bulbs that are burning 24 hours per day until they burn out and are replaced. The lifetime of the bulbs, X, is a normally distributed random...
An airline company operates commuter flights using an aircraft that can take 20 passengers. During each...
An airline company operates commuter flights using an aircraft that can take 20 passengers. During each flight passengers are given a hot drink and a Snack Pack that contains a meat sandwich and a cake. The company is aware that some of their passengers may be vegetarians and therefore every flight should be stocked with vegetarian Snack Pack that contains a cheese sandwich in addition to those contain meat. Given that 5% of the population is vegetarian, on a fully...
An airport limousine can accommodate up to four passengers on any one trip. The company will...
An airport limousine can accommodate up to four passengers on any one trip. The company will accept a maximum of six reservations for a trip, and a passenger must have a reservation. From previous records, 40% of all those making reservations do not appear for the trip. Answer the following questions, assuming independence wherever appropriate. (Round your answers to three decimal places.) (c) Suppose the probability distribution of the number of reservations made is given in the accompanying table. Number...
An airport limousine can accommodate up to 4 passengers on any one trip. The company will...
An airport limousine can accommodate up to 4 passengers on any one trip. The company will accept a maximum of 6 reservations for a trip, and a passenger must have a reservation. From previous records, 20% of all those making reservations do not show up for the trip. Answer the following questions assuming independence wherever appropriate. A) Assume that six reservations are made. Let X = the number of customers who have made a reservation and show up for the...
An airport limousine can accommodate up to four passengers on any one trip. The company will...
An airport limousine can accommodate up to four passengers on any one trip. The company will accept a maximum of six reservations for a trip, and a passenger must have a reservation. From previous records, 35% of all those making reservations do not appear for the trip. Answer the following questions, assuming independence wherever appropriate. (Round your answers to three decimal places.) (b) If six reservations are made, what is the expected number of available places when the limousine departs?...
An airport limousine can accommodate up to four passengers on any one trip. The company will...
An airport limousine can accommodate up to four passengers on any one trip. The company will accept a maximum of six reservations for a trip, and a passenger must have a reservation. From previous records, 50% of all those making reservations do not appear for the trip. Answer the following questions, assuming independence wherever appropriate. (Round your answers to three decimal places.) (a) If six reservations are made, what is the probability that at least one individual with a reservation...
Given the following rational function:             F(X) = (2X^2 - 20) / [( X - 5 )^2]...
Given the following rational function:             F(X) = (2X^2 - 20) / [( X - 5 )^2] Find all horizontal and vertical asymptotes Find the first derivative of F(X) and simplify Find the critical values for X and determine if they are at a maximum or minimum, using the First Derivative Sign Test. Find the Second Derivative and Use it to confirm your answers to part c. You may keep the 2nd derivative in “rough” form and simply substitute in the...
Given 2 trains per hour and passengers arrive according to a triangular distribution of waiting times...
Given 2 trains per hour and passengers arrive according to a triangular distribution of waiting times with mode of 5 minutes. a) What is the expected wait time? b) What is the probability that a random passenger will wait less than 5 minutes? C) What is the probability that a random passenger will wait less than 10 minutes? please show steps for the solution.
The number of buses that arrive at a bus stop during a one-hour time span can...
The number of buses that arrive at a bus stop during a one-hour time span can be modeled as a Poisson process with rate λ (see Remark below). Now suppose a passenger has just arrived at the bus stop and starts waiting. Let Y be the time (in unit of hours) she needs to wait to see the first bus. (a) Is Y a discrete or continuous random variable? Find the set of all possible values of Y . (b)...
A car can be produced by 20 workers in the United States, and by 10 workers...
A car can be produced by 20 workers in the United States, and by 10 workers in Germany. 1,000 chickens can be produced by 25 workers in the United States, and by 20 workers in Germany. a) Using charts, show how a shift of workers toward one of the two industries in the United States, coupled with a shift of workers toward the other in Germany, could result in increased total production of both goods in the two countries. (d)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT