In: Computer Science
Please write this program in JGRASP thanks you so much
This program assesses your ability to use functions, arrays, for loops, and if statements where needed.You are writing a program to track bird sightings in Prince William Countyfor aweekend event where bird watchers watch birds and record each unique species that they see. Over a weekend, Saturday and Sunday, the bird watchers (aka birders) are going to record how many birdspeciesthey sighteach day. You begin by asking the user how many bird watchers are participating in the event. Validate the response with a while loop to ensure that the value entered is between 0 and 100. Once you have a valid response, a for loop is entered for processing 4 parallel arrays. The size of each of the parallel arrays is equal to the number of bird watchersentered by the user. The first array will store the name of the Bird Watcher.The secondarray will store how many sightings (quantity) of different birds that the bird watcher reports forSaturday. Use a while loop to validate the quantityto make sure that it falls in therange of 0 to 250inclusive.(Supposedly the world record for sighting different speciesof birds in one day by one person is 200; therefore,250 should bereasonablefor the maximum quantityofbirds sighted by one person in a single day.)The third array will store how many sightings (quantity) of different birds that the bird watcher reports forSunday. Use a while loop to validate the quantityto make sure that it falls in therange of 0 to 250inclusive.The fourth array will store the totalsightingsfor both daysthat adds the sightings for Saturday+ the sightings for Sunday reported by the bird watcher.If you have at least 1 bird watcher, print the contents of the parallel arrays meaning the bird watcher’sname, Saturday sightings, and Sunday sightings, and Total Sightings for each bird watcher. You also need to calculate the average sightings from the Total Sightings array by using a calcAverage() function.You also need to search for the Bird Watcher with the most sightings and print their name out with the number of sightings for that person.If you do not have any bird watchers(meaning if the user entered 0 bird watcherswhen prompted at the beginning of the program), end the program with a goodbye message.The following functions are required although:•A function to calculate the average ofthe Total Sightings array.The next page shows the output from the program running with some test data. Remember that your program must run for any number of bird watchersand not just these 3 bird watchersand data shown below.Welcome to the Prince William County Bird Watching weekend tracking system.___________________________________________________________
Please enter the number of bird watchers:
3
-------------------------Bird Watcher1 -------------------------
Please enter the bird watcher’sName:
Ima Watcher
Please enter the birds sighted on Saturday:
25
Please enter the birds sighted on Sunday:
30
-------------------------Bird Watcher2-------------------------
Please enter the bird watcher’sname:
Ann Lookin
Please enter the birds sighted on Saturday:
30
Please enter the birds sighted on Sunday:
35
-------------------------Bird Watcher3 -------------------------
Please enter the bird watcher’sname:
Guy Oakley
Please enter the birds sighted on Saturday:
35
Please enter the birds sighted on Sunday:
40
------------------------------------------------PWC Birdwatching Statistics-----------------------------------------
Bird Watcher SaturdaySighings Sunday Sightings. Total Sightings
Ima Watcher 25 30 55
Ann Lookin 30 35 65
Guy Oakley 35 40 37.5
Average Sightings 52.5
The Bird Watcher with the most sightingsof 75 is Guy Oakley.
----------------------------------------------Thanks For Using Our Program---------------------------------
The following program gives you a solution:
The file name is "BirdWatchers.java"
Source Code:
import java.util.*;
public class BirdWatchers {
public static void main(String[] args) {
int bw;
int bwcount=0;
System.out.println("Welcome to the Prince William County Bird
Watching weekend tracking system");
System.out.println("---------------------------------------------------");
System.out.println("Please enter the number of bird
watchers:");
Scanner sc = new Scanner(System.in);
bw = sc.nextInt();
String Wname[]=new String[bw];
int birdssat[]=new int[bw];
int birdssun[]=new int[bw];
int birdtotal[]=new int[bw];
int cnt=1;
if(bw>0 && bw<100)
{
while(bw>0)
{
System.out.println("-------------------------Bird Watcher"+cnt+"
-------------------------");
System.out.println("Please enter the bird watcher'sName:");
Wname[bwcount]=sc.next();
System.out.println("Please enter the birds sighted on
Saturday:");
birdssat[bwcount]=sc.nextInt();
System.out.println("Please enter the birds sighted on
Sunday:");
birdssun[bwcount]=sc.nextInt();
birdtotal[bwcount]=birdssat[bwcount]+birdssun[bwcount];
bwcount++;
cnt++;
bw--;
}
System.out.println("------------------------------------------------PWC
Birdwatching
Statistics-----------------------------------------");
System.out.println("Bird Watcher SaturdaySighings Sunday Sightings
Total Sightings");
for(int i=0;i<bwcount;i++)
{
System.out.println(Wname[i]+" "+birdssat[i]+" "+birdssun[i]+"
"+birdtotal[i]);
}
System.out.println("Average Sightings
"+calcAverage(bwcount,birdtotal));
mostSightings(bwcount,birdtotal,Wname);
System.out.println("----------------------------------------------Thanks
For Using Our Program---------------------------------");
}
else
{
System.out.println("----------------------------------------------
goodbye---------------------------------");
}
}
static float calcAverage(int bcount,int[] btotal)
{
int total=0;
for(int i=0;i<bcount;i++)
{
total+=btotal[i];
}
float avg=total/bcount;
return avg;
}
static void mostSightings(int bcount,int[] btotal,String[]
wname)
{
int max = btotal[0];
int index = 0;
for(int i=0;i<btotal.length;i++)
{
if (max < btotal[i])
{
max = btotal[i];
index = i;
}
}
System.out.println("The Bird Watcher with the most sightingsof
"+max+" is "+wname[index]);
}
}
Excepted Output:
Case 1:
----jGRASP: operation complete.
----jGRASP exec: java BirdWatchers
Welcome to the Prince William County Bird Watching weekend tracking
system
---------------------------------------------------
Please enter the number of bird watchers:
2
-------------------------Bird Watcher1
-------------------------
Please enter the bird watcher'sName:
Madhu
Please enter the birds sighted on Saturday:
23
Please enter the birds sighted on Sunday:
23
-------------------------Bird Watcher2
-------------------------
Please enter the bird watcher'sName:
Sona
Please enter the birds sighted on Saturday:
67
Please enter the birds sighted on Sunday:
66
------------------------------------------------PWC Birdwatching
Statistics-----------------------------------------
Bird Watcher SaturdaySighings Sunday Sightings Total
Sightings
Madhu 23 23 46
Sona 67 66 133
Average Sightings 89.0
The Bird Watcher with the most sightingsof 133 is Sona
----------------------------------------------Thanks For Using Our
Program---------------------------------
----jGRASP: operation complete.
Case 2:
----jGRASP: operation complete.
----jGRASP exec: java BirdWatchers
Welcome to the Prince William County Bird Watching weekend tracking
system
---------------------------------------------------
Please enter the number of bird watchers:
0
----------------------------------------------
goodbye---------------------------------
----jGRASP: operation complete.
Case 3:
----jGRASP exec: java BirdWatchers
Welcome to the Prince William County Bird Watching weekend tracking
system
---------------------------------------------------
Please enter the number of bird watchers:
5
-------------------------Bird Watcher1
-------------------------
Please enter the bird watcher'sName:
Madhu
Please enter the birds sighted on Saturday:
12
Please enter the birds sighted on Sunday:
14
-------------------------Bird Watcher2
-------------------------
Please enter the bird watcher'sName:
Sona
Please enter the birds sighted on Saturday:
67
Please enter the birds sighted on Sunday:
12
-------------------------Bird Watcher3
-------------------------
Please enter the bird watcher'sName:
Swathi
Please enter the birds sighted on Saturday:
28
Please enter the birds sighted on Sunday:
34
-------------------------Bird Watcher4
-------------------------
Please enter the bird watcher'sName:
Kiran
Please enter the birds sighted on Saturday:
45
Please enter the birds sighted on Sunday:
22
-------------------------Bird Watcher5
-------------------------
Please enter the bird watcher'sName:
Nani
Please enter the birds sighted on Saturday:
77
Please enter the birds sighted on Sunday:
88
------------------------------------------------PWC Birdwatching
Statistics-----------------------------------------
Bird Watcher SaturdaySighings Sunday Sightings Total
Sightings
Madhu 12 14 26
Sona 67 12 79
Swathi 28 34 62
Kiran 45 22 67
Nani 77 88 165
Average Sightings 79.0
The Bird Watcher with the most sightingsof 165 is Nani
----------------------------------------------Thanks For Using Our
Program---------------------------------
----jGRASP: operation complete.
Screenshots: