How JustAnswer Works:

  • Ask an Expert
    Experts are full of valuable knowledge and are ready to help with any question. Credentials confirmed by a Fortune 500 verification firm.
  • Get a Professional Answer
    Via email, text message, or notification as you wait on our site.
    Ask follow up questions if you need to.
  • 100% Satisfaction Guarantee
    Rate the answer you receive.

Ask R.R. Jha Your Own Question

R.R. Jha
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5470
Experience:  B.Tech
20870358
Type Your Homework Question Here...
R.R. Jha is online now
A new question is answered every 9 seconds

Java programming

Resolved Question:

The FAA has recently come under fire for not establishing better technologies to save the lives of passengers on flights unfortunate enough to experience mid-air collisions. These mid-air collisions are the result of distance closing faster than the airplane can be made to react. A brilliant aerospace engineer has designed a passenger jet that constantly monitors radar signatures for input. It calculates the distance between the plane and any other objects within the plane's area of concern up to 3 miles away. Though the plane is agile, it has a threshold of a 10s reaction time. That is to say, the plane can be made to safely avert an object it's headed for collision with so long as it has at least 10s to react. If the pilot has not reacted within 20s the system begins to prepare itself to react on behalf of the pilot. If the plane cannot react by averting disaster, it will eject all 400 passengers from their seats in a safe "cocoon-like" pod that drifts to the earth below using parachutes. That is to say, if for some reason the time to react, based on the plane's speed and object's speed is too short to avert a collision, the plane will launch an escape sequence to save the passengers. Your job is to 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. I need help doing the psuedocode, flowchart and the source code to create this program. I have tried to do them and am getting it wrong. Please help.

Submitted: 1 year ago.
Category: Homework
Expert:  R.R. Jha replied 1 year ago.
Hello!
Welcome!

I'm RRJha and I'd be glad to help with your question. Which programming language does the program need to be in?
Customer: replied 1 year ago.

The langauge is Java. Thank you.

Expert:  R.R. Jha replied 1 year ago.
Alright. I can do the pseudocode and java program, but I currently don't have access to flowchart tools. Would that be alright?
Customer: replied 1 year ago.

That is quite alright. Just break the pseudocode down so that I can determine input, output, processing, decision, and any other shape that will need to be used in the flowchart.

Expert:  R.R. Jha replied 1 year ago.
Sure. I'll work over this and get back to you within an hour or so.
Customer: replied 1 year ago.

Okay, thank you. You are so kind. Laughing

Expert:  R.R. Jha replied 1 year ago.
You're welcome :)
Customer: replied 1 year ago.

Attachment: 2013-10-16_191614_buis_305_project2.pdf

I don't know if you can see this, but this is the worked out word problem in which the program will be based on.

Expert:  R.R. Jha replied 1 year ago.
Yes, got it.
Expert:  R.R. Jha replied 1 year ago.
Please download file below

https://app.box.com/s/k5i5yd7idypi4stp0pch

Let me know if any questions.

Please leave a rating.

If you need help with any other problems, just add 'For RRJha' at the start of your question and I'll get back to you.

Thanks
R.R. Jha, Tutor
Category: Homework
Satisfied Customers: 5470
Experience: B.Tech
R.R. Jha and 9 other Homework Specialists are ready to help you
Customer: replied 1 year ago.

Do I add the speed of the plane and the other coordinates in the source code?

Expert:  R.R. Jha replied 1 year ago.
I also sent Java source code of the program in the zip file. We add speed of the plane and speed of object.
Customer: replied 1 year ago.

Are you saying that it is already done? Do I have to do anything else with this code? Do I need to enter something here

System.out.print("Enter distance of nearest object: ");

Expert:  R.R. Jha replied 1 year ago.
Program is complete and ready.
You need to enter those values when you compile and run the program. If you've java installed on your system, open command prompt and change directory to where .java file is located. Then type

javac PlaneCollision.java

then type

java PlaneCollision

to run the program.
Customer: replied 1 year ago.

Okay, I'll use IDEone.com to see if it compiles. Thank you.

Customer: replied 1 year ago.

One other question....when compiling, please show me where to put the coordinates and how it should look. Example:


 


System.out.print("Enter distance of nearest object: "); Does it go between the quotations and does the semicolon stay there?


 


How should it look if I enter it correctly?

Expert:  R.R. Jha replied 1 year ago.
Here is sample run of the program

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here

