[Solved] ReportPayment() method in main is giving errors


Reworked the answer:
I tried to run the code myself and with a little tweaking it works perfectly fine. We are getting there. I think thi is the whole thing you should need!

This should now fix your error aswell as fit the requirements you have.

I changed:

  • renamed ReportPayment() to reportPayment()
  • removed te space inbetween
    “det.” and “ReportPayment() in the main class
  • Rewrote your attributes
  • rewrote the info() method
  • added the calculation for taxes as required

Main.java

public class Main {
    private static boolean running = true;

    public static void main(String[] args) {

        Details det = new Details();
        det.info();
        det.reportPayment();
    }

}

Details.java

import javax.swing.JOptionPane;

class Details {
    private String name;
    private String surname;
    private int age;
    private String gender;
    private double AmountPayout;

    void info() {
        this.name = JOptionPane.showInputDialog(null, "Enter the Patient Name :");
        this.surname = JOptionPane.showInputDialog(null, "Enter the Patient Surname :");
        String rawAge = JOptionPane.showInputDialog(null, "Enter the age of the patient :");
        this.age = Integer.parseInt(rawAge);
        this.gender = JOptionPane.showInputDialog(null, "Enter the Patient gender :");
        String rawPayout = JOptionPane.showInputDialog(null, "Enter the Patient payout :");
        this.AmountPayout = Double.parseDouble(rawPayout);


    }

    void reportPayment() {
        paymentCalculator();
        JOptionPane.showMessageDialog(null, "Victim of Listeriosis" + "\n" + "Patient Name:" + name + " " + surname
                + "\n" + "Age:" + age + "\n" + "Payout:" + AmountPayout);

    }

    private void paymentCalculator() {
        this.AmountPayout = this.AmountPayout * 0.85;
    }
}

12

solved ReportPayment() method in main is giving errors