Hi
I am a beginner and currently trying to create a small program. I seem to be stuck on the multiplication of their elements. Eg. I have an Array with 4 different prices for 4 different products and have created 2 other Arrays to which I have assigned values through window.prompt(p arseFloat) , what I am trying to do is multiplicate the values on the parallel arrays by their corresponding indexes and keep a running total so I can have an overall total afterwards. Sorry if the explanation sounds poor. - var priceOfprod [12,14,2,45];
-
-
var numberOfproducts;
-
numberOfproducts = parseFloat(window.prompt('how many different products you wish to purchase?',''));
-
-
-
var orderProductArray = new Array (numberOfproducts)
-
var orderQuantityArray = new Array (numberOfproducts)
-
for (var count = 0; count < numberOfproducts; count = count + 1)
-
{
-
indexOf = parseFloat(window.prompt ('please enter item required',''));
-
quantity = parseFloat(window.prompt('how many units of this product do you required?',''));
-
-
productPrices[indexOf] + '<br>')
-
orderProductArray[count] = indexOf;
-
orderQuantityArray[count] = quantity;
-
};
1 1990 acoder 16,027
Recognized Expert Moderator MVP
Instead of parseFloat, use parseInt.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Xiaozhu |
last post by:
say, if you had parallel arrays containing the sales person id, the month, and
the sales figures (for that person in that month), sorting on sales figure and
preserve the order of figures within the data about the same person:
Original Data:
id month sales
+-----+ +-----+ +-----+
| 432 | | 8 | | 89 |
+-----+ +-----+ +-----+
| 123 | | 8 | | 116 |
|
by: Paul |
last post by:
See topic;
Context:
Passing arrays around in a MPI system(Message Passing Interface-
Parallel Program crap)
Thanks much!
-Paul
|
by: Luke |
last post by:
Elements with name attribute:
form, input, textarea, a, frame, iframe, button, select, map, meta,
applet, object, param, img (if you know more reply...)
Methods of addresing html elements:
<form name="myform">
<input name="myinput" />
</form>
1. var input = document.forms.myform.myinput;//from nn3+
2. var input = document.forms.myinput;//from nn3+
|
by: Suresh Jeevanandam |
last post by:
Hi all,
Lets say I have an array:
from numarray import *
a = array()
I want to multiply out all the elements and get the result.
r = 1.0
for i in a:
r = r*i
|
by: lifeshortlivitup |
last post by:
I am trying to construct two, one-dimensional parallel arrays that will give me a letter grade for whatever score I enter. The two arrays I need are minimum score and grade. I don't understand how to build the score array. The scores are as follows: 0 - 299 should result in a F
300 - 349 should result in a D
350 - 399 should result in a C
400 - 449 should result in a B
...
| |
by: kmuz08 |
last post by:
Hello to everyone,
I have to do a project in my discovering programming class based on creating parallel arrays for an order form. I am still not completely sure was a parallel array is! But basically any help, tips, pr tricks would help. My program is to allow the user to enter the name of a product, the product number or serial number, the quantity, and the cost per item and have them all displayed in different parrallel...
|
by: IamIan |
last post by:
I'm using an array to store map features (name, lat, lon, caption,
etc), from which the user can then select an individual feature. The
problem is that when thousands of features are stored in the array,
looping over the entire array looking for a match is SLOW.
So I'm running a hash in parallel, where every time a feature is
pushed onto the array it's name is also added to the hash as an
identical key value pair. I then check if the key...
|
by: earla12 |
last post by:
Hi,
I'm working on a program that takes the following input from the user:
Student Name, Student Number, and Student GPA
The information is then supposed to be stored in three separate arrays.
Prior to sending the output to the screen, a bubble sort has to be performed
so that it's sorted by Student Name.
|
by: mh |
last post by:
I want to interate over two arrays in parallel, something like this:
a=
b=
for i,j in a,b:
print i,j
where i,j would be 1,4, 2,5, 3,6 etc.
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |