Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

5 Mini-Projects Due in AP Comp Sci tomorrow. Any takers?

compscisux
compscisux 


These are basic java programs involving interfaces, arrays, and inheritance. Any experienced programmer can do these in an hour. Help me get them done by tomorrow morning, and I'll pay you $40. Attachments Tags Clarifications

Answers

Java Mini Projects - Solution

dickersonka
dickersonka 



Attached is the solution to the java mini projects including source and comments. Each problem is in its own package, if thats an issue remove the package declaration from the top of each file. Attachments
source.zip (9 K) Download
Preview
Radius = " + radius; } @Override public int compareTo(Circle o) { //compare 2 significant digits Integer area1 = (int)(getArea() * 100); Integer area2 = (int)(o.getArea() * 100); return area1.compareTo(area2);

Preview
= height; } public double getWidth() { return width; } public void setWidth(double width) { this.width = width; } public String toString(){ return "Rectangle: Height = " + height + ", Width = " + width;

Preview
getArea(); public double

Preview
@Override public double getArea() { return side * side; } @Override public double getPerimiter() { return 4 * side; } public double getSide() {

Preview
static void main(String[] args){ Square square1 = new Square(); square1.setSide(5.5); printShape(square1); Square square2 = new Square(); square2.setSide(8.5); printShape(square2); if(square1.compareTo(square2) == 0){ System.out.println("Shapes are equal"); } else { System.out.println("Shapes are not equal"); } System.out.println("----------------"); Rectangle

Preview
int[] answerKey = new int[numQuestions]; //prompt for answers for(int i=0; i<numQuestions; i++){ System.out.print("Enter answer for question #" + (i + 1) + ": "); int answer = Integer.parseInt(scanner.nextLine()); answerKey[i] = answer; } int numCorrect= 0; boolean grading = true;

Preview
price; } // ------------------------------------------------- // Returns the name of the item // ------------------------------------------------- public String getName() { return name; } // ------------------------------------------------- // Returns the quantity of the item // ------------------------------------------------- public int getQuantity() { return

Preview
items ArrayList<Item> cart = new ArrayList<Item>(); //items Item soap = new Item("soap", 2.50, 2); Item toothpaste = new Item("toothpaste", 4.09, 2); Item paperTowels = new Item("paper towels", 6.99, 1); Item razor = new Item("razor", 7.99, 8); //add item cart.add(soap);

Preview
//assign number list[currentSize] = num; //increment current size currentSize++; } private void increaseSize(){ //new array is size doubled int[] newArr = new int[list.length * 2]; //copy elements into new array for(int i=0; i<list.length; i++){ newArr[i] = list[i];

Preview
scan.nextInt(); list.addElement(num); break; case 4: System.out.println("Enter element to remove first: "); int remove = scan.nextInt(); list.removeFirst(remove); break; case 5: System.out.println("Enter element to remove all: "); int removeAll = scan.nextInt(); list.removeAll(removeAll); break; default: System.out.println("Sorry, invalid choice");

Preview
j < square.length; j++) { sum += square[j][square.length-1-j]; } return sum; } //-------------------------------------- //return true if the square is magic (all rows, cols, and diags have //same sum), false otherwise //-------------------------------------- public boolean magic() { boolean answer

Preview
int size = scan.nextInt(); //size of next square //Expecting -1 at bottom of input file while (size != -1) {//create a new Square of the given size Square s = new Square(size); s.readSquare(scan); //call its read method to read the values

Preview
19 28 38 47 7 9 18 27 29 46 6 8 17 26 35 37 5 14 16 25 34 36 45 13 15 24 33 42 44 4 21 23 32 41 43 3 12 22 31 40 49 2 11 20 4 48 9 6 39 27

Screenshots
Purchase Answer