C:\My Documents\sprayproject.java:100: <identifier> expected
        JOptionPane.showMessageDialog("\nTotal fees charged: R"+total+"\nCost exceeding R3000: "+count);
                                             ^
1 error

Guys please assist me in rectifying the above error?
Following below is my coding...

import javax.swing.*;

public class sprayproject
{
    public static void main(String[]args)
    {
        String name, temp, temp2;
        int option, acres, farmno, count=0;
        double cost, total=0, inticost, finalcost;

        temp = JOptionPane.showInputDialog(null,"Farm num:");
        farmno = Integer.parseInt(temp);

        while(farmno!=-1)
        {
            name = JOptionPane.showInputDialog(null,"Farmer's name: ");
            option = validate();

            temp2 = JOptionPane.showInputDialog(null,"Num of acres: ");
            acres = Integer.parseInt(temp2);

            initcost = calcinitcost(option,acres);
            finalcost = calcfinalcost(initcost, acres);
            count = farmercount(count, finalcost);
            total +=finalcost;

            display(name, farmno, finalcost);

            temp = JOptionPane.showInputDialog(null,"Farm num: ");
            farmno = Integer.parseInt(temp);        
        }
    }

        public static int validate()
        {
            int spraytype, choice;

            do
            {
                spraytype = JOptionPane.showInputDialog(null,"Please enter type of spraying(1-4): ");
                choice = Integer.parseInt(spraytype);

                if(choice <1 || choice >4)
                {
                    System.out.println("Invalid entry...");
                }       
            }while(choice<=4||choice>=1);

            return choice;
        }

        public static int calcinitcost(int option, int acres)
        {
            switch(option)
            {
                case 1: cost = 1;
                break;
                case 2: cost = 2;
                break;
                case 3: cost = 3;
                break;
                case 4: cost = 5;
                break;
            }

            return cost;
        }

        public static double calcfinalcost(double cost,int acres)
        {
            double disc;
            cost = cost * acres; 
            if(acres>1000)
            {
                disc = cost * 0.05;
            }

            if(cost>1500)
            {
                disc = (cost-1500) * 0.1;
            }

            return cost;
        }

        public static int farmercount(double finalcost)
        {
            if(finalcost>3000)
            count++;

            return count;
        }

        public static void display(String name,int farmno, double finalcost)
        {
            System.out.println("Farme's name is: " +name+ "\n Farmer's number: "+farmno+"\n Final cost is: " +finalcost);
        }


        JOptionPane.showMessageDialog("\nTotal fees charged: R"+total+"\nCost exceeding R3000: "+count);
}

Edited 3 Years Ago by mike_2000_17: Fixed formatting

Is that a carriage return between the : and the "
You can't have a carriage return inside a string like that. The similar line ~5 lines above shows the right way to do it - finish the string first, then put the cr.

This article has been dead for over six months. Start a new discussion instead.