We have one ReadSnowfallData.java which comprises of various methods.
List of methods in this file:-
This is the main method for this program. The program executions start from this method. This method reads the data from the snowfall.dat file and make an array from this data. It also calls the startPrg to start further functionality.
This is the method that is being called from main method. It contains an infinite loop which calls the menu function to take user choice and then call various methods to perform the functionality selected by the user.
This method takes atores the current array into snowfall.dat file.
This method finds and returns the total of an array received as argument.
5.getAverage: –
This method finds the average of the array passed as argument and returns it to the calling function.
This method makes the use of getAverage method to performs the sorting of the array according to the average snowfall of a site.
This method takes two array indexes as arguments and then sorts the array elements present at these two indexes.
This method makes the use of getTotal method to performs the sorting of the array according to the total snowfall of a site.
This method prints the snowfall of all the sites for various years.
This method resizes the array and adds a new row to the current 2D array. After resizing, it takes the snowfall data from the user for all the years and stores it into array.
This method resizes the array and adds a new column to the current 2D array. After resizing, it takes the snowfall data from the user for the New Year for all the sites and stores it into array.
This method prints an exit message and terminates the program.
This method prints the menu choices available and makes the use of getInt method to return one choice to the user.
This method takes two argument min and max. This method performs the exception handling and returns an integer in the range between min and max.
This method gets a double value from the user, and returns this value to the calling function. This method makes sure that a valid double value is entered by the user.
Pseudocode for the various methods: –
E.getAverage: –
in1 and in2 are arguments
1 . set new array as new double array[array.length][array[0].length+1]
IPO Table: –
Method Name |
Input |
Process |
Output |
main |
NA |
Read file add the read data to array call startPrg |
NA |
startPrg |
NA |
Print menu Get user choice perform functyion accordingly |
NA |
saveFile |
NA |
Save the array to file |
NA |
getTotal |
Double [] arr |
Get total of the passed array |
total of the array |
getAverage |
Double [] arr |
Get average of the passed array |
Average of the array |
sortByAverage |
NA |
Sort the array by site average |
NA |
swap |
Int in1, int in2 |
Swap elements at index in1 and in2 |
NA |
sortByTotal |
NA |
Sort the array by site total |
NA |
viewData |
NA |
Print the data of the array |
NA |
addNewSiteData |
NA |
Resize the array Add data for all the years for a new site |
NA |
addNewYearData |
NA |
Resize the array Add data for all the sites for a new year |
NA |
Exit |
NA |
Print exit message terminate the application |
NA |
menu |
NA |
Print menu return a choice from user |
Int value as user choice |
getInt |
Int min, int max, int prompt |
Get an int value perform validation return the read value to calling function |
Int value read from user |
getDouble |
String prompt |
Get an double value perform validation return the read value to calling function |
Double value read from user |
Test Data: –
# |
Test Input |
Expected Output |
Result |
1 |
Add Year data: Enter year 6 snowfall data for site 1 : 1.1 Enter year 6 snowfall data for site 2 : 2.3 Enter year 6 snowfall data for site 3 : 4.5 Enter year 6 snowfall data for site 4 : 6.67 |
Site 1 : 42.7 45.8 44.9 40.3 52.0 1.1 Site 2 : 50.8 52.4 49.6 54.7 50.0 2.3 Site 3 : 48.3 40.7 42.0 57.0 52.5 4.5 Site 4 : 51.3 43.8 46.7 48.3 54.7 6.67 |
Pass |
2 |
Add Site data :- Enter year 1 snowfall data for site 5 : 2.3 Enter year 2 snowfall data for site 5 : 4.5 Enter year 3 snowfall data for site 5 : 6.7 Enter year 4 snowfall data for site 5 : 5.5 Enter year 5 snowfall data for site 5 : 4.4 Enter year 6 snowfall data for site 5 : 2.3 |
Site 1 : 42.7 45.8 44.9 40.3 52.0 1.1 Site 2 : 50.8 52.4 49.6 54.7 50.0 2.3 Site 3 : 48.3 40.7 42.0 57.0 52.5 4.5 Site 4 : 51.3 43.8 46.7 48.3 54.7 6.67 Site 5 : 2.3 4.5 6.7 5.5 4.4 2.3 |
Pass |
3 |
After sorting by total |
Site 1 : 2.3 4.5 6.7 5.5 4.4 1.1 Site 2 : 42.7 45.8 44.9 40.3 52.0 2.3 Site 3 : 48.3 40.7 42.0 57.0 52.5 4.5 Site 4 : 51.3 43.8 46.7 48.3 54.7 6.67 Site 5 : 50.8 52.4 49.6 54.7 50.0 2.3 |
Pass |
4. |
After sorting by average |
Site 1 : 2.3 4.5 6.7 5.5 4.4 1.1 Site 2 : 42.7 45.8 44.9 40.3 52.0 2.3 Site 3 : 48.3 40.7 42.0 57.0 52.5 4.5 Site 4 : 51.3 43.8 46.7 48.3 54.7 6.67 Site 5 : 50.8 52.4 49.6 54.7 50.0 2.3 |
Pass |
5. |
Save file |
Filr successfully saved to snowfall1.dat and can be read from the program |
Pass |
6. |
View Data |
Site 1 : 2.3 4.5 6.7 5.5 4.4 1.1 Site 2 : 42.7 45.8 44.9 40.3 52.0 2.3 Site 3 : 48.3 40.7 42.0 57.0 52.5 4.5 Site 4 : 51.3 43.8 46.7 48.3 54.7 6.67 Site 5 : 50.8 52.4 49.6 54.7 50.0 2.3 |
Pass |
7. |
Exit |
Program terminates after printing exit message |
Pass |
User guide:
Essay Writing Service Features
Our Experience
No matter how complex your assignment is, we can find the right professional for your specific task. Contact Essay is an essay writing company that hires only the smartest minds to help you with your projects. Our expertise allows us to provide students with high-quality academic writing, editing & proofreading services.Free Features
Free revision policy
$10Free bibliography & reference
$8Free title page
$8Free formatting
$8How Our Essay Writing Service Works
First, you will need to complete an order form. It's not difficult but, in case there is anything you find not to be clear, you may always call us so that we can guide you through it. On the order form, you will need to include some basic information concerning your order: subject, topic, number of pages, etc. We also encourage our clients to upload any relevant information or sources that will help.
Complete the order formOnce we have all the information and instructions that we need, we select the most suitable writer for your assignment. While everything seems to be clear, the writer, who has complete knowledge of the subject, may need clarification from you. It is at that point that you would receive a call or email from us.
Writer’s assignmentAs soon as the writer has finished, it will be delivered both to the website and to your email address so that you will not miss it. If your deadline is close at hand, we will place a call to you to make sure that you receive the paper on time.
Completing the order and download