Question

In: Computer Science

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

Solutions

Expert Solution

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:


Related Solutions

please write the java code so it can run on jGRASP Thanks! 1 /** 2 *...
please write the java code so it can run on jGRASP Thanks! 1 /** 2 * PassArray 3 * @Sherri Vaseashta 4 * @Version 1 5 * @see 6 */ 7 import java.util.Scanner; 8 9 /** 10 This program demonstrates passing an array 11 as an argument to a method 12 */13 14 public class PassArray 15 { 16 public static void main(String[] args) 17 { 18 19 final int ARRAY_SIZE = 4; //Size of the array 20 // Create...
please write the java code so it can run on jGRASP Thanks! CODE 1 1 /**...
please write the java code so it can run on jGRASP Thanks! CODE 1 1 /** 2 * SameArray2.java 3 * @author Sherri Vaseashta4 * @version1 5 * @see 6 */ 7 import java.util.Scanner;8 public class SameArray29{ 10 public static void main(String[] args) 11 { 12 int[] array1 = {2, 4, 6, 8, 10}; 13 int[] array2 = new int[5]; //initializing array2 14 15 //copies the content of array1 and array2 16 for (int arrayCounter = 0; arrayCounter < 5;...
Please explain your answer. Thanks so much!! Suppose that you had to explain to a person...
Please explain your answer. Thanks so much!! Suppose that you had to explain to a person (who is not an economist) why a current account deficit must be accompanied by a financial or capital account surplus. What would you say?
Please Reply with an answer as soon as possible, will appreciate it so much. Thanks in...
Please Reply with an answer as soon as possible, will appreciate it so much. Thanks in advance. Case Problem: You are a HR assistant manager in a company employing many expatriates from around the world. Your company has selected ‘FutureFunds Pension Planners’ to provide your employees with an international pension plan that takes advantage of tax laws. The plan allows the company to make tax free contributions to the employee pension funds. It also allows Individuals enrolling in the plan...
please right make it so that it can run on jGRASP and java code please thank...
please right make it so that it can run on jGRASP and java code please thank you Debug Problem 1: As an intern for NASA, you have been instructed to debug a java program that calculates the speed that sound travels in water. Details about the formulas and correct results appear in the comments area at the top of the program Here is the code to debug: importjava.util.Scanner; /**    This program demonstrates a solution to the    The Speed of Sound...
Write a short, cohesive java program in jGrasp that interacts with the user and does the...
Write a short, cohesive java program in jGrasp that interacts with the user and does the following: create at least 2 double variables create at least 1 constant get at least 1 string input from the user get at least 1 int/double input from the user include both, incorporating the input you got from the user: 1 multiway if-else with at least 3 "else if" 1 nested if Your program should combine all of these into one cohesive, interactive program...
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...
PLEASE WRITE IN C++ PROGRAM THANKS - QUEUES Please study the code posted below. Please rewrite...
PLEASE WRITE IN C++ PROGRAM THANKS - QUEUES Please study the code posted below. Please rewrite the code implementing a template class using a linked list instead of an array. Note: The functionality should remain the same /** * Queue implementation using linked list C style implementation ( no OOP). */ #include <cstdio> #include <cstdlib> #include <climits> #include <iostream> #define CAPACITY 100 // Queue max capacity using namespace std; /** Queue structure definition */ struct QueueType { int data; struct...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print...
Write a Java program using jGRASP directions are as follows: Uses a while loop to print the numbers from 3 - 19. Uses a do-while loop to print the numbers from 42 - 56. Uses a for loop to print the numbers from 87 - 95. Asks the user for 2 numbers. Uses a loop to print all numbers between the given numbers, inclusive. Note: Consider that your user's second number can be lower! (see example below) Note: Also consider...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT