i am almost through with this assignment but i keep getting the error
"unreported exception java.io.IOException; must be caught or declared to be thrown
" Am i writing my code out of order or am i missing a chunk of code? Thanks for your time!
import java.io.*;
import java.util.*;
import java.text.*;
public class database1 {
static Scanner console = new Scanner(System.in);
public static void main(String[] args) throws FileNotFoundException {
String empnumber;
String firstname;
String lastname;
String city;
String state;
String zipcode;
String jobtitle;
int salary;
int max = 200000;
int counter = 0;
FileWriter ryyt = new FileWriter("c:\\EmployeeData.txt");
BufferedWriter out = new BufferedWriter(ryyt);
while (counter < 9) {
System.out.print("Enter the employee number ...... ");
empnumber = console.next();
System.out.print("Enter employee's first name .... ");
firstname = console.next();
//firstname = Character.toUpperCase(firstname.charAt(0)) +
firstname.substring(1);
System.out.print("Enter employee's last name ..... ");
lastname = console.next();
lastname = Character.toUpperCase(lastname.charAt(0))
+ lastname.substring(1);
System.out.print("Enter employee's city .......... ");
city = console.next();
city = Character.toUpperCase(city.charAt(0)) + city.substring(1);
System.out.print("Enter employee's state ......... ");
state = console.next();
String upperstate = state.toUpperCase();
System.out.print("Enter employee's zip code ...... ");
zipcode = console.next();
System.out.print("Enter employee's job title ..... ");
jobtitle = console.next();
jobtitle = Character.toUpperCase(jobtitle.charAt(0))
+ jobtitle.substring(1);
System.out.print("Enter employee's salary ........ ");
salary = console.nextInt();
while (salary > max) {
if (salary > max) {
System.out.println(
"Salary is over the maxium allowed, re-enter please ...");
System.out.print("Enter employee's salary ........ ");
salary = console.nextInt();
} else {
System.out.println("Thank you please enter the next employee!");
}
}
System.out.println();
out.write(empnumber + ",");
out.write(firstname + ",");
out.write(lastname + ",");
out.write(city + ",");
out.write(upperstate + ",");
out.write(zipcode + ",");
out.write(jobtitle + ",");
out.write(salary + ",");
out.newLine();
counter = counter + 1;
}
out.close();
}
}