java code7 of 1

Ads
 

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 and a height of 1/2 * v * t where v is the speed at t.

View Answers

December 22, 2010 at 1:11 PM

Hi Friend,

Try the following code:

import java.util.*;
import java.text.*;
class CalculateHeight{
public static void main(String[] args){
DecimalFormat df = new DecimalFormat("##.00");
Scanner input=new Scanner(System.in);
System.out.print("Enter constant rate:");
double g=input.nextDouble();
System.out.print("Enter time:");
double t=input.nextDouble();
double speed=g*t;
double h=speed*t;
double height=h/2;
System.out.println("Rocket reaches at the height of: "+df.format(height)); 
}
}

Thanks

Ads









Related Tutorials/Questions & Answers:
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
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
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 noofClothes as argument & returns the noofClothes   Hi Friend, Visit
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
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, Try
WAP in java to print the series 1*2*3
WAP in java to print the series 1*2*3  WAP in java to print the series 123
Prime numbers in Java between 1 and 100
Prime numbers in Java between 1 and 100  Hi, How to display prime numbers in java between 1 and 100? Thanks   Hi, Prime numbers are the number which is divisible by itself and 1. I have provide you Java program
JAVA leftshift operator add 1 instead of 0
JAVA leftshift operator add 1 instead of 0  Hi Guys, I have a task... So, the answer will be 20. But, I want to have "1" instead of "0"s. So... this in java. Please help me asap. Thanks. Code Eater
why java ignore backspace event when there are more then 1 keychar for a single keystroke.
why java ignore backspace event when there are more then 1 keychar for a single keystroke.  why java ignore backspace event when there are more then 1 keychar for a single keystroke. Assume that i have a text field to get
contructors 1&test
contructors 1&test   how do i Create a class named Box that includes... the 'XXX' with the value of length using the Java keyword this in your code. ??h... to replace the 'XXX' with the values of length and width using the Java keyword
Tags in struts 1
Tags in struts 1   I have problem in Include tag in Struts this tag using but it is not work Please Explain
Ajax Question 1
Ajax Question 1  I am having 3 fields in jsp they are Fieldname,Fieldtype,Required. If i enter Fieldname as studentid,Fieldtype as checkbox,Required as true(i.e., mandatory field as *).It should store their details in database
New Page 1
JavaScript loop through In this Tutorial we want to describe you a code that help you in understanding JavaScript loop through. We are using Java Script...;= 1; i <= 9; i++){   for(var j = 1
data insertion and fetch 1
data insertion and fetch 1  @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type
Maven Dependency orbit-java-parent >> 1
You should include the dependency code given in this page to add Maven Dependency of cloud.orbit >> orbit-java-parent version1 in your project
Maven Dependency uberpom-java-jar >> 1
You should include the dependency code given in this page to add Maven Dependency of com.squeakysand.devtools >> uberpom-java-jar version1 in your project
Maven Dependency oss-java-parent >> 1
You should include the dependency code given in this page to add Maven Dependency of com.terradue >> oss-java-parent version1 in your project
ModuleNotFoundError: No module named 'isotoma.depends.plone4_1'
ModuleNotFoundError: No module named 'isotoma.depends.plone4_1'  Hi...: No module named 'isotoma.depends.plone4_1' How to remove the ModuleNotFoundError: No module named 'isotoma.depends.plone4_1' error? Thanks  
Cohabitation struts 1 and 2 - Struts
Cohabitation struts 1 and 2  Hi, I have a problem with the cohabitation of struts 1 and 2. I work on a web application which used struts 1. But i must add some functionality in struts 2. When i modify my web.xml file
Struts 2 Integration with Struts 1
Struts 2 Integration with Struts 1  I want to integrate struts 2 with struts 1 existing application. Can you please help on how to go about this. I am not finding any good source to integrate struts 2 with struts 1 framework
Chapter 1. EJB Overview
 Chapter 1. EJB OverviewPrev Part I. Exam Objectives Next    Chapter 1. EJB... the Write Once, Run Anywhere™ philosophy of the Java programming
How to Addding 1 Year with PHP
How to Addding 1 Year with PHP  Hi, I am very fresh in PHP language. I trying to create a small application about how to adding 1 year in specific date. Please suggest me. Thanks
Solving task 1 by 1 from bundle of task data
Solving task 1 by 1 from bundle of task data  Hello and namaste guys, i really need help here.i use ResultSet to query data from database. as we know... set.what should i do so that the solve code solve data 1 by 1?do i need to use
How to Create Multiplication Table from 1 to 10?
How to Create Multiplication Table from 1 to 10?  Hi, I want... table 1 to 10. Please suggest online example related to creating multiplication table. Thanks   Hi, Did you want to create multiplication table 1
Prime Number program in Java
Prime Number program in Java will print the prime numbers between 1 to any... than 1 or itself. Similar logic is used in program will displaying the result... automatically prints Prime Number starting from 1 to 50. Example of Prime Number
received memory warning level 1
received memory warning level 1  received memory warning level 1 and if i continue to it .. i get second warning received memory warning level 2 And then my application get crash. Can any one please explain me what
Prime Number in Java
Prime Number in Java In this Java tutorial , you will learn how to write a Java program to get prime numbers between 1 to the desired number. To start with, we have defined a class "PrimeNumber" in this example. Java I/O package
Heilighting error field in struts 1
Heilighting error field in struts 1  Hi, I am trying to change field color on error occur to a particular field. But i m not able to do it.I try to use errorStyleClass and errorStyle as well bt it giving me an error
How to list even numbers between 1 and 100?
How to list even numbers between 1 and 100?  Hi, I Java to check if a number is even? How to list even numbers between 1 and 100? Thanks  ... the numbers between 1 and 100 for (int i=1;i <=num ; i++){ if(i%2==0
print the sum of even number from 1 to 100
print the sum of even number from 1 to 100  how to print the sum of even number from 1 to 100 using for loops? Thanks
Generate random numbers from 1 to 100
Generate random numbers from 1 to 100  1)A class Called: RandomNumberGenerator that generate random numbers from 1 to 100 2)A class Test that tests the hierarchy in A) especially the getArea() and getVolume() methods. Use

Ads