472,804 Members | 975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,804 software developers and data experts.

Java math help needed


I need to recreate the following formula in java:

INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)

Can someone show me how to do this in java?
-Thanks

Jul 17 '05 #1
4 21722
Fred wrote:
I need to recreate the following formula in java:

INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)

Can someone show me how to do this in java?
-Thanks


What do you mean by int? you mean integrate or what?

Mod is % in java. so int i = 10 %5 = 0. 11 % 5 = 1 (if i remember
correctly)

To do powers you simply do Math.pow() look it up in your java api docs.
Look for the Math class.

Jul 17 '05 #2
int answer = ((int)(pow(a2,3) + pow(b2,3)) / 100) +
((pow(a2,3) + pow(b2,2)) % 100);
Fred <it****@cdw.com> wrote in message news:<pa****************************@cdw.com>...
I need to recreate the following formula in java:

INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)

Can someone show me how to do this in java?
-Thanks

Jul 17 '05 #3
All you need to do is to spend 10 mins reading your textbook, rather than
posting your homework and waiting somebody to do it for you.

HD
"Fred" <it****@cdw.com> wrote in message
news:pa****************************@cdw.com...

I need to recreate the following formula in java:

INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)

Can someone show me how to do this in java?
-Thanks

Jul 17 '05 #4
"Yoyoma_2" wrote:
Fred wrote:
I need to recreate the following formula in java:

INT((A2^3 + B2^3) / 100)) + MOD((A2^3 + B2^2), 100)

Can someone show me how to do this in java?
-Thanks

What do you mean by int? you mean integrate or what?

Mod is % in java. so int i = 10 %5 = 0. 11 % 5 = 1 (if i remember
correctly)


Nitpick:

% in Java is actually remainder, not Modulus.
True Modulus produces a result from 0 to the divisor-1.
% can produce negative results.

"the % operator is not a true mod operator, but computes the remainder,
which may be negative"
http://java.sun.com/docs/books/jls/assert-spec.html
To do powers you simply do Math.pow() look it up in your java api docs.
Look for the Math class.

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Lloyd Dupont | last post by:
here a little test program. it's so simple taht it should deliver simmilar result. it's also so simple that people that might says it's unfair to the looser (why Java people are always arguing...
33
by: patrick_woflian | last post by:
hey guys, im just writing a basic calculation at the moment, before building on it for an A-Level piece of work. i can add/divide etc... two numbers together yet i am having a major problem with...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
36
by: Robert Baer | last post by:
I used Google and found some references for integer in Java. But "int" not only does not work, it also prevents reading X and Y coordinates of the mouse. What i would like to do: 1) Get X and Y...
2
by: phjones | last post by:
Need help programming mortagage calculator for 3 different loans 7 year, 15 year and 30 year. using java array I am a beginner with Java, This is what I have so far. Need to know if I am off the...
2
by: dragonball | last post by:
hi, i want to use log(double) in my java prog. so i have imported java.lang.Math flanagan.math.PsRandom now i wanna use log function in a private method inside a class. so i try : ...
1
by: feathers75 | last post by:
-------------------------------------------------------------------------------- First, Hello eveyone and I am new to Java. I am trying to create a Java program that will calculate a person...
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.