Question
(City_Precipitation_Data.txt). The data file contains the precipitation data for 66 US cities. Then proceed to write a java program. First, write four methods: 1 st
(City_Precipitation_Data.txt). The data file contains the precipitation data for 66 US cities. Then proceed to write a java program.
First, write four methods:
1st method: Write a method that has two parameters (name array and precipitation array), it outputs each citys name and precipitation
2nd method: Write a method that has one parameter (precipitation array), it finds and returns the index of the most precipitation.
3rd method: Write a method that has one parameter (precipitation array), it finds and returns the index of the least precipitation.
4th method: Write a method that has one parameter (precipitation array), it calculates and returns the average precipitation of all the cities.
Second, in the main method, read the data from the data file into two arrays, one to store the city names, and another to store the precipitations, then do the following:
Call the 1st method to print each citys name and precipitation
Call the 2nd method to get the index of the highest precipitation, then print the city name with the highest precipitation (assume there is no tie).
Call the 3rd method to get the index of the least precipitation, then print the city name with the least precipitation (assume there is no tie).
Call the 4th method to get the average precipitation and print it.
Then the program prints the names of cities that have less than the average precipitation and the names of the cities that have more than or equal to the average precipitation.
Format the output appropriately.
Sample run:
Name Precipitation in Inches
Billings 14.77 Honolulu 18.29 Houston 47.84 Indianapolis 40.95 Jackson 55.95 Jacksonville 52.34 Juneau 58.33 Kansas_City 37.98 Richmond 43.91 Knoxville 48.22 Birmingham 53.99 Bismarck 16.84 Bridgeport 44.15 Burlington 36.05 Albuquerque 9.47 Anchorage 16.08 Asheville 47.07 Charleston 51.53 Charleston 44.05 Charlotte 43.51 Atlantic_City 40.59 Portland 45.83 Portland 37.07 New_Orleans 64.16 New_York 49.69 Oklahoma_City 35.85 Sioux_Falls 24.69 Baltimore 41.94 Baton_Rouge 63.08 Columbia 48.27 Cheyenne 15.45 Cleveland 38.71 Columbus 38.52 Dallas-Ft_Worth 34.73 Des_Moines 34.72 Fairbanks 10.34 Grand_Junction 8.99 Grand_Rapids 37.13 Hartford 46.16 Las_Vegas 4.49 Lexington 45.91 Little_Rock 50.93 Washington 39.35 Long_Beach 12.94 Los_Angeles 13.15 Louisville 44.54 Milwaukee 34.81 Minneapolis 29.41 Montgomery 54.77 Mt._Washington 101.91 Nashville 48.11 Springfield 35.56 St_Louis 38.75 Philadelphia 42.05 Providence 46.45 Sacramento 17.93 Salt_Lake_City 16.50 San_Antonio 32.92 San_Diego 10.77 San_Francisco 20.11 Savannah 49.58 Seattle-Tacoma 37.07 Pittsburgh 37.85 Vero_Beach 51.93 Wilmington 42.81 Dodge_City 22.35 [66 cities]
The city with the most precipitation is Mt._Washington: 101.91.
The city with the least precipitation is Las_Vegas: 4.49.
The average precipitation of all cities is 37.35.
The cities that have less than the average precipitation:
Billings 14.77 Honolulu 18.29 Bismarck 16.84 Burlington 36.05 Albuquerque 9.47 Anchorage 16.08 Portland 37.07 Oklahoma_City 35.85 Sioux_Falls 24.69 Cheyenne 15.45 Dallas-Ft_Worth 34.73 Des_Moines 34.72 Fairbanks 10.34 Grand_Junction 8.99 Grand_Rapids 37.13 Las_Vegas 4.49 Long_Beach 12.94 Los_Angeles 13.15 Milwaukee 34.81 Minneapolis 29.41 Springfield 35.56 Sacramento 17.93 Salt_Lake_City 16.50 San_Antonio 32.92 San_Diego 10.77 San_Francisco 20.11 Seattle-Tacoma 37.07 Dodge_City 22.35 [28 cities]
The cities that have more than or equal to the average precipitation:
Houston 47.84 Indianapolis 40.95 Jackson 55.95 Jacksonville 52.34 Juneau 58.33 Kansas_City 37.98 Richmond 43.91 Knoxville 48.22 Birmingham 53.99 Bridgeport 44.15 Asheville 47.07 Charleston 51.53 Charleston 44.05 Charlotte 43.51 Atlantic_City 40.59 Portland 45.83 New_Orleans 64.16 New_York 49.69 Baltimore 41.94 Baton_Rouge 63.08 Columbia 48.27 Cleveland 38.71 Columbus 38.52 Hartford 46.16 Lexington 45.91 Little_Rock 50.93 Washington 39.35 Louisville 44.54 Montgomery 54.77 Mt._Washington 101.91 Nashville 48.11 St_Louis 38.75 Philadelphia 42.05 Providence 46.45 Savannah 49.58 Pittsburgh 37.85 Vero_Beach 51.93 Wilmington 42.81 [38 cities] |
(City_Precipitation_Data.txt). The data file contains the precipitation data for 66 US cities. Then proceed to write a program.
First, write four methods: 1st method: Write a method that has two parameters (name array and precipitation array), it outputs each citys name and precipitation 2nd method: Write a method that has one parameter (precipitation array), it finds and returns the index of the most precipitation. 3rd method: Write a method that has one parameter (precipitation array), it finds and returns the index of the least precipitation. 4th method: Write a method that has one parameter (precipitation array), it calculates and returns the average precipitation of all the cities.
Second, in the main method, read the data from the data file into two arrays, one to store the city names, and another to store the precipitations, then do the following: Call the 1st method to print each citys name and precipitation Call the 2nd method to get the index of the highest precipitation, then print the city name with the highest precipitation (assume there is no tie). Call the 3rd method to get the index of the least precipitation, then print the city name with the least precipitation (assume there is no tie). Call the 4th method to get the average precipitation and print it. Then the program prints the names of cities that have less than the average precipitation and the names of the cities that have more than or equal to the average precipitation.
Format the output appropriately. Sample run:
Name Precipitation in Inches
Billings 14.77 Honolulu 18.29 Houston 47.84 Indianapolis 40.95 Jackson 55.95 Jacksonville 52.34 Juneau 58.33 Kansas_City 37.98 Richmond 43.91 Knoxville 48.22 Birmingham 53.99 Bismarck 16.84 Bridgeport 44.15 Burlington 36.05 Albuquerque 9.47 Anchorage 16.08 Asheville 47.07 Charleston 51.53 Charleston 44.05 Charlotte 43.51 Atlantic_City 40.59 Portland 45.83 Portland 37.07 New_Orleans 64.16 New_York 49.69 Oklahoma_City 35.85 Sioux_Falls 24.69 Baltimore 41.94 Baton_Rouge 63.08 Columbia 48.27 Cheyenne 15.45 Cleveland 38.71 Columbus 38.52 Dallas-Ft_Worth 34.73 Des_Moines 34.72 Fairbanks 10.34 Grand_Junction 8.99 Grand_Rapids 37.13 Hartford 46.16 Las_Vegas 4.49 Lexington 45.91 Little_Rock 50.93 Washington 39.35 Long_Beach 12.94 Los_Angeles 13.15 Louisville 44.54 Milwaukee 34.81 Minneapolis 29.41 Montgomery 54.77 Mt._Washington 101.91 Nashville 48.11 Springfield 35.56 St_Louis 38.75 Philadelphia 42.05 Providence 46.45 Sacramento 17.93 Salt_Lake_City 16.50 San_Antonio 32.92 San_Diego 10.77 San_Francisco 20.11 Savannah 49.58 Seattle-Tacoma 37.07 Pittsburgh 37.85 Vero_Beach 51.93 Wilmington 42.81 Dodge_City 22.35 [66 cities]
The city with the most precipitation is Mt._Washington: 101.91.
The city with the least precipitation is Las_Vegas: 4.49.
The average precipitation of all cities is 37.35.
The cities that have less than the average precipitation:
Billings 14.77 Honolulu 18.29 Bismarck 16.84 Burlington 36.05 Albuquerque 9.47 Anchorage 16.08 Portland 37.07 Oklahoma_City 35.85 Sioux_Falls 24.69 Cheyenne 15.45 Dallas-Ft_Worth 34.73 Des_Moines 34.72 Fairbanks 10.34 Grand_Junction 8.99 Grand_Rapids 37.13 Las_Vegas 4.49 Long_Beach 12.94 Los_Angeles 13.15 Milwaukee 34.81 Minneapolis 29.41 Springfield 35.56 Sacramento 17.93 Salt_Lake_City 16.50 San_Antonio 32.92 San_Diego 10.77 San_Francisco 20.11 Seattle-Tacoma 37.07 Dodge_City 22.35 [28 cities]
The cities that have more than or equal to the average precipitation:
Houston 47.84 Indianapolis 40.95 Jackson 55.95 Jacksonville 52.34 Juneau 58.33 Kansas_City 37.98 Richmond 43.91 Knoxville 48.22 Birmingham 53.99 Bridgeport 44.15 Asheville 47.07 Charleston 51.53 Charleston 44.05 Charlotte 43.51 Atlantic_City 40.59 Portland 45.83 New_Orleans 64.16 New_York 49.69 Baltimore 41.94 Baton_Rouge 63.08 Columbia 48.27 Cleveland 38.71 Columbus 38.52 Hartford 46.16 Lexington 45.91 Little_Rock 50.93 Washington 39.35 Louisville 44.54 Montgomery 54.77 Mt._Washington 101.91 Nashville 48.11 St_Louis 38.75 Philadelphia 42.05 Providence 46.45 Savannah 49.58 Pittsburgh 37.85 Vero_Beach 51.93 Wilmington 42.81 [38 cities]
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started