Colorado State University Logo | Summer 21: CS 150 - Culture and Coding (AUCC 3B/GT-AH3) Colorado State University Logo | Summer 21: CS 150 - Culture and Coding (AUCC 3B/GT-AH3)
Summer 21: CS 150 - Culture and Coding (AUCC 3B/GT-AH3)
Computer Science

Practical Project > Insecticide & Bees

Effects of insecticide on bees (usda.gov). Field and Lab data regarding the effects of 4 sublethal concentrations of a neonicotinoid insecticide (Imidacloprid) on honey bees and about a dozen native bee species.

Details

The columns in the data are in order:

  • Level of Sociality
  • Degree of floral specialization
  • Habitat floral host
  • bee species
  • bee genus/species
  • Date bee captured and installed in bioassay unit (Julian day)
  • bee sex
  • Imidacloprid concentration (parts per billion)
  • bee longevity in bioassay (days)
  • days paralyzed
  • days active
  • % of days bee is paralyzed

The parts you will need for the methods you are tested on are:

  • Level of Sociality
    this indicates whether a bee is social or solitary

  • bee genus/species
    This states the genus or species of the bee

  • Imidacloprid concentration (parts per billion)
    States the concentration of insecticide used

  • bee longevity in bioassay (days)
    This states the days the bee survived

  • days paralyzed
    This states the amount of days the bee was paralyzed

Required Methods To Implement (graded)

We will grade the following methods. Please note, that while there may be different ways to implement them, and you are free to even write helper methods (which we did ourselves) - we need the method names to match the following specification.

CSVReader

This file specifically is used to read the Comma Separated Value files using a Scanner Object. We also used it to help store the indices of the columns in constant variables for easy use in GenderStats.java.

public void initialize(String file)

This method will initialize a class level scanner object based on a File (new File(…)). The name of the file will be passed in. You can assume it is a correct name, but you should also try and catch the IOException that is required by calling new file. The following code can help you get started. You may also want to look at the Digital Humanities lab for an example.

Here is some example code that will help you.

try {
     fileScanner = new Scanner(new File(file));
 }catch (IOException io) {
     io.printStackTrace();
}

public boolean hasNext()

Returns if the scanner has more lines to read if the scanner has been initialized. If the scanner hasn’t been initialized, it will return false. Looking at how scanner checks to see if more lines need to be read will help with this method.

public String[] getNext()

If the scanner has more lines to read, it reads the line and returns a String array of all the values in the line - broken up by the comma (‘,’) delimiter! This is essentially how CSV files are stored.

Stats.java

This file is the main driver file of your program. It will display the averages for the given input (Sociality or Genus/Species).

The final output will print out the average imidacloprid concentration, longevity, and days paralyzed for the given input (Sociality or Genus/Species). Use the following examples as a template for the output

Example given genus (Apis):

Averages for Apis bees:
Average Imidacloprid Concentration: 32.02
Average Longevity: 7.06
Average Days Paralyzed: 1.71

Example given Sociality (Solitary):

Averages for Solitary bees:
Average Imidacloprid Concentration: 29.48
Average Longevity: 5.27
Average Days Paralyzed: 1.33

Example given invalid Genus/Species:

Genus: Test not found

Suggestions / Insights

Before you start coding it is always good to plan your code out. Look at what each method is asking for and think about how you can accomplish it. (Think about how an average is calculated, and how to compare strings.)

If you would like to expand upon the data there are many different things you could look for. Examples are:

  • Floral host differences across averages
  • Sex differences across averages
  • Overall statistics of the bees

These are just examples, feel free to come up with your own ideas of sorting/processing the data.

Reference

  • Sampson, Blair J.. (2019). Raw data for imidacloprid effects on native bees. Ag Data Commons. https://doi.org/10.15482/USDA.ADC/1503843. Accessed 2020-11-7.

Computer Science Department

279 Computer Science Building
1100 Centre Avenue
Fort Collins, CO 80523
Phone: (970) 491-5792
Fax: (970) 491-2466

Summer 21: CS 150 - Culture and Coding (AUCC 3B/GT-AH3)

Survey of computer science, formal logic, and computational thinking. Explores the historical, gender, and cultural perspectives on the role of technology in society. Includes learning a basic programming language. Students will be expected to write small programs, and construct written arguments on ways in which technology influences our modern culture. Previous computer science experience not necessary.