Plane Collision Program

Plane Collision Program

<p>Plane Collision Program Object Oriented Programming Assignment: Project #1 BUIS 305-101</p><p>October 16, 2013</p><p>Group Members:</p><p>Carmara Royster Malik Petersen Charles Abegbesan Raven Anderson Carmara Royster, Malik Petersen, Charles Abegbesan, Ravan Anderson October 16, 2013 OOP - 305 Project #1</p><p>Write a program that receives distance and speed values for the plane and the closest moving object to the plane. The program must calculate the time to impact. If the time to impact, based on the parameters above, is less that 10s then the program will signal the plane to launch the passengers to safety.</p><p>Pseudo code:</p><p>Declare distance As double, planeSpeed As double, objectSpeed As double</p><p>Declare timeToCollision As double</p><p>INPUT distance</p><p>INPUT planeSpeed</p><p>INPUT objectSpeed</p><p>SET timeToCollision = distance / (planeSpeed + objectSpeed)</p><p>IF timeToCollision >= 10 </p><p>OUTPUT “Safely averting the object” ELSE</p><p>OUTPUT “Ejecting passengers to safety” END IF Flow Chart:</p><p>Start</p><p>Distance As double, planeSpeed as double, objectSpeed as double</p><p> timeToCollision As double</p><p> timeToCollision = distance / {planeSpeed + objectSpeed}</p><p> if {timeToCollision >= 10</p><p>System.out.println("\nAvert object!"); System.out.println("\nEject passengers!");</p><p>End</p><p>Source Code:</p><p>/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*;</p><p>/* Name of the class has to be "Main" only if the class is public. */ class Ideone { public static void main (String[] args) throws java.lang.Exception { double distance, planeSpeed, objectSpeed; double timeToCollision;</p><p>Scanner input = new Scanner(System.in); System.out.print("Enter distance of nearest object: "); distance = input.nextDouble(); System.out.print("Enter speed of the plane: "); planeSpeed = input.nextDouble(); System.out.print("Enter speed of the object: "); objectSpeed = input.nextDouble(); //declarations above accounts for the two objects, the distance between, and the speed of both timeToCollision = distance / (planeSpeed + objectSpeed); //Input is plane speed + object speed / distance if (timeToCollision >= 10) { System.out.println("\nAvert object!"); //If the time remaining before a collision is less than 10 seconds, then the plane will not eject the passengers } else { System.out.println("\nEject passengers!"); //Else if the plane is equal to 10 seconds, it will eject the passengers }</p><p>} }</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    5 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us