a. What type of array would you use to store the data and why? b. Write the code to initialize the array. c. Write the code to enter the data
a. What type of array would you use to store the data and why? b. Write the code to initialize the array. c. Write the code to enter the data
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
JAVA Based Prgm
![You are the director of sales in a pharmaceutical company, and you oversee 6 salespeople, and each salesperson has their territory (city) within the state. The territory is not equal, so salesperson A could have 4 cities, salesperson B could have 10, etc. You need to keep track of the number of sales within each territory for each salesperson listed below:
- **Salesperson 1: (Gomez)** - has 3 territories with sales of 2000, 1525, 1860
- **Salesperson 2: (Morticia)** - has 5 territories with sales of 1680, 2282, 750, 675, 250
- **Salesperson 3: (Pugsley)** - has 2 territories with sales of 950, 1280
- **Salesperson 4: (Wednesday)** - has 1 territory with sales of 1750
- **Salesperson 5: (Fester)** - has 4 territories with sales of 1964, 600, 1250, 150
- **Salesperson 6: (Lurch)** - has 3 territories with sales of 725, 550, 135
a. **What type of array would you use to store the data and why?**
A jagged array (an array of arrays) would be most suitable to store this data because each salesperson has a different number of territories.
b. **Write the code to initialize the array.**
```python
sales = [
[2000, 1525, 1860], # Salesperson 1
[1680, 2282, 750, 675, 250], # Salesperson 2
[950, 1280], # Salesperson 3
[1750], # Salesperson 4
[1964, 600, 1250, 150], # Salesperson 5
[725, 550, 135] # Salesperson 6
]
```
c. **Write the code to enter the data.**
The data can be directly entered as shown in the initialization step above.
d. **Write the code to print out the sales.**
```python
for i, salesperson in enumerate(sales):
print(f"Salesperson {i+1}:](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fe4aa3b5e-e7fa-4aac-8b86-8434ebe6fb39%2Ff9d8fb5d-6ea4-4bad-91b0-3d762da16e1b%2Fh9jihzc_processed.png&w=3840&q=75)
Transcribed Image Text:You are the director of sales in a pharmaceutical company, and you oversee 6 salespeople, and each salesperson has their territory (city) within the state. The territory is not equal, so salesperson A could have 4 cities, salesperson B could have 10, etc. You need to keep track of the number of sales within each territory for each salesperson listed below:
- **Salesperson 1: (Gomez)** - has 3 territories with sales of 2000, 1525, 1860
- **Salesperson 2: (Morticia)** - has 5 territories with sales of 1680, 2282, 750, 675, 250
- **Salesperson 3: (Pugsley)** - has 2 territories with sales of 950, 1280
- **Salesperson 4: (Wednesday)** - has 1 territory with sales of 1750
- **Salesperson 5: (Fester)** - has 4 territories with sales of 1964, 600, 1250, 150
- **Salesperson 6: (Lurch)** - has 3 territories with sales of 725, 550, 135
a. **What type of array would you use to store the data and why?**
A jagged array (an array of arrays) would be most suitable to store this data because each salesperson has a different number of territories.
b. **Write the code to initialize the array.**
```python
sales = [
[2000, 1525, 1860], # Salesperson 1
[1680, 2282, 750, 675, 250], # Salesperson 2
[950, 1280], # Salesperson 3
[1750], # Salesperson 4
[1964, 600, 1250, 150], # Salesperson 5
[725, 550, 135] # Salesperson 6
]
```
c. **Write the code to enter the data.**
The data can be directly entered as shown in the initialization step above.
d. **Write the code to print out the sales.**
```python
for i, salesperson in enumerate(sales):
print(f"Salesperson {i+1}:
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 2 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON

Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education