I have to write a program where the user inputs 3 numbers into an array and then the output is the numbers subtracted from each other.
I have tried using a for loop for this but it just outputs the numbers added together then turns it negative eg :…
I am using Java 7
I am trying to get a double from dividing two integer:
double chance = 1/main.getConfig().getInt("dailygiftItems.items."+key+".chance");
double w = Math.random();
System.out.println("Pulled:…
I have the following calculation in Java:
rightMotor = (int) (((double)speed)/((double)100)*rightMotor));
Speed and rightMotor are both integers.
The problem is, it keeps returning 0. I have tried to force to divide speed and 100 as doubles, which…
In Java,I need to ask user input for two integers. The program needs to divide by these two integers and produce a decimal to the sixth place.
I know that i will need to name two integers: numerator and denominator. Also, I need to name a double…
So what i need is basically described in the subject.
Like if i would put in number 12 and amount of parts it should devide into, i would like it to return something like (with 4 parts) 8, 2, 1, 1. But not doubles because i need the values as…
I try to figure out how to handle my array to do "some math" with its values.
The array looks similar to this:
Array
(
[0] => Array
(
[person1] => 71
[person2] => 49
[person3] => 15
)
[1] => Array
(
…
I am currently watching some tutorials and I am stuck at a part that looks like this:
int x = (int) a_float / an_int;
What will happed if a_float / an_int; is not an integer? Will the number be rounded / floored / weird stuff?
Here is the extracted code :
long timeMs = 1473;
double timeS = (timeMs / 1000) + (timeMs% 1000) / 1000.0;
System.out.println(timeS);
And the output is:
1.4729999999999999
So basically, I was just trying to convert the time taken in seconds into…
I can sum up strings:
result=[firstString stringByAppendingString:secondString];
I can subtract one string from another:
result=[firstString stringByReplacingOccurencesOfString:secondString withString:@""];
Can you help me to divide a string into…
I am trying to split the below array. array_chunk, splice, etc dint give me output as expected. Below is the input array:
Array ( [0] => Stephen
[1] => stephearce
[2] => s@gmail.com
[3] => Stephen
[4] => stephon
…
So my problem is that I am trying to position a sprite in the middle of the screen. How to do that is very simple but the calculations made during runtime are wrong. I have come to the conclusion that it is about floating points being messy in…
I need to create a recursive function that receives a number by two without using /.
This is what I wrote, but it works only if after dividing it will still be a decimal number and not a float, that's why I asked.
int recursive(int a, int b){
if…
Hi I am currently teaching myself C# using different books and online solutions, there is one exercise that i cant really get my head around. I had to divide a number by another number in C# using iteration and subtraction but the remainder had to…
I have one variable ($TotalCountyTaxAmount) I want to divide by 365 to calculate a daily tax rate. In this example the variable value is 1614.21. When I divide the variable by the number of days (e.g. $TCA / $days), I get 0.2261 which is incorrect. …