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: 50% (2 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...
-
What is the purpose of level numbers in COBOL records?
-
Santana Auto Care is considering the purchase of a new tow truck. The garage Compute net present value doesn't currently have a tow truck, and the \($50,000\) price tag for a new truck would...
-
On January 1, 2021, Acme Co. is considering purchasing a 40 percent ownership interest in PHC Co., a privately held enterprise, for $700,000. PHC predicts its profit will be $185,000 in 2021,...
-
blem #5: (a) Let u = (-9, -1, 6, -6) and v = (-9, -1, -1, -6). Find ||u proj,u||. Note: You can partially check your work by first calculating proj,u, and then verifying that the vector proju and...
-
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...
-
Prove parts (c) and (d) of Theorem 16.1. (c) If a, b, c G and ab = ac, then b = c. (Left-cancellation property) (d) If a, b, c G and ba = ca, then b = c. (Right-cancellation property)
-
How to close the instructional gap in elementary school? How to solve transient problem in a school? How to close the academic gap in elementary school?
-
What are the different types, benefits and challenges of fieldwork?
-
Problem # 2 Cost incurred Installation services Supplies 45.00 Labor 445.00 Designer services Supplies Labor 10.00 200.00 Cleanup Janitorial service cost 35.25 Service overhead for installation...
-
Q2. Elaborate on the following diagrams and graphs: (what why and when they are used)? A. First Diagram. Normal Prioritized Features List Fast Tracking Crashing B. Second Diagram. 1 2 3 68 Selected...
-
How has telemedicine and mobile application impacted positive change in the United States healthcare and how this has led to increased interest in the use of operations management tools and...
-
For each of the following long-term assets, identify the type of expense that will beincurred to allocate the assets cost as depreciation expense (DR), depletion expense (DL), amortization expense...
-
Using the information presented in Problem 13.4B, prepare a partial statement of cash flows for the current year, showing the computation of net cash flows from operating activities using the...
-
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?
-
DUX COMPANY Comparative Balance Sheets December 31, 2018 and 2017 ($ in 000s) 2018 2017 Assets Cash Accounts receivable Less: Allowance for uncollectible accounts $ 39 $ 23 47 53 (5) (4) Dividends...
-
Frank Incorporated is trying to decide whether to lease or purchase a plece of equipment needed for the next 10 years. The equipment would cost $53,000 to purchase, and maintenance costs would be...
-
Skull Company makes snowboards and uses the total cost method in setting product price. Its costs for producing 12,500 units follow. The company targets a 10.0% markup on total cost. Variable Costs...
Study smarter with the SolutionInn App