Java Assignment
I need my answers to be formatted with one decimal place.
Here is my code.
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.JFileChooser;
class Calculator {
ArrayList<String> list = newArrayList<String>();
public static double currentValue = 0; //Variable to holdresult
public Calculator(double currentValue)
{
this.currentValue = currentValue;
}
public void display() {
File outputFile = null;
JFileChooser fileChooser = new JFileChooser( //Creating theJFileChooser
“Choose a file to save the contents”); //Displaying the dialogand getting response
int userSelection = fileChooser.showSaveDialog(null);
if (userSelection == JFileChooser.APPROVE_OPTION) {
outputFile = fileChooser.getSelectedFile();
try {
FileWriter fw = new FileWriter(outputFile); //Writing the ArrayList into the file and displaying on the console
for (String i : list) {
System.out.println(i);
fw.write(i + “rn”);
}
fw.close();
} catch (Exception e) {
System.out.println(e);
}
}
}
public static int displayMenu(Scanner choose)
{
int
PayPal Gateway not configured
PayPal Gateway not configured