help me to identify the problem with this code

public class Calculate
{
    int service;
    }
    int price(int total, int amount, int currency)//overloading
    {
        int price(int total, int amount)//overloading
        {
            return service;
            }
}

C:\Users\User\Documents\Calculate.java:12: error: class, interface, or enum expected
int price(int total, int amount, int currency)//overloading
^
C:\Users\User\Documents\Calculate.java:17: error: class, interface, or enum expected
        }
        ^
 this is the error:

This code on its own has mismatched brackets.

Again, count your left and right curly brackets and you see they don't match. I can't guess your code's intent so I can't fix it for you.

The close bracket on line 4 ends the class definition, so whatever follows has to be a new class/interface/enum.
Line 7 attempts to define a method inside the method definition starting on line 5. You cannot nest method definitions.

Plus (not exectly errors, but bad style):
Class names should be nouns - the kind of thing that the class represents.
Method names should be verbs - what the method does.
It's baffling that a method called "price" should return something called "service"
Java code is usually indented like this

int getTotal() {
   return quantity*unitPrice;
}

Worrying about names or indentation may look like nit-picking, but in reality it's essential for making code understandable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.