Attachments are only available to registered users.

Register Here
View Full Image

Attachments are only available to registered users.

Register Here


It asked 'Enter distance of object: and I entered 100
Then it asked "Enter speed of the plane: and I entered 5
Then it asked "Enter speed of the object: and I entered 2
Then program outputs "Avert object"

There is also a second run of program where program outputs to eject passengers.
Customer: replied 1 year ago.

Okay, I am not getting it to compile for some reason. This is the code I am using. If there is error here, please tell me where to correct it. Thanks.


 


 


import java.util.Scanner;

public class PlaneCollision {

public static void main(String[] args) {

double distance, planeSpeed, objectSpeed;
double timeToCollision;

Scanner input = new Scanner(System.in);
System.out.print:100;
distance = input.nextDouble();
System.out.print:3;
planeSpeed = input.nextDouble();
System.out.print:2;
objectSpeed = input.nextDouble();

timeToCollision = distance / (planeSpeed + objectSpeed);

if (timeToCollision >= 10) {
System.out.println("\nAvert object!");
} else {
System.out.println("\nEject passengers!");
}
}
}

Expert:  R.R. Jha replied 1 year ago.
How are you compiling it? System.out.print statements aren't in right syntax.
Customer: replied 1 year ago.

Actually, I am using and online java environment to try to compile that is called IDEone.com. What is the right syntax?

Customer: replied 1 year ago.

If you go to IDEone.com. You can test and run your programs there. That is what I am using. So, if it won't compile because of what I have posted, please tell me how to fix it. Do I need to pay more or something?

Expert:  R.R. Jha replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Customer: replied 1 year ago.

I am getting error. Below is the code I used per your instruction:


 


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* 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;

Scanner input = new Scanner(System.in);
System.out.print("Enter distance of nearest object: ");
distance = input.nextDouble(100);
System.out.print("Enter speed of the plane: ");
planeSpeed = input.nextDouble(5);
System.out.print("Enter speed of the object: ");
objectSpeed = input.nextDouble(2);

timeToCollision = distance / (planeSpeed + objectSpeed);

if (timeToCollision >= 10) {
System.out.println("\nAvert object!");
} else {
System.out.println("\nEject passengers!");
}
}
}


 


 


Here is the error messages I am getting on IDEone.com


 


Compilation error
Standard input is empty
Compilation info
Main.java:17: error: method nextDouble in class Scanner cannot be applied to given types; distance = input.nextDouble(100);

required:
no arguments found: int reason: actual and formal argument lists differ in length Main.java:19: error: method nextDouble in class Scanner cannot be applied to given types; planeSpeed = input.nextDouble(5);

required:
no arguments found: int reason: actual and formal argument lists differ in length Main.java:21: error: method nextDouble in class Scanner cannot be applied to given types; objectSpeed = input.nextDouble(2);


required:



no arguments found: int reason: actual and formal argument lists differ in length 3 errors


 


stdout



Expert:  R.R. Jha replied 1 year ago.
You're again using wrong syntax. Please copy and paste the code I sent in previous post. In my code, it was

distance = input.nextDouble()

while your code is having

distance = input.nextDouble(100)

Please use what I sent and after pasting, in input (stdin) box just below main code, enter 100 5 2
Customer: replied 1 year ago.

Okay, I did it, but still get error. I know this is getting frustrating, However, if you go test it yourself on IDEone,come, you will see what I am talking about.


