-1

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 ??

4
Contributors
6
Replies
32
Views
3 Weeks
Discussion Span
Last Post by rahaf_1
0

Please note our member rules, including

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

0

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

0
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 :(

Edited by rahaf_1

1

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.

1

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

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.