There is something that I tried to fix over and over and I couldn't.
So the program asks a user for 3 numbers a then asks for the percentage they want to add then these numbers goes to a void method:
So its like this:
public static void main(String[] args) {
System.out.print("Number 1: ");
X1 = s.nextLong();
System.out.print("Number 2: ");
W1 = s.nextLong();
System.out.print("Number 3: ");
Z1 = s.nextLong();
System.out.print("Percentage 1: ");
int a = s.nextInt();
System.out.print("Percentage 2: ");
int b = s.nextInt();
System.out.print("Percentage 3: ");
int c = s.nextInt();
Number(a,b,c);
}
public static void Number(int a, int b, int c)
{
X1 = (long) (X1*(a/100 + 1));
W1 = (long) (W1*(b/100 + 1));
Z1 = (long) (Z1*(c/100 + 1));
}
But if I try to type the results the numbers don't change.
Note: X1,W1 and Z1 are all used as static long
And thanks in advance.
Unless a,b,c >= 100, the expression
a/100
will be 0. Hence
something * (a/100 +1)
is
something * 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With