Again, this is what I believe you just said to do. This is the code.


 


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
public static void main (String[] args) throws java.lang.Exception
{
import java.util.Scanner;

public class PlaneCollision {

public static void main(String[] args) {

double distance, planeSpeed, objectSpeed;
double timeToCollision;

Scanner input = new Scanner(System.in);
System.out.print("Enter distance of nearest object: ");
distance = input.nextDouble(100);
System.out.print("Enter speed of the plane: ");
planeSpeed = input.nextDouble(5);
System.out.print("Enter speed of the object: ");
objectSpeed = input.nextDouble(2);

timeToCollision = distance / (planeSpeed + objectSpeed);

if (timeToCollision >= 10) {
System.out.println("\nAvert object!");
} else {
System.out.println("\nEject passengers!");
}
}
}




 


Here is the error message:


 


Compilation error


 


stdin

 


compilation info

Main.java:12: error: illegal start of expression import java.util.Scanner; ^

Main.java:12: error: not a statement import java.util.Scanner; ^

Main.java:14: error: illegal start of expression public class PlaneCollision

{ ^ Main.java:37: error: reached end of file while parsing } ^ 4 errors
Expert:  R.R. Jha replied 1 year ago.
I meant to copy paste the code I sent in previous post, not the code I sent in PlaneCollision.java file. And don't forget that in input (stdin) box just below main code, enter 100 5 2
Customer: replied 1 year ago.

Okay, I went back and copied the code in the prior message and there was still one error which is below which is this:


 


 


 


/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* 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;

Scanner input = new Scanner(System.in);
System.out.print("Enter distance of nearest object: ");
distance = input.nextDouble(100);
System.out.print("Enter speed of the plane: ");
planeSpeed = input.nextDouble(5);
System.out.print("Enter speed of the object: ");
objectSpeed = input.nextDouble(2);

timeToCollision = distance / (planeSpeed + objectSpeed);

if (timeToCollision >= 10) {
System.out.println("\nAvert object!");
} else {
System.out.println("\nEject passengers!");
}
}
}


 


 


The errors again are below:


 


Compilation error

stdin
Standard input is empty


 


compilation info

Main.java:17: error: method nextDouble in class Scanner cannot be applied to given types; distance = input.nextDouble(100);

^ required:

no arguments found: int reason: actual and formal argument lists differ in length Main.java:19: error: method nextDouble in class Scanner cannot be applied to given types; planeSpeed = input.nextDouble(5);

^ required:

no arguments found: int reason: actual and formal argument lists differ in length Main.java:21: error: method nextDouble in class Scanner cannot be applied to given types; objectSpeed = input.nextDouble(2);

^ required:

no arguments found: int reason: actual and formal argument lists differ in length 3 errors
Expert:  R.R. Jha replied 1 year ago.
You're again making the same mistake. input.nextDouble(100) while there should be no 100.

Here is the working program in Ideone

http://ideone.com/TMKI0j
Customer: replied 1 year ago.

I dont get it, I copied the same code from your working one, and still get errors. I didn't change anything at all. I just copied it and pasted it. So I should have gotten the same results that you did. This is bazaar.

Customer: replied 1 year ago.

I just tried another engine to execute the program, and the error I get with this other one is below.


 


Error - At least one public class is required in main file

Expert:  R.R. Jha replied 1 year ago.
Online engines aren't ideal for use. Going back, where did you get the line in bold

System.out.print("Enter distance of nearest object: ");
distance = input.nextDouble(100);
System.out.print("Enter speed of the plane: ");
planeSpeed = input.nextDouble(5);
System.out.print("Enter speed of the object: ");
objectSpeed = input.nextDouble(2);

I've always sent you

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();

You notice the difference? I'm not using anything inside the parenthesis. That's where you got error.

I hope that helps as I've working for more than a couple of hours on your issue.
Customer: replied 1 year ago.

Okay again. Here is the code that you showed me that worked: This is what I copied and pasted:


 




  1. /* package whatever; // don't place package name! */






  2. import java.util.*;



  3. import java.lang.*;



  4. import java.io.*;






  5. /* Name of the class has to be "Main" only if the class is public. */



  6. class Ideone



  7. {



  8. public static void main (String[] args) throws java.lang.Exception



  9. {



  10. double distance, planeSpeed, objectSpeed;



  11. double timeToCollision;






  12. Scanner input = new Scanner(System.in);



  13. System.out.print("Enter distance of nearest object: ");



  14. distance = input.nextDouble();



  15. System.out.print("Enter speed of the plane: ");



  16. planeSpeed = input.nextDouble();



  17. System.out.print("Enter speed of the object: ");



  18. objectSpeed = input.nextDouble();






  19. timeToCollision = distance / (planeSpeed + objectSpeed);






  20. if (timeToCollision >= 10) {



  21. System.out.println("\nAvert object!");



  22. } else {



  23. System.out.println("\nEject passengers!");



  24. }






  25. }



  26. }



 


 


As you can see, there are no characters in the brackets.


 


 


Here is the error message.


 


stdin
Standard input is empty


stdout
Enter distance of nearest object:

stderr


Exception in thread

"main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Scanner.java:907) at java.util.Scanner.next(Scanner.java:1530) at java.util.Scanner.nextDouble(Scanner.java:2456) at Ideone.main(Main.java:17)

