473,466 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 21750
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.