(adsbygoogle = window.adsbygoogle || []).push({}); 1. The problem statement, all variables and given/known data

I have to write a JAVA program that will compute and display (via the ptplot package) the solutions for the damped harmonic oscillator (x against t) in some given range for t. The solutions vary depending on how gamma and omega are related. The instructions given were:

1) Read in values of omega, gamma and the number of points to plot from the terminal

2) Calculate and plot the amplitude vs time using the ptplot package

3) Reprompt for new values of omega, gamma and no. of points

4) Add the results of this new calculation to the existing graph as a new series

3. The attempt at a solution

Writing up how to draw the graph is fine, I am just getting a bit confused about how to go about coding the loop (i.e the bit about reprompting for new values)

I remember someone saying they had to enclose the code in a 'while' loop, but I am not sure what the boolean condition would be here.

What I have written so far is something like:

while (some boolean statement) {

// In my program, I have the code that should be under this while statement correctly, here I will just write what I am doing - Ask user for values of omega,gamma and no.of points and parse into double form

if (gamma>2omega) {

//Here I write in the code to draw this graph etc..

After this I get stuck- How to reprompt user for more values?

What is the boolean statement?

How to plot graphs on existing graphs?

Any help here would be greatly appreciated and if anything is unclear, I will explain again.

Many thanks

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: Java - program with SHM

**Physics Forums | Science Articles, Homework Help, Discussion**