Untitled
unknown
plain_text
2 years ago
1.7 kB
5
Indexable
Change this java method to print to a csv file with the columns studyType relTol maxResult Wint Qint nteFlux and dEi0Int. When maxResult > Double.parseDouble(relTol), the line should be in red or a new column error should be added and set to true when this condition is respected public static void printToFile(String resultsFileName,String fileName, String studyType, String relTol, double maxResult, double Wint, double Qint, double nteFlux, double dEi0Int) { //Print data to file try { BufferedWriter out = new BufferedWriter(new FileWriter(resultsFileName,true)); out.write("---------------------------------"); out.newLine(); out.write("Case name: " + fileName); out.newLine(); out.write("Study type: " + studyType); out.newLine(); out.write("Relative tolerance : " + relTol); out.newLine(); out.write("Maximum energy balance value: " + maxResult + " W"); out.newLine(); out.write("Associated dEi0Int: " + dEi0Int + " W"); out.newLine(); out.write("Associated nteFluxInt: " + nteFlux + " W"); out.newLine(); out.write("Associated Qint: " + Qint + " W"); out.newLine(); out.write("Associated Wint: " + Wint + " W"); out.newLine(); try { if (maxResult > Double.parseDouble(relTol)) { out.write("!!!!!! Incorrect energy balance, check the results."); out.newLine(); } else if (relTol.equals("NaN")) { out.write("!!!!!! Undefined relative tolerance, check the results."); out.newLine(); } } catch (Exception e) { out.write("!!!!!! Undefined relative tolerance, check the results."); out.newLine(); } out.close(); } catch (IOException e) { //JOptionPane.showMessageDialog(null, "There was a problem while writing to result file."); } }
Editor is loading...