Access over 35 million academic & study documents

Doc1

Content type
User Generated
Subject
Programming
School
Allan Hancock College
Type
Homework
Rating
Showing Page:
1/5
Main.java
import util.Sequence;
import java.util.Random;
//----------------------------------------------------------------------------
-
// DO NOT MAKE ANY CHANGES TO THIS CLASS
//
// Any changes you make to this class will not be used for grading.
//----------------------------------------------------------------------------
-
public class Main
{
public static void main(String[] args)
{
Random prng = new Random();
int min, max;
// random bounds by default
min = prng.nextInt(50);
max = prng.nextInt(50) + 50;
// override with command line args
if (args.length >= 2)
{
try
{
min = Integer.parseInt(args[0]);
max = Integer.parseInt(args[1]);
}
catch (Exception e)
{
System.err.println("Command line arguments threw an
exception!");
System.exit(1);
}
}
// create object
Sequence seq = new Sequence(min, max);
// use class
System.out.println("Sequence bounds:");
System.out.println(min + ", " + max);

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/5
System.out.println("Sequence listed:");
printArray(seq.list());
System.out.println("Sequence backwards:");
printArray(seq.backwards());
System.out.println("Sequence evens:");
printArray(seq.evens());
System.out.println("Sequence squares:");
printArray(seq.squares());
System.out.println("Sequence summation:");
System.out.println(seq.summation());
}
public static void printArray(int[] stuff)
{
for (int x : stuff)
System.out.print(x + ", ");
System.out.println();
}
}
Sequence.java
package util;
import java.io.*;
public class Sequence
{
private int mMin = 0;
private int mMax = 0;
public Sequence(int min, int max)
{
//TODO: assign the arguments to the class member variables
// settting up the class variables using constructors.
this.mMin=min;
this.mMax=max;
}
public int[] list()
{

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/5

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 5 pages?
Access Now
Unformatted Attachment Preview
Main.java import util.Sequence; import java.util.Random; //---------------------------------------------------------------------------// DO NOT MAKE ANY CHANGES TO THIS CLASS // // Any changes you make to this class will not be used for grading. //---------------------------------------------------------------------------public class Main { public static void main(String[] args) { Random prng = new Random(); int min, max; // random bounds by default min = prng.nextInt(50); max = prng.nextInt(50) + 50; // override with command line args if (args.length >= 2) { try { min = Integer.parseInt(args[0]); max = Integer.parseInt(args[1]); } catch (Exception e) { System.err.println("Command line arguments threw an exception!"); System.exit(1); } } // create object Sequence seq = new Sequence(min, max); // use class System.out.println("Sequence bounds:"); System.out.println(min + ", " + max); System.out.println("Sequence listed:"); printArray(seq.list()); System.out.println("Sequence backwards:"); printArray(seq.backwards()); System.out.println("Sequence evens:"); printArray(seq.evens()); System.out.println("Sequence squares:"); printArray(seq.squares()); System.out.println("Sequence summation:"); System.out.println(seq.summation()); } public static void printArray(int[] stuff) { for (int x : stuff) System.out.print(x + ", "); System.out.println(); } } Sequence.java package util; import java.io.*; public class Sequence { private int mMin = 0; private int mMax = 0; public Sequence(i ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Really helpful material, saved me a great deal of time.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4