java code 8 of 1

Ads

 
 
 

Share on Google+Share on Google+

arvind
java code 8 of 1
1 Answer(s)      6 years and 5 months ago
Posted in : JavaScript Questions

Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time, and the Pythagorean Theorem is c2 = a2 + b2.

Ads
View Answers

December 22, 2010 at 3:15 PM


Hi Friend,

Try the following code:

import java.util.*;
import java.text.*;

class DistanceTravelledbyBoat{

public static void main(String[] args){
DecimalFormat df = new DecimalFormat("##.00");
Scanner input=new Scanner(System.in);
System.out.print("Enter width of river: ");
double width=input.nextDouble();
System.out.print("Enter boat's speed perpendicular to river: ");
double boatspeed=input.nextDouble();
System.out.print("Enter river's speed: ");
double riverspeed=input.nextDouble();
double a=width;
double bs=boatspeed;
double c=0;
double t=a/bs;
double rs=riverspeed;
double b=t*rs;
double distance=c*c;
double BB=b*b;
double AA=a*a;
distance=AA+BB;
System.out.println("Distance boat travels: "+df.format(distance));
}
}

Thanks


Ads









Related Tutorials/Questions & Answers:
java code 8 of 1
java code 8 of 1  Develop a program that computes the distance a boat travels across a river, given the width of the river, the boat's speed perpendicular to the river, and the river's speed. Speed is distance/time
java code 1 of 2
java code 1 of 2  Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts the noofClothes as argument & returns the noofClothes   Hi Friend, Visit
Advertisements
java code 1 of 2
java code 1 of 2  Create a washing machine class with methods as switchOn, acceptClothes, acceptDetergent, switchOff. acceptClothes accepts... the following code: import java.util.*; class WashingMachine { Scanner input
Filter collection in Java 8
Java in it. How to filter this using the Java 8? Thanks   Hi, Example of Filter collection in Java 8 You can use the following code in Java 8...Filter collection in Java 8  Hi, I have following collection
java program 8
java program 8  Develop the program calculateHeight, which computes the height that a rocket reaches in a given amount of time. If the rocket accelerates at a constant rate g, it reaches a speed of g ? t in t time units
8 - Java Beginners
8  Unit board is PIC18F4520 Purpose of euiqpment is to make test heart beat; fast/slow/moderate heartbeat I need to activate the speaker when testing for heartbeat. Should be able to start buzzing when testing is done. Should
Building and Running Java 8 Support
Building and Running Java 8 Support  As you know Java 8 is already released and available for download. Now I am developer of Java based projects. So... and run Java 8 application in Eclipse? Thanks   Hi, don't worry
Lambda Expression in Java 8
Lambda Expression in Java 8: Learn the power of Lambda Expression... in the Java 8. This is the biggest upgrade introduced in the Java so far... Expression in Java 8? The Lambda Expression is one of most important feature added
JEE 8 - Java Enterprise Edition 8
JEE 8 - Java Enterprise Edition 8 Tutorials, Examples and latest updates... about the JEE 8: The Java Community Process (JCP) team has started the development of next generation JEE 8 Java EE 8 Takes Off
Java 8 consumer class(interface) example
How to use the Java 8 consumer class(interface)? In this example program I will show you how you can use the consumer interface of the Java 8 to iterate.... The Consumer is a functional interface added to the Java 8 which is used to assign
Learn the Java 8 and master the new features of JDK 8
JDK 8 - Java 8 Tutorial and examples: Learn JDK 8 with the help of examples... bug fixes. Here we are giving the news, articles and updates of Java 8. About Java 8 Java 8 Officially released JDK 8 Developers
task 1 - Java Beginners
task 1  Please write a Java client that send a small letters string to a Java server which convert it to uppercase letters and send it back..., Try the following code: import java.util.*; class ChangeCase{ public
How to download and install Java 8 on Windows?
How to download and install Java 8 on Windows?  I am beginner in Java going to learn and make program in Java. Is there any tutorial for setting up Java development kit? Tell me How to download and install Java 8 on Windows
problem 1 - Java Beginners
problem 1   Hi, please help me!!!! How can i code in java using Two-dimensional Arrays? This question is related to the one i posted before. this is my input data file: 88 90 94 102 111 122 134 75 77 80 86 94 103 113 80
java code7 of 1
java code7 of 1  Develop the program calculateHeight, which computes the height that a rocket reaches in a given amount of time. If the rocket accelerates at a constant rate g, it reaches a speed of g ?· t in t time units
About Java 8
of upcoming Java 8. Lambda expressions will allow code to be streamlined. When...Java 8 is slated to be released in March 2014 but the debate has already begun... for Java developers or not. This debate has made Java 8 update as the most
java program 1
java program 1  (4) WAP to take input of a String and check wheather it is valid number or not? Sample Output1: Enter a String : 10 10 is a number Sample Output2: Enter a String : 10b1 10b1 is not a number (5) WAP to take
que 1 - Java Beginners
que 1  WAP to enter a sentence & count the no. of times a particular word occurs in it.Display the frequency of the searched word. eg- input...:frequency of word-2 times   Hi Friend, Try the following code: import
java bits 8 - Java Interview Questions
java bits 8  Assume that country is set for each class. Given: 10. public class Money { 11. private String country, name; 12. public getCountry() { return country; } 13.} and: 24. class Yen extends Money { 25. public
Java EE 8 Takes Off
Finally its good news for Java developers as Java EE 8 Takes Off The future version of Java EE 8 officially launched as JSR 366 via the JCP (Java Community... to be introduced in the JEE8. The primary focus of Java EE 8 will be providing
array 1 - Java Beginners
array 1  WAP to input values in 2 arrays and merge them to array M.  Hi Friend, Try the following code: import java.util.*; class MergeArray{ public static int[] merge(int [] ... arr) { int arrSize = 0
function 1 - Java Beginners
function 1  WAP to calculate the value of x,where x=tan(A)+tan(B)/1+tan(A)*tab(B)  Give more details like how to calculate and what is tan(A) and tan(B),etc
Java programming 1 - Java Beginners
Java programming 1  write one program, which consists of a main...? There are nine words in total Java has a standard to index elements starting... be at position 1, etc ?A sentence is constructed with a series of words? Index 0 1 2 3 4
Java programming 1 - Java Beginners
Java programming 1  write one program, which consists of a main... 1 2 3 4 5 6 7 8 We need to provide a method...? There are nine words in total Java has a standard to index elements starting
Java programming 1 - Java Beginners
Java programming 1  Thx sir for reply me ^^ err how bout if using scanner class or further method to solve that code? instead of using array?  ...://www.roseindia.net/java/java-tips/examples-introductory/console/console-input
Java EE 8 Takes Off
Java EE 8 the next generation application development platform is starting... of next generation enterprise application development platform Java EE 8. JCP team is no featuring out the features to be added to the Java EE 8
Java 8: Java 8 is officially released and it can be downloaded
Java 8 officially released Java 8 is finally available for download - Download the latest Java 8 SDK and start developing next generation applications for your client. Java 8 comes with many new features including Lambda expression
Java programming 1 - Java Beginners
Java programming 1  hi there, Sir! Can u help me check where my program gone wrong? here are my coding =D, hope to get reply from u guys soon... = JOptionPane.showInputDialog(null,"Enter mark 1", "Homework 8",JOptionPane.QUESTION_MESSAGE
Java programming 1 - Java Beginners
Java programming 1  Hi sir, i facing problem in this program....   Hi friend, Please send me full code. Because your.../java/example/java/swing/ Thanks
Java programming 1 - Java Beginners
Java programming 1  thx sir for reply me..but sir can u pls simplify...; Hi friend, 1. Ask the user for their height. Convert it to a double... is the code. import javax.swing.JFrame; class BMI { public static void
Java 8 Consumer Interface with forEach Loop
How to use the Java 8 Consumer Interface with forEach Loop? In this tutorial I will explain you about the Java 8 Consumer Interface and then explain you how... you can use the Java 8 Consumer Interface and then iterate through the class
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads