So our assignment calls for us to copy data into a text file and use the file with the data in it to calculate some stuff. Everything works EXCEPT for the calculation of percent increase/decrease between the numbers. Below the code is my current output.

import java.io.*;

import java.util.*;

public class Cert{

public static void main(String[] args)

throws FileNotFoundException{

Scanner certFile = new Scanner(new File("C:\\Users\\Zofia\\Documents\\Courses\\COSC 236\\Programs\\Lab5\\cert1.txt"));

int total = 0;

int newVul = 1;

int oldVul;

while (certFile.hasNextInt()){

int year = certFile.nextInt();

oldVul = newVul;

newVul = certFile.nextInt();

if (oldVul!=newVul){

double pChange = (double)((newVul-oldVul)/oldVul)*100;

total +=newVul;

System.out.println("In the year " + year + ", there were " + newVul + " vulnerabilities.");

if (total!=newVul){

System.out.println("There is a " + pChange + "% change between " + (year-1) +" and " + year);

}

}

}

System.out.println("The total vulnerabilities is " + total);

}

}

In the year 1995, there were 171 vulnerabilities.

In the year 1996, there were 345 vulnerabilities.

There is a 100.0% change between 1995 and 1996

In the year 1997, there were 311 vulnerabilities.

There is a 0.0% change between 1996 and 1997

In the year 1998, there were 262 vulnerabilities.

There is a 0.0% change between 1997 and 1998

In the year 1999, there were 417 vulnerabilities.

There is a 0.0% change between 1998 and 1999

In the year 2000, there were 1090 vulnerabilities.

There is a 100.0% change between 1999 and 2000

In the year 2001, there were 2437 vulnerabilities.

There is a 100.0% change between 2000 and 2001

In the year 2002, there were 4129 vulnerabilities.

There is a 0.0% change between 2001 and 2002

In the year 2003, there were 3784 vulnerabilities.

There is a 0.0% change between 2002 and 2003

In the year 2004, there were 3780 vulnerabilities.

There is a 0.0% change between 2003 and 2004

In the year 2005, there were 5990 vulnerabilities.

There is a 0.0% change between 2004 and 2005

In the year 2006, there were 8064 vulnerabilities.

There is a 0.0% change between 2005 and 2006

In the year 2007, there were 7236 vulnerabilities.

There is a 0.0% change between 2006 and 2007

The total vulnerabilities is 38016.