Customer: replied 1 year ago.
Relist: Inaccurate answer.
I need for someone to be more complete with the solution, and clear on the issue. I feel as though I am getting the run around here.
Expert:  R.R. Jha replied 1 year ago.
Because this time you forgot to enter the input. In input (stdin) box below main code, type 100 5 2
Customer: replied 1 year ago.

You said not to put 100: Your response below:


 


System.out.print("Enter distance of nearest object: ");
distance = input.nextDouble(100);
System.out.print("Enter speed of the plane: ");
planeSpeed = input.nextDouble(5);
System.out.print("Enter speed of the object: ");
objectSpeed = input.nextDouble(2);

I've always sent you

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();





So if I am to put 100, 5 and 2 where do I put it. Your confusing me because you just said that I was making the same mistake by putting the 100 and now your saying that I need to put it. If so, show me exactly where. Am, I missing something. Sorry for the lack of understanding

Expert:  R.R. Jha replied 1 year ago.
THIS ANSWER IS LOCKED!
You can view this answer by clicking here to Register or Login and paying $3.
If you've already paid for this answer, simply Login.
Customer: replied 1 year ago.

Phew thank you, it worked.

Expert:  R.R. Jha replied 1 year ago.
You're welcome!
Bonus is appreciated. Option to add bonus would be where you left the rating for the answer. Somewhere around top of this page.

Thanks
Customer: replied 1 year ago.

Okay. I'll look for it.

JustAnswer in the News:

 
 
 
Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.
JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.
Web sites like justanswer.com/legal
...leave nothing to chance.
Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.
Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.
I will tell you that...the things you have to go through to be an Expert are quite rigorous.
 
 
 

What Customers are Saying:

 
 
 
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
< Last | Next >
  • Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help. Mary C. Freshfield, Liverpool, UK
  • This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!! Alex Los Angeles, CA
  • Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult. GP Hesperia, CA
  • I couldn't be more satisfied! This is the site I will always come to when I need a second opinion. Justin Kernersville, NC
  • Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around. Esther Woodstock, NY
  • Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know. Robin Elkton, Maryland
  • He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here. Diane Dallas, TX
 
 
 

Meet The Experts:

 
 
 
  • Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4522
    More than 5000 online tutoring sessions.
< Last | Next >
  • http://ww2.justanswer.com/uploads/BU/BusinessTutor/2012-2-2_115741_Kouki2.64x64.jpg Manal Elkhoshkhany's Avatar

    Manal Elkhoshkhany

    Tutor

    Satisfied Customers:

    4522
    More than 5000 online tutoring sessions.
  • http://ww2.justanswer.com/uploads/ComputersGuru/2010-02-13_051118_Photo41.JPG LogicPro's Avatar

    LogicPro

    Engineer

    Satisfied Customers:

    3458
    Expert in Java C++ C C# VB Javascript Design SQL HTML
  • http://ww2.justanswer.com/uploads/LI/lindaus/2012-6-10_04811_IMG20120609164157.64x64.jpg Linda_us's Avatar

    Linda_us

    Finance, Accounts & Homework Tutor

    Satisfied Customers:

    3124
    Post Graduate Diploma in Management (MBA)
  • http://ww2.justanswer.com/uploads/chooser77/2009-08-18_162025_Chris.jpg Chris M.'s Avatar

    Chris M.

    M.S.W. Social Work

    Satisfied Customers:

    2385
    Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)
  • http://ww2.justanswer.com/uploads/JawaadAhmed/2009-6-27_12137_SIs_SHadi.jpg F. Naz's Avatar

    F. Naz

    Chartered Accountant

    Satisfied Customers:

    1988
    Experience with chartered accountancy
  • http://ww2.justanswer.com/uploads/JK/jkcpa/2011-1-16_182614_jkcpa.64x64.jpg Bizhelp's Avatar

    Bizhelp

    CPA

    Satisfied Customers:

    1876
    Bachelors Degree and CPA with Accounting work experience
  • http://ww2.justanswer.com/uploads/avremote/photoa.jpg Seanna's Avatar

    Seanna

    Tutor

    Satisfied Customers:

    1781
    3,000+ satisfied customers, all topics, A+ work
 
 
 

Related Homework Questions

Chat Now With A Tutor
R.R. Jha
R.R. Jha
Tutor
5470 Satisfied Customers
B.Tech