Building Java Programs: A Back to Basics Approach (4th Edition)
Building Java Programs: A Back to Basics Approach (4th Edition)
4th Edition
ISBN: 9780134322766
Author: Stuart Reges, Marty Stepp
Publisher: PEARSON
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
In your favorite open world adventure video game, currency conversion is as given below:     1 Gold coin 23 Bolts 1 Gem 13 Gold coins Write a program that takes a number of Bolts as user input (as an integer) and converts it to the number of whole Gems, Gold coins, and Bolts as shown below. The conversion information between these measurement metrics is provided in the table above. The number of Bolts should be converted in such a way that maximizes the whole number of Gems and Gold coins. Expected output 1 (bold is user input) Enter the number of Bolts: 32 0 Gems(s) 1 Gold coin(s) 9 Bolt(s) Expected output 2 (bold is user input) Enter the number of Bolts: 3000 10 Gem(s) 0 Gold coin(s) 10 Bolt(s) The file should be named as convertCurrency.cpp. Don’t forget to head over to Coderunner on Canvas and paste your solution in the answer box!
Please code in python In an alternate reality, chemistry Professors Hodge and Sibia have teamed up to design a chemical compound X such that when X is added to Dan’s favorite food (saltine crackers), it’ll make him despise it. For this, they are working with 6 kinds of extracts: Singleton Extracts: berries (B), green veggies (G), dairy (D) Combination Extracts: icecream (I), salad (S), and cheese sauce (C). Like regular food, mixing two extracts of the same kind will result in an extract of the same kind (eg. mixing berries B with berries B will result in berries B). Mixing two singleton extracts will result in a combination extract, using these rules: Berries (B) + Green Veggies (G) = Salad (S) Berries (B) + Dairy (D) = Icecream (I) Green Veggies (G) + Dairy (D)= Cheese Sauce (C) Mixing two combination extracts will result in a singleton extract closest to them. For example, Icecream (I) + Salad (S) is closest to Berries (B) since both Icecream and Salad extracts require using…
Write a program that reads a four-digit integer, such as 2014, and then displays it, one digit per line in reverse order, like so: 4 1 0 2 Your prompt should tell the user to enter a four-digit integer. You can then assume that the user follows directions. (Hint: Use the division andm remainder operators.)

Chapter 2 Solutions

Building Java Programs: A Back to Basics Approach (4th Edition)

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
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