//*************************************************************************** //
ID: 646943 • Letter: #
Question
//***************************************************************************
//Purpose: Implement various array methods
//
//Input: Methods arguments
//Output: Returned arguments and display values
//
//Author: <Enter your name here
//
//Date: 10/24/2013
//
//Class: CS1301A
//
//Program: OneDArrayQuizSkeletonA_10_24_2013.java
//***************************************************************************
//***************************************************************************
//1. Complete as many methods as you can.
//2. Complete the methods in any order you like.
//3. Do not spend too much time on a few methods.
//4. Submit your work by the end of the class period.
//5. Do not modify or attach the driver. Use driver to test your code only.
//6. if you don't complete your work by the end of the class period,
// you may resubmit your additional work by 6:00PM tonight.
//
// Good luck.
//*************************************************************************
import java.util.*;
import java.io.*;
public class OneDArrayQuizSkeletonA_10_24_2013 {
//*********************************************************
//1. Declarations:
// a. Declare name, course, and semester of type String
// b. Declare year of type integer
// c. Declare dateCreated of type Date
//*********************************************************
//To be implemented remove when done
//*********************************************************
//2. No-argument constructor.
// a. Assign your name to name
// b. Assign CS1301 to course
// c. Assign current year to year
// d. Assign the current date (Use the Date class) to dateCreated
//*********************************************************
public OneDArrayQuizSkeletonA_10_24_2013 (){
//To be implemented remove when done
System.out.println (" 2: not implemented");
}
//*********************************************************
//3. Populate Array.
// a. Complete the method that accepts a one-dimensional
// array of type integer and populates the array with
// random values from 10 to 50 (inclusive)
//*********************************************************
public void populate (int [] list) {
//To be implemented remove when done
System.out.println (" 3: not implemented");
}
//*********************************************************
//4. Print Array.
// a. Complete the method that accepts a one-dimensional
// array of type integer and prints on the screen
// 5 values per line.
//*********************************************************
public void printArray (int [] list ) {
//To be implemented remove when done
System.out.println (" 4: not implemented");
}
//*********************************************************
//5. min.
// a. Complete the method that accepts a one-dimensional
// array of type integer and returns the smallest
// value in the array.
//*********************************************************
public int min (int [] list ) {
//To be implemented remove when done
System.out.println (" 5: not implemented");
return 0; // replace when implementred
}
//*********************************************************
//6. sum.
// a. Complete the method that accepts a one-dimensional
// array of type integer and returns the sum of all
// values in the array.
//*********************************************************
public int sum (int [] list ) {
//To be implemented remove when done
System.out.println (" 6: not implemented");
return 0; // replace when implementred
}
//*********************************************************
//7. Average of even values
// a. Complete the method that accepts a one-dimensional
// array of type integer and returns the average of all
// even values in the array.
//*********************************************************
public double averageOfEvenValues (int [] list ) {
//To be implemented remove when done
System.out.println (" 7: not implemented");
return 0; // replace when implementred
}
//*********************************************************
//8. found
// a. Complete the method that accepts a one-dimensional
// array of type integer and an integer value. returns
// true if the values is in the array, otherwise, it
// return false.
//*********************************************************
public boolean found (int [] list, int value) {
//To be implemented remove when done
System.out.println (" 8: not implemented");
return false; // replace when implementred
}
//*********************************************************
//9. rotateLeft
// a. Complete the method that accepts a one-dimensional
// array of type integer. it rotates values left. For
// example, if the recieved array contains 5, 10, 8, 7,
// the method manipulate the values as follows:
// 10, 8, 7, and 5. Where each value moves left one position
// and the first will be stored in last entry.
//*********************************************************
public void rotateLeft (int [] list ) {
//To be implemented remove when done
System.out.println (" 9: not implemented");
}
//*********************************************************
//10. toString
// a. Complete the method to return the values of the instance
// variables with appropriate labels and indention.
// Have a variable per line.
//*********************************************************
public String toString () {
//To be implemented remove when done
System.out.println (" 10: not implemented");
return "TBI"; // replace when implementred
}
}
Explanation / Answer
import java.util.*;
import java.io.*;
public class OneDArrayQuizSkeletonA_10_24_2013 {
// 1.Declarations:
String name, course,semester;
int year;
Date dateCreated;
//2. No-argument constructor.
public OneDArrayQuizSkeletonA_10_24_2013() {
this.name=
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.