0% found this document useful (0 votes)
18 views2 pages

Array Declaration and Sales Program Guide

Uploaded by

4btkkdmzxg
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Array Declaration and Sales Program Guide

Uploaded by

4btkkdmzxg
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Array Declaration Worksheet

Please enter the code to declare the following arrays properly:

1. Declare an int array named scores that will hold 100 elements.

int scores[] = new int[100];

2. Declare an array named alpha that will hold 500 characters:

char alpha[] = new char[500];

3. Declare an array named tortoise that will hold 50 Turtle objects:

Turtle tortoise[] = new Turtle[50];

4. Declare an array called flag that will hold 75 boolean values:

boolean flag[] = new Boolean[75];

5. Declare an array called num that will hold 1,000 double values:

double num[] = new double[1000];

6. Assign the length of the array num from #5 to a variable called len:

int len = [Link];

7. Assign the value of 10.34 to the second element in the num array above:

num[1] = 10.34;

8. Write a for loop that will print out the elements of the num array on one line:

for (double n: num) {

[Link](n);

Create a runner program (has a main menu) that:

1. Prompts the user for the number of current salespeople at the company

2. Creates an array of the correct size based on the number of salespeople


3. Create a “for loop” that will prompt and allow the user to enter the total sales
for each salesperson. This step should enter the sales into an element of the
array.

4. After the loop that enters the sales, print out the total sales for the company
and the average sales per salesperson.

5. List the salesperson and amount that sold the most and the salesperson and
amount who sold the least.

You might also like