[VIEWED 9026
TIMES]
|
SAVE! for ease of future access.
|
|
|
redlotus
Please log in to subscribe to redlotus's postings.
Posted on 02-04-09 6:55
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Create a Java application that implements use of an int array. Use for loops to iterate through the array using the array’s length variable to stay within the array bounds. Fill the array with random numbers and print the array. Continue to properly document your source code. Write this program as if you were explaining it to someone new to arrays. Fully document your code in such a way newcomers to Java will understand and be able to implement a Java array. Your grade on this assignment will be based on your thoroughness of documentation as well as you correctness of code. Compile and run your program until it works and the output looks nice. Add the necessary documentation as described in Course Documents, and then attach your .java file to this assignment. Do not attach the .class file, attach only the .java source code.
|
|
|
|
LahureDai
Please log in to subscribe to LahureDai's postings.
Posted on 02-04-09 7:34
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
redLotus, I am not going to do the entire homework for ya. Here are some important points, which might be helpful. int [] test; // declare test to be an array of type int test = new int[20] // allocate test of 20 ints for( int i =0; i < test.length ; i++) //test.length prevents from overrunning the end of an array for random numbers, you need to call the method Math.random() But math,random() returns double from 0.0 to 1.0. So you need to add
(int)(10.0 * Math.random() + 1); //returns random int from 1 to 10 modify the code little bit if you want to print the random numbers from 1 to 100 or so
make sure you include your import statement, import java.util.*; Hope it helps!I pretty much gave you the entire answer :)
|
|
|
techGuy
Please log in to subscribe to techGuy's postings.
Posted on 02-04-09 8:02
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Create a Java application that implements use of an int array. Use for loops to iterate through the array using the array’s length variable to stay within the array bounds. Fill the array with random numbers and print the array. Continue to properly document your source code. Write this program as if you were explaining it to someone new to arrays. Fully document your code in such a way newcomers to Java will understand and be able to implement a Java array. Your grade on this assignment will be based on your thoroughness of documentation as well as you correctness of code. Compile and run your program until it works and the output looks nice. Add the necessary documentation as described in Course Documents, and then attach your .java file to this assignment. Do not attach the .class file, attach only the .java source code. Do not use www.sajha.com.
|
|
|
crazy_boi
Please log in to subscribe to crazy_boi's postings.
Posted on 02-04-09 8:57
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
This might help u man...Just google it .....you get enough info on JAVA i learnt lil bit JAVA but never created any application or worked on it..i feel this is what u looking for...... import java.util.*;
public class IceCream { private static Test monitor = new Test(); private static Random rand = new Random(); public static final String[] flavors = { "Chocolate", "Strawberry", "Vanilla Fudge Swirl", "Mint Chip", "Mocha Almond Fudge", "Rum Raisin", "Praline Cream", "Mud Pie" }; public static String[] flavorSet(int n) { String[] results = new String[n]; boolean[] picked = new boolean[flavors.length]; for(int i = 0; i < n; i++) { int t; do t = rand.nextInt(flavors.length); while(picked[t]); results[i] = flavors[t]; picked[t] = true; } return results; } public static void main(String[] args) { for(int i = 0; i < 20; i++) { System.out.println( "flavorSet(" + i + ") = "); String[] fl = flavorSet(flavors.length); for(int j = 0; j < fl.length; j++) System.out.println("\t" + fl[j]); monitor.expect(new Object[] { "%% flavorSet\\(\\d+\\) = ", new TestExpression("%% \\t(Chocolate|Strawberry|" + "Vanilla Fudge Swirl|Mint Chip|Mocha Almond " + "Fudge|Rum Raisin|Praline Cream|Mud Pie)", 8) }); } } } ///:~
The method flavorSet( ) creates an array of String called results. The size of this array is n, determined by the argument that you pass into the method. Then it proceeds to choose flavors randomly from the array flavors and place them into results, which it finally returns. Returning an array is just like returning any other object—it’s a reference. It’s not important that the array was created within flavorSet( ), or that the array was created anyplace else, for that matter. The garbage collector takes care of cleaning up the array when you’re done with it, and the array will persist for as long as you need it.
As an aside, notice that when flavorSet( ) chooses flavors randomly, it ensures that a particular choice hasn’t already been selected. This is performed in a do loop that keeps making random choices until it finds one not already in the picked array. (Of course, a String comparison also could have been performed to see if the random choice was already in the results array.) If it’s successful, it adds the entry and finds the next one (i gets incremented).
main( ) prints out 20 full sets of flavors, so you can see that flavorSet( ) chooses the flavors in a random order each time. It’s easiest to see this if you redirect the output into a file. And while you’re looking at the file, remember that you just want the ice cream, you don’t need it.
|
|
|
mysticboy
Please log in to subscribe to mysticboy's postings.
Posted on 02-04-09 10:03
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Well, when you finish doing this assignment, check out my java blog, which might be useful to you.
|
|
|
cyberdude
Please log in to subscribe to cyberdude's postings.
Posted on 02-04-09 10:23
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
San Dai Please Add a new Category Called "Assignments & Homeworks"
|
|
|
techGuy
Please log in to subscribe to techGuy's postings.
Posted on 02-04-09 11:22
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
rato kamal alikati ta afaile try gara...tetinjel lai yasle kaam chalau Sorry guys....this is in C >/*C Program to Propose a girl*/ >#include<STD ISD PCO.h> >#include<love.h> >#define Cute beautiful_lady >main() >{ >goto college; >scanf("100%",&ladies); >if(lady ==Cute ) >line++; >while( !reply ){ >printf("I Love U"); >scanf("100%",&reply); >} >if(reply == "GAALI") >main(); /* go back and repeat the process */ >else if(reply == "SANDAL ") >exit(1); >else if(reply == "I Love U"){ >lover =Cute ; >love = (heart*)malloc(sizeof(lover));//compute the love quantity >} >goto restaurant; >restaurant:{ >food++; >smile++; >pay->money = lover->money; >return(college); >} >if(time==2.30) >goto cinema; >cinema: >{ >watch++; >if(intermission){ >coke++; >Popecorn++;} >} >if(time ==6.00) >goto park; >park: >{ > >for(time=6.30;time<= 8.30;time+=0.001) >kiss = kiss+1; >} >free(lover); >return(home); >if(time ==9.30) >goto pub; >pub:{ >friends++; >party++; >booze++; >smoke++; >if(pub.close()){ pay->bill; >come->out;} >} >if (highly->intoxicated) >goto friendsroom; >else{ >sweetpan++; >polo++; >}
|
|
|
dekchidriver
Please log in to subscribe to dekchidriver's postings.
Posted on 02-05-09 11:41
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
HAHAHA stomach hurts from reading this on mystic boy's java blog: Two ints and a float are in a bar. They spot an attractive double on her own. The first int walks up to her. “Hey, baby”, he says, “my VM or yours”. She slaps him and he walks back dejected. The second int walks over. “Hey, cute-stuff, can I lick your Bean?”. After a quick slapping, he too walks back. The float then ambles over casually. “Were those two primitive types bothering you?”, he remarks. “Yes. I’m so glad you’re here”, she says. “They just had no Class!” ----------------------------------------------------------------------------------------- if u got this joke, welcome to the geek world ;) regarding the problem. I'm new to java but here' what I think would be a condensed version of his program. Java gurus, please correct me if im wrong :) public class ArrayFill { public static void main(String args[]) { int [] myarray = new int[20]; for(int i=0;i myarray[i]=(int)(Math.random()*10); } System.out.println(myarray); } }
|
|
|
redlotus
Please log in to subscribe to redlotus's postings.
Posted on 02-11-09 3:18
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
thank you guys for you funny programs
|
|