Hey guys I am needing to create a data mining program in Java code. I am using NetBeans and created a JavaFX application. I need this program to read a file, analyze the data (calculate percentages based on total sales of each group to overall sales of company, and add an organizational value code to each group), then write this information to a new file. So far I have been able to code to find the file and open it but I cannot figure out how to do the analysis portion. Could you please help me figure this out. I have attached the code I have come up with so far.
package businesssalesdataanalysis;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.stage.FileChooser;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author Anthony
*/
public final class BusinessSalesDataAnalysis extends Application {
private final Desktop desktop = Desktop.getDesktop();
@Override
public void start(final Stage primaryStage) {
primaryStage.setTitle("Business Sales Data Analysis");
final FileChooser fileChooser = new FileChooser();
final Button uploadButton = new Button("Upload a file");
uploadButton.setOnAction(
new EventHandler<ActionEvent>(){
@Override
public void handle(final ActionEvent e){
configureFileChooser(fileChooser);
File file = fileChooser.showOpenDialog(primaryStage);
if (file != null){
openFile(file);
}
}
});
final GridPane inputGridPane = new GridPane();
GridPane.setConstraints(uploadButton, 100, 50);
inputGridPane.setHgap(6);
inputGridPane.setVgap(6);
inputGridPane.getChildren().addAll(uploadButton);
final Pane rootGroup = new VBox(12);
rootGroup.getChildren().addAll(inputGridPane);
rootGroup.setPadding(new Insets(12, 12, 12, 12));
primaryStage.setScene(new Scene(rootGroup));
primaryStage.show();
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Application.launch(args);
}
private static void configureFileChooser(final FileChooser fileChooser){
fileChooser.setTitle("Choose a File");
fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
fileChooser.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("All Files", "*.*"),
new FileChooser.ExtensionFilter("DOC", ".doc"),
new FileChooser.ExtensionFilter("DOCX", ".docx")
);
}
private void openFile(File file){
try{
desktop.open(file);
}
catch (IOException ex){
Logger.getLogger(BusinessSalesDataAnalysis.class.getName()).log(Level.SEVERE, null, ex);
}
}
}