# Assignment 4
- 此次作業主題為Array,請務必依題目提示使用Array作題,否則會扣分。
- The topic of this assignment is **Array**. Please make sure to use **Array** as instructed in the Quesiton Text. If not, points will be deducted.
- 此次作業為***Console App***類型,請各位同學不要創建錯誤。
- This assignment is of the ***Console App*** type. Please make sure to create the correct project type.
- 繳交方式同[Assignment 2 繳交教學](https://hackmd.io/@CCUPD2025/SJeWlJx31l),請將所有題目的`.cs` file命名完成後放在同個資料夾,最後壓縮上傳。
- The submission process follows the same steps as in Assignment 2 Submission Guide. Please name all `.cs` files correctly, place them in the same folder, and compress the folder before submission.
- 務必詳閱題目,並且正確命名!
- Make sure to read the instructions carefully and use the correct file names!
## Question 1 - CheckZips
Write a program named ***CheckZips*** that is used by a package delivery service to check delivery areas.
The program contains an **array** that holds the 10 zip codes of areas to which the company makes deliveries.
Prompt a user to enter a zip code, and display a message indicating whether the zip code is in the company’s delivery area.
> Please use the zip code table below:
| Area code |
| --------- |
| 62141 |
| 62142 |
| 62143 |
| 62144 |
| 62145 |
| 62146 |
| 62147 |
| 62148 |
| 62149 |
| 62150 |
#### Sample input 範例輸入:
1. `62141`
2. `66666`
#### Sample output 範例輸出:
1. `The zip code is in the company’s delivery area`
2. `Error: the zip code is NOT in the company’s delivery area.`
## Question 2 - DeliveryCharges
Write a program called ***DeliveryCharges*** for the package delivery service in **Question 1**.
The program should again use an array that holds the 10 zip codes of areas to which the company makes deliveries.
Create a **parallel array** containing 10 delivery charges that differ for each zip code.
Prompt a user to enter a zip code, and then display either a message indicating the price of delivery to that zip code or a message indicating that the company does not deliver to the requested zip code.
> Please use the zip code/price table below:
| Area code | 62141 | 62142 | 62143 | 62144 | 62145 | 62146 | 62147 | 62148 | 62149 | 62150 |
| --- | -------- | -------- | -------- | --- | --- | --- | --- | --- | --- | --- |
| Price of Delivery| 80 | 120 | 90 | 150 | 100 | 130 | 95 | 160 | 110 | 140 |
> **Parallel array** will be something like:
```csharp=
// Or string array:
// string[] areaCodes = { "62141", "62142", "62143", "62144", "62145", "62146", "62147", "62148", "62149", "62150" };
int[] areaCodes = {
62141, 62142, 62143, 62144, 62145,
62146, 62147, 62148, 62149, 62150
};
int[] deliveryPrices = {
80, 120, 90, 150, 100,
130, 95, 160, 110, 140
};
```
#### Sample input 範例輸入:
1. `62141`
2. `66666`
#### Sample output 範例輸出:
1. `The price of delivery to 62141 is $80`
2. `Error: the zip code is NOT in the company’s delivery area.`
## Question 3 - ChatAWhile
The Chat-A-While phone company provides service to six area codes and charges the per-minute rates for phone calls shown in `Figure 6-01`.
Write a program named ***ChatAWhile*** that stores the area codes and rates in **parallel arrays** and allows a user to enter an area code and the length of time for a call in minutes.
Display the total cost of the call or an error message if the area code is not found.
>Figure 6-01
| Area Code | Per-Minute Rate ($) |
| -------- | -------- |
| 262 | 0.07 |
| 414 | 0.10 |
| 608 | 0.05 |
| 715 | 0.16 |
| 815 | 0.24 |
| 920 | 0.14 |
>Per-minute phone call rates
#### Sample input 範例輸入:
1. Area code: `262`
Minutes: `20`
2. Area code: `263`
Minutes: `30`
#### Sample output 範例輸出:
1. `Total cost of the call is $1.40`
2. `Area code is not found.`
## Question 4 - ResortPrices
Write a program for The Carefree Resort named ***ResortPrices*** that prompts the user to enter the number of days for a resort stay.
Then display the price per night and the total price.
Nightly rates are:
- $200 for one or two nights;
- $180 for three or four nights;
- $160 for five, six, or seven nights;
- $145 for eight nights or more.
> You can use array like this:
```csharp=
// Use index to indicate the number of nights to stay
int[] prices = { 0, 200, 200, 180, 180, 160, 160, 160, 145 };
// If days > 8, then days * prices[8]...
```
#### Sample input 範例輸入:
1. Nights to stay: `2`
2. Nights to stay: `10`
#### Sample output 範例輸出:
1. `The price per night is $200 and the total price is $400.`
2. `The price per night is $145 and the total price is $1450.`
## Question 5 - HomeSalesWithArrays
Danielle, Edward, and Fatima are three salespeople at Holiday Homes.
Write an application named ***HomeSalesWithArrays*** that prompts the user for a salesperson’s initial (`D`, `E`, or `F`).
**Issue an error message for any invalid initials entered; the valid initials are stored in an array**.
Either uppercase or lowercase initials are valid(`D`, `E`, `F`, `d`, `e`, `f`).
While the user does not type `Z` or `z`, continue by prompting for the amount of a sale.
**In an array**, keep a running total of the amounts sold by each salesperson.
After the user types `Z` or `z` for an initial, display each salesperson’s initial and total.
- Display a grand total for all sales.
- If two or more salespeople’s totals are tied, display an appropriate message;
- otherwise, display the initial of the salesperson with the highest total. (only initial)
> Please make sure to use arrays, otherwise you might not get any points.
#### Program Example:
1. D: 20 E: 10 F: 10 (tie between E and F)

2. D: 30 E: 20 F: 10
