# loop to input multiple points to calculate final distance and speed

Sunil
loop to input multiple points to calculate final distance and speed
Posted in : Java Beginners

import java.util.Scanner;

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

```public Travel()
{
time=0;
distance=0;
}

public void setTime(double t)
{
time=t;
}

public void setDistance(double d)
{
distace=d;
}

public void getTime()
{
return time;
}

public void getDistance()
{
return distance;
}

public static void main (String[] args)
{
Scanner input= new Scanner(System.in);
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;

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

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

x1=x2;
y1=y2;
s1=s2;

} while(s1!=0)
```

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

}

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. thanks...how 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
final  what does final means in "public static final void main (string args[])" ?   keyword final can be assigned only once. They cannot be modified
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
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
input
input  a java program that will exchange the last names of two students that were input by a user
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
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.in); System.out.print("Enter the value of n
loop
loop  what is the difference b/w do while,while and for loop..with example
loop
loop  i want to write my name(inder) through loop in java using star
loop
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(System.in
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
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
For loop
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
Loop
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
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
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
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
Delhi to Udaipur by road distance
Delhi to Udaipur by road distance  delhi to udaipur by road distance
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
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
final keyword
final keyword  why is final keyword used in java
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 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
Finding a Factorial using while loop
to calculate the factorial .Now use while loop and pass the condition that until...Finding a Factorial using while loop     ... the while loop. In while loop the loop will run until the condition we have given