Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using the Design Recipe and NetBeans, construct an algorithm, and then write a J

ID: 3796399 • Letter: U

Question

Using the Design Recipe and NetBeans, construct an algorithm, and then write a Java program based on the algorithm, to solve each of the following problems:

(Engineering: acceleration) Average acceleration is defined as the change of velocity divided by the time taken to make the change, as shown in the following formula:


Write a program that prompts the user to enter the starting velocity v0 in meters/second, the ending velocity v1 in meters/second, and the time span t in seconds, and displays the average acceleration.
  

Sample Run (user input in color):

run:
Enter the starting velocity in meters/second: 5.5
Enter the ending velocity in meters/second: 50.9
Enter the time span in seconds: 4.5
The average acceleration is 10.1
BUILD SUCCESSFUL (total time: 10 seconds)

Explanation / Answer


// Acceleration.java
import java.util.Random;
import java.util.Scanner;

class Acceleration
{

public static void main(String args[])
{
Scanner scan = new Scanner(System.in);
System.out.print("Enter the starting velocity in meters/second: ");
double initialVelocity = scan.nextDouble();

System.out.print("Enter the ending velocity in meters/second: ");
double finalVelocity = scan.nextDouble();
  
System.out.print("Enter the time span in seconds: ");
double time = scan.nextDouble();

double acceleration = (finalVelocity- initialVelocity)/time;

acceleration = (double)Math.round(acceleration * 10d) / 10d;


System.out.println("The average acceleration is " + acceleration);

  
}
}   


/*
output:

Enter the starting velocity in meters/second: 5.5
Enter the ending velocity in meters/second: 50.9
Enter the time span in seconds: 4.5
The average acceleration is 10.1

*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote