Preview

Java

Satisfactory Essays
Open Document
Open Document
762 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java
In the long distant future, in the year 2016, the cable news empire has fallen, and former talking heads have stooped to running for political office. In fact, five former talk show stars are running for President of the United States, and locked in a close race.
Your task is to design and implement a set of classes that process a collection of Integer objects, corresponding to votes for each candidate.

The integers are stored in a queue by a driver. In particular, the following code must compile error free and execute correctly on your implementation. You should implement your own generic Queue class. If you borrow code from elsewhere, cite your sources.

public static void main(String[] args) {
Queue<Integer> collection = new Queue<Integer>(); for (int index = 0; index < 10000; index++) { int candidate = ((int) (Math.random() * 10000)) % 5;
Integer integ = new Integer(candidate); collection.enqueue(integ); }
RequestProcessor processor = new
RequestProcessor(collection);
int numberOfThreads = 5;
Thread[] threads = new Thread[numberOfThreads]; for (int index = 0; index < threads.length; index++) { threads[index] = new Thread(processor); threads[index].start(); } try { for (int index = 0; index < threads.length; index++) { threads[index].join(); }
} catch(InterruptedException ie) { ie.printStackTrace(); }
ThreadStatisticsSetup.print();
}
One possible output is:
Tabulator: 1 Count 1137 for candidate Bill
O'Reilly=20.695303967965053%
Tabulator: 1 Count 1077 for candidate Ann
Coulter=19.603203494721516%
Tabulator: 1 Count 1090 for candidate Rachel
Maddow=19.839825263924283%
Tabulator: 1 Count 1094 for candidate Rush
Limbaugh=19.912631962140516%
Tabulator: 1 Count 1096 for candidate Glenn Beck=19.949035311248636%
Tabulator: 2 Count 232 for candidate Bill
O'Reilly=19.414225941422593%
Tabulator: 2 Count 232 for candidate Ann Coulter=19.414225941422593%
Tabulator: 2 Count 243 for candidate Rachel
Maddow=20.334728033472803%
Tabulator: 2 Count 216 for candidate Rush

You May Also Find These Documents Helpful

  • Good Essays

    Honors Discrete Voting Theory Project Part 2 You will be presenting your project on October 17. Conduct your own preference ballot. A. B. C. D. E. F. G. H. I. J. K. L. Determine the winner of the election using the Plurality Method.…

    • 378 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    | Hint: Get the contribution per barrel of Mountain Man Light In the second work sheet…

    • 701 Words
    • 3 Pages
    Powerful Essays
  • Good Essays

    Java

    • 490 Words
    • 3 Pages

    Write a Java program to demonstrate using bitmaps and bitwise operators to sort and remove duplicates from a file of random phone numbers. Do not confuse the term bitmap used for compressing data into smaller spaces with the bitmap that has come to mean a graphic image.…

    • 490 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    Brannigan Foods

    • 2496 Words
    • 42 Pages

    BRANNINGAN FOOD’S DECLINING SOUPS DIVISION Table of Contents       Executive Summary …Slide 3 Hypothesis …Slide 4 Evidence …Slide 5 Background …Slide 6 Market Report … Slide 7-9  Tipha …Slide 23-25  Mackey … Slide 2628  Chung … Slide 2931  Pugh …Slide 32-34  Analysis of the situation…Slide 1021  Current Market Position …Slide 10-12  Competitive Analysis …Slide 1317  SWOT ……

    • 2496 Words
    • 42 Pages
    Powerful Essays
  • Good Essays

    Java

    • 827 Words
    • 4 Pages

    9. The withholding tax on a weekly salary (let us assume) is computed as follows: 14% of the difference between a person's gross pay and $13 times the number of dependents he or she claims. Read the values for the gross pay and the number of dependents; print the withholding tax.…

    • 827 Words
    • 4 Pages
    Good Essays
  • Better Essays

    JAVA

    • 956 Words
    • 4 Pages

    References: Tutorials Point - Simply Easy Learning. (n.d.). Java. Retrieved July 7, 2014, from http://www.tutorialspoint.com/java/java_abstraction.htm…

    • 956 Words
    • 4 Pages
    Better Essays
  • Satisfactory Essays

    Java Programming

    • 461 Words
    • 2 Pages

    Tipping has become just a normal expense already calculated into ones dining experience. It is understood that most services that provide us consumers a way to measure how satisfied we are with the experience of vending with a particular merchant; is done so through tipping.…

    • 461 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    I declare that, apart from properly referenced quotations, this report is my own work and contains no plagiarism; it has not been submitted previously for any other assessed unit on this or other courses.…

    • 2145 Words
    • 9 Pages
    Satisfactory Essays
  • Good Essays

    David Etheridge Java: Graphical User Interfaces – An Introduction to Java Programming Download free eBooks at bookboon.com 2 Java: Graphical User Interfaces – An Introduction to Java Programming © 2009 David Etheridge & Ventus Publishing ApS ISBN 978-87-7681-496-0 Download free eBooks at bookboon.com 3 Contents Java: Graphical User Interfaces Contents 1. 1.1 1.2 1.3 1.4 1.5 1.6 1.7…

    • 4571 Words
    • 19 Pages
    Good Essays
  • Powerful Essays

    When only two candidates are involved, there is only one way to count, but when there are more you can choose a variety of methods. The more candidates that are involved the harder it is to determine who the “real” winner is. The “normal” method in the United States is to vote for a single candidate and take the “absolute” winner out of the group of candidates. Dr. Hawthorne introduced a few other methods and showed how in a group of multiple candidates, the way you count matters.…

    • 1893 Words
    • 8 Pages
    Powerful Essays
  • Good Essays

    Key Words in Java

    • 888 Words
    • 4 Pages

    Part of the Java For Dummies Cheat Sheet The 50 Java keywords have specific meanings within the language, so you can’t use the keywords in this table for anything other than their function within Java. And, you can't make up new meanings for the words false, null, and true, either. But for technical reasons, those three words aren't called keywords. Whatever!…

    • 888 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    Thesis on java

    • 314 Words
    • 2 Pages

    This class consists of static utility methods for operating on objects. These utilities include null-safe or null-tolerant methods for computing the hash code of an object, returning a string for an object, and comparing two objects.…

    • 314 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Inroduction to Java

    • 536 Words
    • 3 Pages

    3. An Application and run-time environment – general purpose program that run n any machine where the java run time environment (JRE) is installed.…

    • 536 Words
    • 3 Pages
    Satisfactory Essays
  • Powerful Essays

    The Art and Science of Java

    • 3909 Words
    • 16 Pages

    1. Babbage’s Analytical Engine introduced the concept of programming to computing. 2. Augusta Ada Byron is generally recognized as the first programmer. The U.S. Department of Defense named the Ada programming language in her honor. 3. The heart of von Neumann architecture is the stored-programming concept, in which both data and programming instructions are stored in the same memory system. 4. Hardware is tangible and comprises the physical parts of a computer; software is intangible and consists of the programs the computer executes. 5. The abstract concept that forms the core of computer science is problem-solving. 6. For a solution technique to be an algorithm, it must be • Clearly and unambiguously defined • Effective, in the sense that its steps are executable • Finite, in the sense that it terminates after a bounded number of steps 7. Algorithmic design refers to the process of designing a solution strategy to fit a particular problem; coding refers to the generally simpler task of representing that solution strategy in a programming language. 8. A higher-level language is a programming language that is designed to be independent of the particular characteristics that differentiate computers and to work instead with general algorithmic concepts that can be implemented on any computer system. The higher-level language used in this text is called Java. 9. Each type of computer has its own machine language, which is different from that used in other computers. The compiler acts as a translator from the higher-level language into the machine language used for a specific machine. 10. A source file contains the actual text of a program and is designed to be edited by people. An object file is created by the compiler and contains a machine-language representation of the program. Most programmers never work directly with object files. 11. A syntax error is a violation of the grammatical rules of the programming…

    • 3909 Words
    • 16 Pages
    Powerful Essays
  • Satisfactory Essays

    Bank

    • 469 Words
    • 2 Pages

    Lab Objectives In this lab we will learn implementation of queue data structure using circular array.…

    • 469 Words
    • 2 Pages
    Satisfactory Essays