Add a main() method to Program 3.4.1 that unit-tests the Body data type. Program 3.4.1 Gravitational body
Question:
Add a main() method to Program 3.4.1 that unit-tests the Body data type.
Transcribed Image Text:
Program 3.4.1 Gravitational body public class Body { py private Vector r; private Vector v; private final double mass; public Body (Vector r0, Vector v0, double m0) { r = r0; v = v0; mass = m0; } public void move (Vector force, double dt) { // Update position and velocity. Vector a = force.scale(1/mass); v = v.plus (a.scale(dt)); r = r.plus (v.scale(dt)); } public Vector forceFrom(Body b) { // Compute force on this body from b. b } public void draw() { force dt G delta dist magnitude Body a this; double G = 6.67e-11; Vector delta = b.r.minus(a.r); double distdelta.magnitude(); double magnitude= (Ga.mass * b.mass) / (dist dist); Vector force = delta.direction ().scale (magnitude); return force; StdDraw.setPenRadius (0.0125); StdDraw.point (r.cartesian (0), r.cartesian (1)); position velocity V mass mass force on this body time increment acceleration this body another body gravitational constant vector from b to a distance from b to a magnitude of force
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (3 reviews)
java public class Body private Vector 1 private Vector v private final double mass public BodyVector ...View the full answer
Answered By
Asd fgh
sadasmdna,smdna,smdna,msdn,masdn,masnd,masnd,m asd.as,dmas,dma.,sd as.dmas.,dma.,s ma.,sdm.,as mda.,smd.,asmd.,asmd.,asmd.,asm
5.00+
1+ Reviews
15+ Question Solved
Related Book For
Introduction To Programming In Java An Interdisciplinary Approach
ISBN: 9780672337840
2nd Edition
Authors: Robert Sedgewick, Kevin Wayne
Question Posted:
Students also viewed these Algorithm Design questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Define the contextual-equivalence relation ` M =ctx M0 : for pairs of PCF terms M, M0 , PCF types , and PCF type environments . [3 marks] (ii) For PCF terms M and N with respective typings ` M : and...
-
re Regular Languages and Finite Automata (a) Let L be the set of all strings over the alphabet {a, b} that end in a and do not contain the substring bb. Describe a deterministic finite automaton...
-
The common stock of Fido Corporation was trading at $45 per share on October 15, 2010. A year later, on October 15, 2011, it was trading at $80 per share. On this date, Fidos board of directors...
-
Many animals, including humans, tend to avoid direct eye contact and even patterns that look like eyes. Some insects, including moths, have evolved eye-spot patterns on their wings to help ward off...
-
Appreciate the changes taking place in the fashion system. LO.1
-
A company growing at an annual rate of 35 percent will double in size in just two years. A company growing at an 18 percent rate will double in size in four years. A company growing by 12 percent...
-
Madrid Jewelry Company reported the following summarized balance sheet at December 31, 2012: During 2013, Madrid completed the following transactions that affected stockholders equity: Requirements...
-
How has Starbucks implemented hedging strategies to mitigate the impact of exchange rate fluctuations on its financial performance?
-
Give an implementation of minus () for Vector solely in terms of the other Vector methods, such as direction() and magnitude().
-
Write a program that takes from the command line three integers between 0 and 255 that represent red, green, and blue values of a color and then creates and shows a 256-by-256 Picture in which each...
-
The accompanying table shows a portion of the number of cases of crime related to gambling (Gambling) and offenses against the family and children (Family Abuse) for the 50 states in the United...
-
2.11.2Project:Performance Task: The Parallax Problem Project Geometry Sem 1 (S3537251) Julio Duenas Points possible:120 Date: ____________ The Scenario:You're looking for a sponsor to pay for you to...
-
If the most common treatment of assigning overapplied overhead was used, the final balance in Cost of Goods Sold would have been * (1 Point) At the end of the last fiscal year, BREAD Company had the...
-
Angelina received new word processing software for her birthday. She also received a cheque with which she intends to purchase a new computer. Angelina's UNILUS Professor assigned a paper due in two...
-
At date t, the portfolio P to be hedged is a portfolio of Treasury bonds with various possible maturities. Its characteristics are as follows: Value YTM MD Convexity $1,450 6% 4.25 55 We consider...
-
A playground merry-go-round with an axis at the center (radius R = 1.3 m and rotational inertia | = 1.2 x 103 kgm2) is initially rotating at angular velocity w = 0.21 rad/s clockwise). A girl of mass...
-
Snooker Arnovich buys on margin 1,000 shares of Rockford Systems stock at $60 per share. The initial margin requirement is 50% and the maintenance margin requirement is 30%. If the Rockford stock...
-
Kims Konstructions has assembled the following data for a proposed straw-reinforced brick maker (SRBM): SRBM Cost: $26,000 Life: 5 years Revenue (p.a.) $11,000 Operating Expenses (p.a.) $3,000...
-
Based on the following query: SELECT CUS_CODE, MAX(LINE_UNITS*LINE_PRICE) FROM CUSTOMER NATURAL JOIN INVOICE NATURAL JOIN LINE WHERE CUS_AREACODE = 615 GROUP BY CUS_CODE; How would you rewrite the...
-
The following data structure and constraints exist for a magazine publishing company. a. The company publishes one regional magazine each in Florida (FL), South Carolina (SC), Georgia (GA), and...
-
Describe the characteristics of predictive analytics. What is the impact of Big Data in predictive analytics?
-
What is the Macaulay duration of a bond with a coupon of 6.6 percent, seven years to maturity, and a current price of $1,069.40? What is the modified duration? (Do not round intermediate...
-
"Tell me something you know today that you did not know yesterday" about 3D Animation Justify by citing 2 or more resources from this course.
-
Warrants exercisable at $20 each to obtain 50,000 shares of common stock were outstanding during a period when the average market price of the common stock was $25. Application of the treasury stock...
Study smarter with the SolutionInn App