There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
audio avg avg 8 blue screen brand new codec control panel conversion crash delete personal data desktop display dos driver duplicate dvd error error message excel explorer file firefox game graphics hardware hijackthis log install installation internet itunes javascript laptop macro malware monitor msconfig msn music network outlook outlook 2003 outlook express php problem program random rundll32 security seo sound sp3 spyware switch tag cloud trojan usb video virtumonde virus vista visual basic vundo wallpaper windows windows vista windows xp wireless word xp sp3 youtube
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Java Help


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
bootsiebella's Avatar
Junior Member with 12 posts.
 
Join Date: Mar 2008
09-May-2008, 08:37 PM #1
Java Help
Can somebody show me how to write an algorithm for these two please and get me on the right track!
Thanks

reads in two integers and determines and prints if the first is a multiple of the second using the modulus operator.

calculates the squares and cubes of the numbers from 0 to 10
bootsiebella's Avatar
Junior Member with 12 posts.
 
Join Date: Mar 2008
09-May-2008, 09:00 PM #2
I am thinking this might do it for the first one. What do you think anyone??
public class PassPrimitive {

public static void main(String[] args) {
int in = 10;
passMethod(in);
// print x to see if its value has changed
System.out.println("After invoking passMethod, in = " + in);
}
public static void passMethod(int p) {
p = 20;
}
}
Jackiefrost9's Avatar
Computer Specs
Distinguished Member with 3,720 posts.
 
Join Date: Jun 2004
Location: Spokane, Wa
Experience: Advanced
14-May-2008, 09:36 PM #3
I see you already have a thread for the first one.

I'm not going to tell you what the code is for the second one, but think about it like this:

since you have to go through the numbers 0 to 10 and do the same thing to each of them, some kind of loop would be desirable.
To do the squares and cubes you can do it the usual way (the cube of 5 is 5*5*5) or you can read up on the java math object here (search for math and it's the second one):
http://java.sun.com/javase/6/docs/api/

look for the "pow" method.


You should get used to using the java API if you are doing much java programming. If you know how to use it then it can provide the answer to any kind of problem you encounter.
__________________
M.O.U.S.

I do things with hardware n stuff

I'm at the University of Washington
Computer Engineering
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 02:08 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.