Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

import java.File; import java.FileNotFoundException; import java.PrintWriter; import java.

import java.io.File;

import java.io.FileNotFoundException;

import java.io.PrintWriter;

import java.util.Scanner;

public class MathOp2 {

 public static void main(String[] args) throws FileNotFoundException {

  Scanner scanner = new Scanner(new File("MathInput.csv"));

  PrintWriter printWriter = new PrintWriter(new File("Math_Results.csv"));

  int total = 0;

  while (scanner.hasNext()) {

   total = 0;

   String readLine = scanner.nextLine();

   String[] getData = readLine.split(",");

   if (getData[1].trim().equals("+")) {

    int operand = Integer.parseInt(getData[0]);

    total = operand + Integer.parseInt(getData[2]);

    printWriter.write(operand + "+" + Integer.parseInt(getData[2])

      + ", = ," + total + "n");

   } else if (getData[1].trim().equals("-")) {

    int operand = Integer.parseInt(getData[0]);

    total = operand - Integer.parseInt(getData[2]);

    printWriter.write(operand + "-" + Integer.parseInt(getData[2])

      + ", = ," + total + "n");

   } else if (getData[1].trim().equals("*")) {

    int operand = Integer.parseInt(getData[0]);

    total = operand * Integer.parseInt(getData[2]);

    printWriter.write(operand + "*" + Integer.parseInt(getData[2])

      + ", = ," + total + "n");

   } else if (getData[1].trim().equals("/")) {

    int operand = Integer.parseInt(getData[0]);

    total = operand / Integer.parseInt(getData[2]);

    printWriter.write(operand + "/" + Integer.parseInt(getData[2])

      + ", = ," + total + "n");

   }

  }

  Scanner userInput = new Scanner(System.in);

  System.out.println("Do you want to save the results (Y/N)?");

  String choice = userInput.nextLine();

  if (choice.equals("Y")) {

   printWriter.close();

  }

  System.out.println("do you want to review the results (Y/N)?");

  choice = userInput.nextLine();

  if (choice.equals("Y")) {

   scanner = new Scanner(new File("Math_Results.csv"));

   while (scanner.hasNext()) {

    System.out.println(scanner.nextLine().replace(',', ' '));

   }

  }

  scanner.close();

 }

}

Error: Could not find or load main class week8.Week8

Java Result: 1

BUILD SUCCESSFUL (total time: 1 second)

I do not know how or what I am doing wrong. please help

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question