Java Help

0 Zodiac delby · November 2, 2014
Hi Simon,

I hope you can help on this question also , appreciated thank you.

1.       Write a program that takes three double values x0, v0, and t from the user and prints the value x0 +v0t +g t2/2, where g is the constant 9.78033. This value is the displacement in meters after t seconds when an object is thrown straight up from initial position x0 at velocity v0 meters per second.
 
Sample run:
Enter the value of x0, v0 and t: 0 2 2
The displacement in meters after 2 seconds when an object is thrown straight up from initial position 0 at velocity 2meters per second is: 23.56066


Answer :

Post a Reply

Replies

Oldest  Newest  Rating
0 Yasser Taha · November 3, 2014

import java.util.Scanner;
public class QuestionOne {
    public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    System.out.println(" Enter the values of x0(Initial position), v0(Initial speed), and t(time in seconds):");
    double x, x0, v0,t,g;
    
    x0 = input.nextInt();
    v0 = input.nextInt();
    t = input.nextInt();
    g = 9.78033;
    x = x0 +v0*t +g*Math.pow(t , 2)/2;
    System.out.println("The displacement in meters after " + t + " seconds is thrown straight up from initial position " + x0 + " at velocity " + v0 + " meter per seconds is:" + x);
          
        
        
        
    }
    
}
0 Zodiac delby · November 2, 2014
No I did as below , but I'm not sure it's right ... 

package problem_3;

import java.util.Scanner;

public class Problem_3
{

    public static void main(String[] args)
    {
        Scanner s =new Scanner(System.in);
        int N1D1,N2D2,SUM,SUB,MUL,DIV;
        double result;
        System.out.println("Enter the numerator and denominator of the first fraction:");
        N1D1=s.nextInt();
        N2D2=s.nextInt();
        System.out.println("Enter the numerator and denominator of the second fraction:");
        N2D2=s.nextInt();
        System.out.println("The sum is :"+N1D1+N2D2);
        System.out.println("The subtraction is :");
        System.out.println("The multiplication is :");
        System.out.println("The division is :");

    }
    
}
0 Zodiac delby · November 2, 2014
if you want to help you can do that , if not , it's not the right place to show that your are super genius . and it's not a  place to share jokes , it's a place to learn.
  • 1

Java / Android Development

107,039 followers
About

Very popular language used to create desktop applications, website applets, and Android apps.

Links
Moderators
Bucky Roberts Administrator