Question

In: Computer Science

Please use jGRASP program to solve the following project. This program assesses your ability to use...

Please use jGRASP program to solve the following project.

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 County for a weekend 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 bird species they sight each 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 watchers entered by the user.

The first array will store the name of the Bird Watcher.

The second array will store how many sightings (quantity) of different birds that the bird watcher reports for Saturday. Use a while loop to validate the quantity to make sure that it falls in the range of 0 to 250 inclusive. (Supposedly the world record for sighting different species of birds in one day by one person is 200; therefore, 250 should be reasonable for the maximum quantity of birds 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 for Sunday. Use a while loop to validate the quantity to make sure that it falls in the range of 0 to 250 inclusive.

The fourth array will store the total sightings for both days that 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’s name, 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 watchers when 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 of the 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 watchers and not just these 3 bird watchers and data shown below.

Welcome to the Prince William County Bird Watching weekend tracking system.

___________________________________________________________

Please enter the number of bird watchers:

3

-------------------------Bird Watcher 1 -------------------------

Please enter the bird watcher’s Name:

Ima Watcher

Please enter the birds sighted on Saturday:

25

Please enter the birds sighted on Sunday:

30

-------------------------Bird Watcher 2 -------------------------

Please enter the bird watcher’s name:

Ann Lookin

Please enter the birds sighted on Saturday:

30

Please enter the birds sighted on Sunday:

35

-------------------------Bird Watcher 3 -------------------------

Please enter the bird watcher’s name:

Guy Oakley

Please enter the birds sighted on Saturday:

35

Please enter the birds sighted on Sunday:

40

------------------------------------------------PWC Birdwatching Statistics-----------------------------------------

Bird Watcher                     Saturday Sightings          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 sightings of 75 is Guy Oakley.

----------------------------------------------Thanks For Using Our Program---------------------------------

Solutions

Expert Solution

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.


Related Solutions

Please write this program in JGRASP thanks you so much This program assesses your ability to...
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...
Please use excel file to solve You are evaluating a project for your company. The project...
Please use excel file to solve You are evaluating a project for your company. The project will require equipment that has a purchase price of $500,000, and will need to include $60,000 for delivery costs and $70,000 for installation related expenses. The equipment will be depreciated using MACRS as a 10 year class asset. Assume you expect a salvage value of $50,000 at the end of the projects life. In addition, land will need to be purchased for $1,500,000. The...
c++ The purpose of this project is to test your ability to use files, class design,...
c++ The purpose of this project is to test your ability to use files, class design, operator overloading, and Strings or strings effectively in program design Create a program which will read a phrase from the user and create a framed version of it for printing. For example, the phrase "hello world"would result in: ********* * hello * * world * ********* Whereas the phrase "the sky is falling"might be: *********** * the * * sky * * is *...
Please use C programming to write the code to solve the following problem. Also, please use...
Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially: void inputStringFromUser(char *prompt, char *s, int arraySize); void songNameDuplicate(char *songName); void songNameFound(char *songName); void songNameNotFound(char *songName); void songNameDeleted(char *songName); void artistFound(char *artist); void artistNotFound(char *artist); void printMusicLibraryEmpty(void); void printMusicLibraryTitle(void); const int MAX_LENGTH = 1024; You will write a program that maintains information about your...
Create a new project called: ToDoList Purpose: To demonstrate your ability to use a linear structure  to...
Create a new project called: ToDoList Purpose: To demonstrate your ability to use a linear structure  to insert, contain, change, and remove data elements (Strings). Also to show that you can perform the detailed work in functions with the main function containing only the major program logic. Specifications: Create a new project called ToDoList and save it in the appropriate Lab folder. Step 1: To begin the main program, use an ArrayList or LinkedList, to declare a structure to hold String...
Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname10.java, using your last name and your first name, that does the following: Create two arrays that will hold related information. You can choose any information to store, but here are some examples: an array that holds a person's name and an array that hold's their phone number an array that holds a pet's name and an array that holds what type of animal that pet is an array that holds a student's...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname09.java, using your last name and your first name, that does the following: Declare an array reference variable called myFavoriteSnacks for an array of String type. Create the array so that it is able to hold 10 elements - no more, no less. Fill the array by having each array element contain a string stating one of your favorite foods/snacks. Note: Only write the name of the snack, NO numbers (i.e. Do not...
Using jGRASP, write a Java program named LastnameFirstname11.java, using your last name and your first name,...
Using jGRASP, write a Java program named LastnameFirstname11.java, using your last name and your first name, that does the following: Defines a method called generateNums. This method will create an array of size x, fill it with random numbers between y and z, then return the array. When you call the method, you must specify the size of the array (x), the beginning of your random number range (y), and the ending of your random number range (z). Defines a...
Please provide solutions to the following problems. Please use Excel to solve the problems and submit...
Please provide solutions to the following problems. Please use Excel to solve the problems and submit the Excel spreadsheet. A fair coin is tossed 15 times, calculate the probability of getting 0 heads or 15 heads A biased coin with probability of head being .6 is tossed 12 times. What is the probability that number of head would more than 4 but less than or equal to 10. You have a biased dice (with six faces numbered 1,2,3,4,5 and 6)...
Please provide solutions to the following problems. Please use Excel to solve the problems and submit...
Please provide solutions to the following problems. Please use Excel to solve the problems and submit the Excel spreadsheet. You started a new restaurant. Based on invoices for the first 30 days, you estimated your average grocery bill to be $20,000 with a standard deviation of $2000. You want to start another restaurant in a similar neighborhood and you are planning to prepare a brochure for investors and to work out a deal with a whole sale food distributor. Prepare...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT