Get Instant Help From 5000+ Experts For
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing:Proofread your work by experts and improve grade at Lowest cost

And Improve Your Grades
myassignmenthelp.com
loader
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Guaranteed Higher Grade!
Free Quote
wave

Upon successful completion of this unit students should be able to:

a. Analyse and dissect simple design and programming problems

b. Demonstrate basic knowledge of object oriented programming concepts and syntax

c. Implement a well-designed modularised solution to small programming problems

d. Develop and/or implement testing schedules

Method Details

We have one ReadSnowfallData.java which comprises of various methods. 

List of methods in this file:-

  1. main: -

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. 

  1. startPrg: -

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. 

  1. saveFile: -

This method takes atores the current array into snowfall.dat file. 

  1. getTotal: -

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. 

  1. sortByAverage: -

This method makes the use of getAverage method to performs the sorting of the array according to the average snowfall of a site. 

  1. swap: -

This method takes two array indexes as arguments and then sorts the array elements present at these two indexes. 

  1. sortByTotal: -

This method makes the use of getTotal method to performs the sorting of the array according to the total snowfall of a site. 

  1. viewData: -

This method prints the snowfall of all the sites for various years.

  1. addNewSiteData: -

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. 

  1. addNewYearData: -

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. 

  1. exit: -

This method prints an exit message and terminates the program. 

  1. menu: -

This method prints the menu choices available and makes the use of getInt method to return one choice to the user. 

  1. getInt: -

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. 

  1. getDouble: -

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: -

  1. main: -
  2. set dis as new datastream to input file
  3. set rows as int value read from dis
  4. set cols as int value read from dis
  5. repeat steps 5 to 8
  6. set data as read double value from dis
  7. set array[i][j] as data
  8. set j as j+1
  9. if j is equal to columns, set i as i+1 and j as 0
  10. close dis
  11. call strtPrg 
  1. startPrg: -
  2. repeat steps 2 to 10
  3. get choice as result from calling method menu
  4. if choice is equal to 1 call addNewYearData and then break
  5. if choice is equal to 2 call addNewSiteData and then break
  6. if choice is equal to 3 call viewData and then break
  7. if choice is equal to 4 call sortByTotal and then break
  8. if choice is equal to 5 call sortByAverage and then break
  9. if choice is equal to 6 call saveFile and then break
  10. if choice is equal to 5 call exit and then break 
  1. saveFile: -
  2. set dis as DataOutputStream to snowfallData1.dat
  3. write array.length as int to dis
  4. wite array[0].length as int to dis
  5. for i in range 0 to length of array repeat step 5
  6. for j in range 0 to array[i].length repeat step 6
  7. write array[i][j] as double to dis
  8. close dis 
  1. getTotal: -
  2.  set tot as 0.0
  3. for i in range 0 to length of array repeat step 3
  4. for j in range 0 to array[i].length repeat step 4
  5. set tot as tot+ array[i][j]
  6. return tot to the calling function

E.getAverage: -

  1.  set tot as 0.0
  2. for i in range 0 to length of array repeat step 3
  3. for j in range 0 to array[i].length repeat step 4
  4. set tot as tot+ array[i][j]
  5. return tot/length of array to the calling function 
  1. sortByAverage: -
  2.   if length of array is 1 return
  3. for i in range 0 to length of array repeat step 3
  4. for j in range 0 to array[i].length repeat step 4
  5. if getAverage(array[j]) is less than getAverage(array[i]) call swap(i,j)  
  1. swap: -

