Share on Google+Share on Google+

loop to input multiple points to calculate final distance and speed
0 Answer(s)      4 years and 6 months ago
Posted in : Java Beginners

import java.util.Scanner;

public class Travel { private double time;
private double distance;

public Travel() 

public void setTime(double t)

public void setDistance(double d)

public void getTime()
    return time;

public void getDistance()
    return distance;

public static void main (String[] args)
    Scanner input= new Scanner(;
    System.out.print(" Enter two doubles for points and an integer for speed");
    double x1= input.nextDouble();
    double y1= input.nextDouble();
    int s1= input.nextInt();
    int n=2;

        System.out.print(" Way point", +n);
        Scanner input= new Scanner(;
        double x2 =input.nextDouble();
        double y2=input.nextDouble);
        int s2=input.nextInt();

        double d= Math.sqrt(Math.pow(x2-x1,2)+Math.pow(y2-y1, 2);
        double t= distance/s1;


    } while(s1!=0)

System.out.println(" The total distance is", +distance); System.out.println("The total time is ", time/60, "hours ", time%60, "minutes");



View Answers

Related Tutorials/Questions & Answers:
loop to input multiple points to calculate final distance and speed
loop to input multiple points to calculate final distance and speed  ... doubles for points and an integer for speed"); double x1= input.nextDouble...; private double distance; public Travel() { time=0; distance=0
calculate reward points.
calculate reward points.  How to calculate reward points in a multiplex automation system
how to calculate max and min in the loop - Java Beginners
and min value in the loop. the input is from the user. could u teach me. to calculate max and min in the loop  thanks coz giving me..., in a loop...till the end of the array...check each values against the max
Managing Multiple User Input Data in an Array (or ArrayList)
Managing Multiple User Input Data in an Array (or ArrayList)  Hey there! I need to make a code of an employee record. Here's how it should work: (1... record alphabetically (2) If user chooses choice1, the input data is stored
class distance
class distance  class distance-integer data member km1,km2,km3,m1,m2,m3. run()-to input the two distance and add them in the third. display()-to display the total distance. display the constructor if required
final  what does final means in "public static final void main (string args[])" ?   keyword final can be assigned only once. They cannot be modified
Edit Distance
Edit Distance  I want java programming ask from user input two string and the program find the edit distance between two strings and find table and optimal solution using GUI
plotting of points inside a rectangle
plotting of points inside a rectangle  I want to plot various points inside a rectangle such that any two points are at a distance of at least 3... example ,if I have a Rectangle of 20m by 14m then one possible placement of points
single selection of chechbox among multiple selection when in a loop.
single selection of chechbox among multiple selection when in a loop. ... that when in a loop i trying to choose single checkbox among multiple checkboxes but here am getting multiple selection(previous selected item also coming again
Road distance using Java - Java Beginners
Road distance using Java  Dear All i am calculating the straight line distance between two latlong points using the simple mathematical formula... it in java // Calculate driving distance with Google Maps API
CPU fan speed - Security
CPU fan speed  Hi, my question is how can we get the cpu fan speed... of fan and temperature. Just update us if find the example to find the speed...(System.out); }}-------------But I don't know how to get the speed of fan
points being displayed in the world
points being displayed in the world  how do i display points in my world   Hi Friend, Please clarify your problem. Thanks
input  a java program that will exchange the last names of two students that were input by a user
Delhi to Udaipur by road distance
Delhi to Udaipur by road distance  delhi to udaipur by road distance
Delete points from database
Delete points from database  I have a polygon on a web page... in database. However the points are not getting deleted. I used this code..._error())); I also used: mysqlquery("DELETE FROM points WHERE ID=".$GET['ID
How to put points on a JButton
How to put points on a JButton  I wanted to ask....what am i supposed to do if i wanna set points on my JButton so as to be able to draw arcs or curves.... supposedly my button represents a tile with 2 openings and the opening
final grade
final grade  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point...? or ?Failed   C. Write a JavaScript program that would input a student
Distance in meters - Java Beginners
?s input is shown in bold. Enter a distance in meters: 500 1. Convert...Distance in meters  Write a program that asks the user to enter a distance in meters. The program will then present the following menu of selections
For Loop
For Loop  Write a program using a for loop that computes the following sum: 1/2 + 2/2 + 3/2 + 4/2 + 5/2 + ... N/2 N will be an integer limit... input=new Scanner(; System.out.print("Enter the value of n
loop  i want to write my name(inder) through loop in java using star
loop  what is the difference b/w do while,while and for loop..with example
for loop
for loop  what is for loop   Loops are used for iteration... for a number of times it is finite loop and if repetition is done infinitely it is infinite loop. Java provides several loop structures for iteration. Those
to output the following code using a loop the code is as follows with the user... { public static void main(String[] args) { Scanner input=new... static void main(String[] args) { Scanner input=new Scanner(
Distance conversion - Java Beginners
Distance conversion  Write an application that reads a distance... the distance to kilometres, feet and inches, according to the user?s selection...() for the user selection. ? Write a method to read a distance in metres from
For loop
For loop  Hi! Please explain the following loop: for(i=0;i<a[j];i++) THANX!!   Please reply as soon as possible
for loop
for loop  how to performs the for loop when 2 inputs given like displays the triangle shape and how to take initial values or declaration values plz explain in detailed ex. 1 12 123 1234
final keyword
final keyword  why is final keyword used in java
to understand a loop my quesiton are: what du i do wrong in my code since.... (made in blueJ) Class Loop public void loopUpGeneral(int start, int stop... dk  Hi, Please check the for loop once again: for (int i
Final Keyword
Final Keyword  hello, What is final?   hii In case of class if we use final then this class can not be extended or final class may not be subclassed. A final method can't be overridden when its class is inherited
final variable
final variable  Please give some easiest and understanding example program for final variable
for loop
for loop  using only two for loop how can print below numbers 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9 8 8 8 8 8 8 8 8 7 7 7 7 7 7 7 6 6 6 6 6 6 5 5 5 5
Java Spring Hibernate Struts Training What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? file location SASLError using PLAIN: not-authorized how to convert war file into .exe file using java code


Advertisement null