Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Why cant i call method to main

0 votes
asked Apr 7, 2020 by Santino (120 points)
import java.util.Scanner;
package lab.pkg3.q2;

public class PropertyCost {
double RATE = 1.1;
double UNITPRICE = 1.4;
double GST = 0.1;
    public static void main(String[] args) {
        Scanner fetch = new Scanner(System.in);
        double area, propCost;
        System.out.print("Porperty cost: ");
        area = fetch.nextInt();
    public double calcTotalCharges(double area){
    double actualArea = area * RATE;
    double propertyCharge = actualArea * UNITPRICE;
    double propertyCost = propertyCharge + propertyCharge * GST;
        return propertyCost;

1 Answer

0 votes
answered Jul 27, 2020 by Sushma (160 points)

In main method call calcTotalCharge() method with parameter and return type of  calcTotalCharge() assign to a variable and better to use static keyword in function defination or you can create an object for that class and with that help you can call that function.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.