Create an All-in-One sticky form to solve the common “two trains are moving toward each other” word problem. The form should have three inputs, all numbers greater than 0: the speed of Train A ($SpeedA), the speed of Train B ($SpeedB), and the distance between the two trains ($Distance). For this problem, you will need the following equations:
$DistanceA = (($SpeedA / $SpeedB) * $Distance) / (1 + ($SpeedA / $SpeedB));
$DistanceB = $Distance - $DistanceA;
$TimeA = $DistanceA / $SpeedA;
$TimeB = $DistanceB / $SpeedB;
In the preceding equations, $DistanceA and $DistanceB are the distances traveled by Trains A and B, respectively; $TimeA and $TimeB are how long Trains A and B traveled, respectively ($TimeA should equal $TimeB). If $SpeedA or $SpeedB is allowed to be 0, PHP will display a “division by zero not allowed” error. Save the document as TwoTrains.php
PHP PROGRAMMING SOURCE CODE
<html>
<body>
<form method="post">
<!-- Speed of train A in first textbox as input -->
Speed of Train A:
<input type="number" name="number1"
/><br><br>
<!-- Speed of train B in second textbox as input -->
Speed of Train B:
<input type="number" name="number2"
/><br><br>
<!-- Distance between train A and train B in third textbox as
input -->
Distance between the two trains(A,B):
<input type="number" name="number3"
/><br><br>
<!-- submit button to calculate results -->
<input type="submit" name="submit" value="Calculate">
</form>
<?php
// if submit button is pressed //
if(isset($_POST['submit']))
{
try
{
// take three
inputs in three variables//
$SpeedA = $_POST['number1'];
$SpeedB = $_POST['number2'];
$Distance=$_POST['number3'];
//if speed of train A or B is
zero,it will throw exception //
if($SpeedA==0 or $SpeedB==0 )
{
throw new Exception("division by zero not allowed");
}
// calculation the results from
given equations //
$DistanceA = (($SpeedA / $SpeedB) * $Distance) / (1 + ($SpeedA /
$SpeedB));
$DistanceB = $Distance - $DistanceA;
$TimeA = $DistanceA / $SpeedA;
$TimeB = $DistanceB / $SpeedB;
// print the results //
// here with number_format() method
results are considered up to 2 decimal place//
echo "The distance traveled by Train A :
".number_format($DistanceA,2);
echo "<br>";
echo "The distance traveled by Train B :
".number_format($DistanceB,2);
echo "<br>";
echo "The time taken by Train A : ".number_format($TimeA,2);
echo "<br>";
echo "The time taken by Train B : ".number_format($TimeB,2);
}
// thrown error details is
displayed through message//
catch(Exception $e) {
echo $e->getMessage();
}
}
?>
</body>
</html>
SCREEN SHOT


OUTPUT











Create an All-in-One sticky form to solve the common “two trains are moving toward each other”...
Problem 7 A satellite consists two cylinders which can rotate relative to each other about the common axis of summetry. The rotation can be precisely controlled through a built-in motor. Both cyllinders can be asuumed to be uniform; they have the same mass, m 10.0 kg, and the same radius 0.30 m. The top cylinder has attached to it two balls, each of which has mass 1.0kg and radius b 0.1 m. Each ball is fastened to the end of...
8.4 The Two-Dimensional Central-Force Problem The 2D harmonic oscillator is a 2D central force problem (as discussed in TZD Many physical systems involve a particle that moves under the influence of a central force; that is, a force that always points exactly toward, or away from, a force center O. In classical mechanics a famous example of a central force is the force of the sun on a planet. In atomic physics the most obvious example is the hydrogen atom,...
solve no: 3.14 , 3.16, 3.19
please show each step and solve for beginners
120 Power System Analysis 3.12. A single-phase system similar to that shown in Figure 3.11 has two transformers A-B a B-C connected by a line B feeding a load at the receiving end C. The ratings and parame ter values of the components are 500 V/1.5 kV, 9.6 kVA. leakage reactance 5 % 1.2 kV/120 V, 7.2 kVA, leakage reactance 4 % series impedance (0.5 +...
Yes, this is one problem. Please solve ALL PARTS. Guaranteed
thumbs up for the person who solves it.
3 1. Photodiode amplifier circuit You are designinga CF photosensor circuit for a light detection and ranging LiDAR) system in autonomous vehicles. The circuit utilizes a transimpedance amplifier to convert low-level RF photodiode current signal to a usable voltage output. It consists of a photodiode, an amplifier, and feedback capacitor/resistor pair as shown in Figure 1. We will derive simple equations to...
CSC 142
Music Player
You will complete this project by implementing one class.
Afterwards, your program will play music from a text file.
Objectives
Working with lists
Background
This project addresses playing music. A song consists of notes,
each of which has a length (duration) and pitch. The pitch of a
note is described with a letter ranging from A to G. 7
notes is not enough to play very interesting music, so there are
multiple octaves; after we reach...
The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use the following libraries: #include <math.h> #include <stdlib.h> #include <string.h> #include <limits.h> and any .graphics and .timers libraries. The guidelines are outlined as follows: Terminal Set-up: you may assume that the terminal will be quite large, for example, on the order of 150×50, or more. Status Display: The...
The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use the following libraries: #include <math.h> #include <stdlib.h> #include <string.h> #include <limits.h> and any .graphics and .timers libraries. The guidelines are outlined as follows: Terminal Set-up: you may assume that the terminal will be quite large, for example, on the order of 150×50, or more. Status Display: The...
What an Executive Summary Is
An executive summary is a specific type of document that does
two things: it summarizes a research article, and it offers
recommendations as to how information from the article can be
used.
Some long reports can contain an executive summary section, as
indicated in the Pearson handbook.
Write a 2 pahe Executive Summary
In business contexts, an executive summary is always written
for a specific purpose: to explain the information in the article
to a...
How can we assess whether a project is a success or a
failure?
This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...