[Show all top banners]

redlotus
Replies to this thread:

More by redlotus
What people are reading
Subscribers
Subscribers
[Total Subscribers 1]

Rolemodel
:: Subscribe
Back to: Kurakani General Refresh page to view new replies
 java -assignment help!!!!!!!!!!!
[VIEWED 7739 TIMES]
SAVE! for ease of future access.
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.


 


 
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 :)

 
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.








 
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.


 
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.

 
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"

 
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++;
>}


 
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);
}
}
 
Posted on 02-11-09 3:18 AM     Reply [Subscribe]
Login in to Rate this Post:     0       ?    
 

thank you guys for you funny programs

 


Please Log in! to be able to reply! If you don't have a login, please register here.

YOU CAN ALSO



IN ORDER TO POST!




Within last 60 days
Recommended Popular Threads Controvertial Threads
What are your first memories of when Nepal Television Began?
Basnet or Basnyat ??
TPS Re-registration case still pending ..
nrn citizenship
ढ्याउ गर्दा दसैँको खसी गनाउच
अमेरिकामा बस्ने प्राय जस्तो नेपालीहरु सबै मध्यम बर्गीय अथवा माथि (higher than middle class)
Send Parcels from USA to Nepal & Worldwide.
Why is every youths leaving Nepal? Why are not youths entering politics and serving the country, starting business etc?
TPS Work Permit/How long your took?
Travelling to Nepal - TPS AP- PASSPORT
कल्लाई मुर्ख भन्या ?
Morning dharahara
महँगो अण्डाको पिकल्प : कुखुरा र खोर भाडामा लिने
Travelling on TPS advance travel document to different country...
काेराेना सङ्क्रमणबाट बच्न Immunity बढाउन के के खाने ?How to increase immunity against COVID - 19?
Informatica consultancy share
मन भित्र को पत्रै पत्र!
TPS Renewal Reregistration
Nepali doctors future black or white usa ?
हेर अमेरिकामा नेपालीहरुको बेज्जत
NOTE: The opinions here represent the opinions of the individual posters, and not of Sajha.com. It is not possible for sajha.com to monitor all the postings, since sajha.com merely seeks to provide a cyber location for discussing ideas and concerns related to Nepal and the Nepalis. Please send an email to admin@sajha.com using a valid email address if you want any posting to be considered for deletion. Your request will be handled on a one to one basis. Sajha.com is a service please don't abuse it. - Thanks.

Sajha.com Privacy Policy

Like us in Facebook!

↑ Back to Top
free counters