in1 and in2 are arguments

  1. for i in range 0 to length of array repeat step 2
  2. set t as array[in1][i]
  3. set array[in1][i] as array[in2][i]
  4. set array[in1][2] as t 
  1. sortByTotal:
  2.   if length of array is 1 return
  3. for i in range 0 to length of array repeat step 3
  4. for j in range 0 to array[i].length repeat step 4
  5. if getTotal(array[j]) is less than getTotal(array[i]) call swap(i,j) 
  1. viewData: -
  2. for i in range 0 to length of array repeat step 2 and 3
  3. Display “Site” +(i+1)
  4. for j in range 0 to array[i].length repeat step 4
  5. Display array[i][j]+”t”; 
  1. addNewSiteData: -
  2. set new array as new double array[array.length+1][array[0].length
  3. for i in range 0 to length of array repeat step 3
  4. for j in range 0 to array[i].length repeat step 4
  5. set newArr[i][j] as array[i][j]
  6. setarray as new array
  7. for i in range 0 to length of array repeat step 7
  8. set array[array.length-1][i] as double value from callin getDouble 
  1. addNewYearData: -

1 . set new array as new double array[array.length][array[0].length+1]

  1. for i in range 0 to length of array repeat step 3
  2. for j in range 0 to array[i].length repeat step 4
  3. set newArr[i][j] as array[i][j]
  4. setarray as new array
  5. for i in range 0 to length of array repeat step 3
  6. set array[i][array[i].length-1] as double value from callin getDouble 
  1. exit: -
  2. Display “Exitting”
  3. terminate the application 
  1. menu: -
  2. Display "nnSouth Pacific Hotel (snowfall) Menu options: "
  3. Display "1. Add new Year data."
  4. Display "2. Add new site data."
  5. Display "3. View data"
  6. Display "4. Sort by Total"
  7. Display "5. Sort by Average"
  8. Display "6. Save to File"
  9. Display "7. Exit"
  10. return getInt(1,7)  
  1. getInt: -
  2. set value as 0
  3. set value as input from user
  4. if value < min or value greater than max throw exception
  5. else return value
  6. if exception call getInt 
  1. getDouble: -
  2. set value as 0
  3. set value as double input from user
  4. return value
  5. if exception call  getDouble  

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:

  1. Please make sure that you have snowfall.dat in the same directory as program.
  2. No errors/bugs in the program
Cite This Work

To export a reference to this article please select a referencing stye below:

My Assignment Help. (2021). Methods In ReadSnowfallData.java Essay Snowfall Data Manipulation And Shorten Its Length.. Retrieved from https://myassignmenthelp.com/free-samples/oodp101-object-oriented-design-and-programming/further-functionality.html.

"Methods In ReadSnowfallData.java Essay Snowfall Data Manipulation And Shorten Its Length.." My Assignment Help, 2021, https://myassignmenthelp.com/free-samples/oodp101-object-oriented-design-and-programming/further-functionality.html.

My Assignment Help (2021) Methods In ReadSnowfallData.java Essay Snowfall Data Manipulation And Shorten Its Length. [Online]. Available from: https://myassignmenthelp.com/free-samples/oodp101-object-oriented-design-and-programming/further-functionality.html
[Accessed 21 May 2024].

My Assignment Help. 'Methods In ReadSnowfallData.java Essay Snowfall Data Manipulation And Shorten Its Length.' (My Assignment Help, 2021) <https://myassignmenthelp.com/free-samples/oodp101-object-oriented-design-and-programming/further-functionality.html> accessed 21 May 2024.

My Assignment Help. Methods In ReadSnowfallData.java Essay Snowfall Data Manipulation And Shorten Its Length. [Internet]. My Assignment Help. 2021 [cited 21 May 2024]. Available from: https://myassignmenthelp.com/free-samples/oodp101-object-oriented-design-and-programming/further-functionality.html.

Get instant help from 5000+ experts for
question

Writing: Get your essay and assignment written from scratch by PhD expert

Rewriting: Paraphrase or rewrite your friend's essay with similar meaning at reduced cost

Editing: Proofread your work by experts and improve grade at Lowest cost

loader
250 words
Phone no. Missing!

Enter phone no. to receive critical updates and urgent messages !

Attach file

Error goes here

Files Missing!

Please upload all relevant files for quick & complete assistance.

Plagiarism checker
Verify originality of an essay
essay
Generate unique essays in a jiffy
Plagiarism checker
Cite sources with ease
support
Whatsapp
callback
sales
sales chat
Whatsapp
callback
sales chat
close