Write a program that computes the gold zakat. The user should enter the gold
weight in gram and its worth. The program should print and calculate the zakat
if the gold is worth 3000 or more. Otherwise, the program should print 0.
Hint:
zakat = gold worth * 2.5%

how can i do that in netbeans ??

Recommended Answers

All 6 Replies

Please note our member rules, including

Do provide evidence of having done some work yourself if posting questions from school or work assignments

Well, start by creating a new project, kept the "Main class" option checked, open your main class and we will continue from there.

static void main(String[] args) {
    // TODO code application logic here
}

package javaapplicationEX3;

public class JavaApplication15 {

    static void main(String[] args) {
        // TODO code application logic here
    }

}
}

i just want like an example on how to calculate because my teacher is lazy she doesn't even bother to teach :(

Good, very good. Now we will all our code inside the main method, but first : remove the lines 1, 2, 3 and 14.
Now lets assume that the gold worth is fixed, lets try some values then return to that point later.

So, lets be :

// double to get the maximum size and precision
double goldWorth = 30000;

Now, we need the calculation, but we can not write 2.5%, this % sign is the problem, so we must take the equivalent value of 0.025 :

double zakat = goldWorth * 0.025;

// Lets print to the screen
System.out.println(String.valueOf(zakat));

Try the previous code with different values of goldWorth.
Then we will proceed from there.

It looks to me that you'd be better off learning from the beginning. Here's the link for one place to start

thanks alot it really helped me !!!

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.