»
S
I
D
E
B
A
R
«
Javascript Variable Dollar
January 19th, 2009 by admin

javascript variable dollar
Javascript Assignment Please help!!!?

Hi guys, I really really really am in need of some help with this assignment, I tried million times but it just doesn’t work, I really don’t knwo how to do it…Please help me out. Thanks a lot….

Write a program to determine the monthly bonus payment for the sales staff of Ask-Me Automobile Dealership. The bonus formula is $50 per car sold plus one percent (1%) of total sales. In addition, an extra bonus of one percent (1%) is paid on the amount of sales in excess of the average sales per peson.

-allow input of the following data for each salesperson: name, number of cars sold, total dollar amount of sales
-use an array to store each set of data, for a total of three arrays
-continue to ask for data until the user clicks Cancel instead of OK in the Prompt Box
-use an accumulator variable inside the loop to keep a running total as you calculate the average
-calculate the average after all data has been entered by dividing the accumulator by the # of salesperson

Personally I think this is a java question, not a javascript. Anyhow, I am not going to argue with that.

If you have your Prompt Box and can get the information from it, the following methods may help you.

// Arrays to hold the seles person data
String[] salesperson_names = new String[100];
int[] salesperson_cars_sold = new int[100];
double[] salesperson_sales_amount = new double[100];

int counter = 0;

// method to store data
void inputData(String name, int cars_sold, double total) {
salesperson_names[counter] = name;
salesperson_cars_sold[counter] = cars_sold;
// etc.
counter++;
}

// for the average, do a for loop
int accumulator = 0;
for (int i = 0; i < counter; i++) {
accumulator += salesperson_sales_amount[i];
}
int average = accumulator / counter;


Leave a Reply

»  Substance: WordPress   »  Style: Ahren Ahimsa