This is this impossible question I have to do I dont even know how to start it.
2) The physics equation for Force, F = m*a. (3pt)
Means force (N) is equals to mass (kg) times by acceleration (m/s^2)
...Use an array to store 10 masses and another array to store 10 accelerations.
...Use a loop to calculate and output (document.write) the forces generated.
Sample output: 5(kg) * 10 (m/s^2) = 50 (N)
??????????????????????????????????????????
7 1663
thats not too hard ! come on i'll help you get started but because its a class I won't give you the full code. (tsdn policies);
so you make an array i would go about it like this -
var masses = [1, 23, 43, 34, 51, 26, 57, 78, 89, 10];
-
var mass = [masses];
-
This is how an array is made
then to pull the data just use -
mass[0][2] this would = 23
-
todo some javascript math i use Math.floor()
Math.floor(Math functions here)
then you need a loop a loop would be made like this for example -
for (i=0; i<10; i++) {
-
dostuff
-
}
-
its i<10 because it starts at 0 so it would be 10 overall when it stops at 9.
document.write is used like this -
-
document.write("hello people!");
-
to add vars to a document.write you do -
document.write("hello people!"+mass[0][i]+" mass!");
-
I need to do a physics equation using Javascript it needs to use the array variable and it needs to contain 10 different equations. I need a equation that looks something like this
5(kg) * 10 (m/s^2) = 50 (N)
did I not already answer this question for you in this Thread?
did I not already answer this question for you in this Thread?
This calls for a merging. Threads merged.
I need to do a physics equation using Javascript it needs to use the array variable and it needs to contain 10 different equations. I need a equation that looks something like this
5(kg) * 10 (m/s^2) = 50 (N)
You have been given enough information to attempt the problem yourself. If you don't know the basics of javascript, see the tutorial links in the Offsite Links thread at the top of this forum.
Make an attempt and if you get stuck on a particular part, then post again.
Thank you guys This is this code that i used and it worked
<script>
var nAcc = new Array();
nAcc[0] = 3;
nAcc[1] = 4;
nAcc[2] = 5;
nAcc[3] = 6;
nAcc[4] = 7;
nAcc[5] = 8;
nAcc[6] = 9;
nAcc[7] = 10;
nAcc[8] = 11;
nAcc[9] = 12;
var nMass = new Array();
nMass[0] = 3;
nMass[1] = 4;
nMass[2] = 5;
nMass[3] = 6;
nMass[4] = 7;
nMass[5] = 8;
nMass[6] = 9;
nMass[7] = 10;
nMass[8] = 11;
nMass[9] = 12;
var nForce=0;
for (n=0; n<10; n++){
nForce = nAcc[n] * nMass[n];
document.write(nForce + " (N)=" + nMass[n] +"(m/s^2) * " + nAcc[n]+ "kg<br>");
}
</script>
cool good for you.... i had written this code out before i told you how to do it... i made mine with a nested loop for all possibilities. -
<script>
-
function calcForce() {
-
var masses = [2, 4, 5, 12, 1232, 289, 925, 892, 102, 383];
-
var mass = [masses];
-
var accelerations = [20, 12, 44, 218, 12, 33, 11, 22, 23, 78];
-
var acceleration = [accelerations];
-
for (i=0; i<10; i++) {
-
for (b=0; b<10; b++) {
-
document.write(mass[0][i]+"(kg) * "+acceleration[0][b]+"(m/s^2) = "+Math.floor(mass[0][i]*acceleration[0][b])+" (N)<br>");
-
}
-
}
-
}
-
</script>
-
<input type="button" onclick="calcForce()" value="Test">
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: KellyH |
last post by:
Hi, I hope someone can point me in the right direction.
I'll get it out of the way: Yes, I am a college student. No, I am not
looking for anyone to do my homework, just looking for help. I have...
|
by: Psykarrd |
last post by:
I am trying to declare a string variable as an array of char's. the
code looks like this.
char name;
then when i try to use the variable it dosn't work, however i am not
sure you can use it...
|
by: John |
last post by:
Hi all...
Either I'm doing really something really stupid - or maybe there is
some bug somewhere (optimizing?). In a function I have:
int x1, y1, x2, y2;
float dR, dX, dY;
dR =...
|
by: Dave Vandervies |
last post by:
I just fixed a bug that some of the correctness pedants around here may
find useful as ammunition.
The problem was that some code would, very occasionally, die with a
segmentation violation...
|
by: Sheldon |
last post by:
Hi,
I have a written a script that will check to see if the divisor is zero
before executing but python will not allow this:
if statistic_array > 0.0:
statistic_array =...
|
by: frankie_85 |
last post by:
Hi everyone,
I just made a simple code which is part of my assignment but I can't
figure it out what's wrong with it. (always give me error messages)
What the code basically does is:
a...
|
by: Ken Fine |
last post by:
Hi there,
I have written a simple function that attempts to set the angle of objects
so as to place them in aesthetically appealing ways. The code follows; there
is some stupidness in it (e.g. a...
|
by: namit101 |
last post by:
Hi,
does c# provide any classes for handling single dimension vector math (i.e., something to adding two double arrays)? Does anyone know any good opensource math libraries that would accomplish...
|
by: moltendorf |
last post by:
Hey everyone, as I have been by far pleased with some of the top helpers on this forum, I have decided to send another one your way.
Even though I am personally having minimal issues with this...
|
by: T |
last post by:
hi, Just wondering what tools are available for authoring in XML for
docs that have complex math environments. Like equation arrays,
multiline equations, etc. The kind of environments AMSLaTeX...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |