EBK BUILDING JAVA PROGRAMS
EBK BUILDING JAVA PROGRAMS
4th Edition
ISBN: 9780134323718
Author: Stepp
Publisher: PEARSON CUSTOM PUB.(CONSIGNMENT)
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 2, Problem 1E

In physics, a common useful equation for finding the position s of a body in linear motion at a given time t, based on its initial position s0, initial velocity v0, and rate of acceleration a, is the following:

  s = s 0 + v 0 t + 12 at 2

 Write code to declare variables for s0, v0, a, and t, and then write the code to compute s on the basis of these values.

Expert Solution & Answer
Check Mark

Explanation of Solution

Code for declaring variables

  • A declaration of a variable is where a program says that it needs a variable.
  • The declaration gives a name and data type for the variable.
  • A variable cannot be used in the program unless it has been declared.
  • It also asks for a particular value that can be placed in the variable.
  • Hence the code for declaring variables s0,v0,a and t is

 double s0 = 12.0;

 double v0 = 3.5;

 double a = 9.8;

 double t = 10.0;

  • The code for computing s on the basis of these values is

 double s = s0 + v0 * t + 0.5 * a * t * t;

 System.out.println(s);

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
Suppose you want to deposit a certain amount of money into a savings account, and thenleave it alone to draw interest for the next 10 years. At the end of 10 years, you would like tohave $10,000 in the account. How much do you need to deposit today to make that happen?You can use the following formula, which is known as the present value formula, to find out:The terms in the formula are as follows: [5 marks]• P is the present value, or the amount that you need to deposit today.• F is the future value that you want in the account. (In this case, F is $10,000.)• r is the annual interest rate.• n is the number of years that you plan to let the money sit in the account.Write a method named presentValue that performs this calculation. The method should accept the future value, annual interest rate, and number of years asarguments. It should return the present value, which is the amount that you need to deposit today.Demonstrate the method in a program that lets the user experiment with…
The quadratic formula is used to solve a very specific type of equation, called aquadratic equation. These equations are usually written in the following form:ax2 + bx + c = 0The Quadratic Formula x = ( -b ± √( b^2 - 4ac ) ) / ( 2a ) Where a, b, and c are constants with a ≠ 0. (If a = 0, the equation is a linear equation.)The discriminant is the part of the formula in the square root. If the value of the discriminant is zero then the equation has a single real root. If the value of thediscriminant is positive then the equation has two real roots. If the value of thediscriminant is negative, then the equation has two complex roots.Write a program that finds the roots of the quadratic equation using the Quadratic Formula. Write a function named discriminant in the file, Disc.py, to calculate and return the discriminant of the formula. Let the main function call the discriminant function and then calculate the solution(s) of the equation. Do not calculate the solutions in the discriminant…
The concentration (C) of insulin in the body is described by the following equation C = C0e^-40t / M Where C0 = 85 pmol/L is the initial insulin concentration, t is time in minutes, M is the person mass in kg. a) Write code that will calculate the insulin concentration of two people with weighs 60 Kg and 100 Kg. Simulate the insulin concentration for 4 minutes in steps of 0.1 minute. b) Plot the insulin concentration of the two people on the same graph. For the first curve plot a magenta solid line, square marker, cyan for MarkerFaceColor, and MarkerSize of 6. For the second curve plot a black dashed line with LineWidth of 2. c) Your plot should have a title, a legend, and appropriate labels for the x and y axis.

Chapter 2 Solutions

EBK BUILDING JAVA PROGRAMS

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Constants, Variables, Data types, Keywords in C Programming Language Tutorial; Author: LearningLad;https://www.youtube.com/watch?v=d7tdL-ZEWdE;License: Standard YouTube License, CC-BY