Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA program I have this in my code but i dont know what it references or means. it has an error that i cant resolve

JAVA program

I have this in my code but i dont know what it references or means. it has an error that i cant resolve does anyone know how i can fix this? thanks

image text in transcribed

image text in transcribed

//here is the entire class

package com.paycheck.controller;

import com.paycheck.entity.Employee; import com.paycheck.entity.Paycheck; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.Button; import javafx.scene.control.DatePicker; import javafx.scene.control.TextField; import javafx.scene.text.Font; import javafx.stage.FileChooser;

import java.io.*; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.List;

public class Controller {

@FXML public Button openBtnId;

@FXML public Button printPaycheckId;

@FXML public TextField nameId;

@FXML public DatePicker dateOfBirthId;

@FXML public TextField addressId;

@FXML public TextField yearsOfExperience;

@FXML public TextField welcomeId;

private Employee employee;

public void printPaycheckBtnAction(ActionEvent event) { if(employee != null) { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Save Paycheck"); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Text Files", "*.txt")); File file = fileChooser.showSaveDialog(null); if(file != null){ SaveFile(employee.toString(), file); } System.out.println(employee.toString()); } }

private void SaveFile(String content, File file){ try { FileWriter fileWriter = new FileWriter(file); fileWriter.write(content); fileWriter.close(); } catch (IOException ex) { } }

public void openBtnAction(ActionEvent actionEvent) { if (nameId.getText().isEmpty() || addressId.getText().isEmpty() || yearsOfExperience.getText().isEmpty()) { welcomeId.setFont(new Font("System", 15)); welcomeId.setText("Please input all fields"); return; }

FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open Resource File"); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Text Files", "*.txt")); File selectedFile = fileChooser.showOpenDialog(null); if (selectedFile != null) {

welcomeId.setFont(new Font("System", 23)); welcomeId.setText("Welcome!");

List strings = readFromFile(selectedFile); int experience = Integer.parseInt(yearsOfExperience.getText()); String date = dateOfBirthId.getValue().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); employee = new Employee(nameId.getText(), date, addressId.getText(), experience); employee.setPaycheck(new Paycheck(findWage(strings, employee.getYearsOfExperience()))); }

}

private List readFromFile(File file) { List list = new ArrayList();

try (BufferedReader br = new BufferedReader(new FileReader(file))) { String line; while ((line = br.readLine()) != null) { list.add(line); } } catch (IOException e) { e.printStackTrace(); } return list; }

private int findWage(List list, int experience) { int from; int to; int wage = 0; for (int i = 1; i

wage = Integer.parseInt(list.get(i).substring(list.get(i).indexOf('$'), list.get(i).length()).replaceAll("[^0-9]", "").trim()); break; } else { from = Integer.parseInt(list.get(i).substring(0, list.get(i).indexOf('')).trim()); to = Integer.parseInt(list.get(i).substring(list.get(i).indexOf('') + 1, list.get(i).indexOf('$')).trim()); } if ((experience >= from && experience

}

.indexof(a)).trim()); ex

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

What is DDL?

Answered: 1 week ago