project 5

3
Computer Science 121 Programming Project 5 Due Monday, December 8th at 4 PM 100 Points In this project, you will be asked to create five different Java programs. Anything submitted after the deadline stated above will be considered late. Remember that there is a 10% penalty for every 24 hours late. At the top of each Java source file, you must include the following comment: / * * Your Name * Submission Date * CS 121 * Name of Program * * Describe what the program does in one to two sentences. * / Also, include additional comments throughout the code to provide proper documentation. You do not need to provide a comment for every single line of code, but you should explain different parts of your program using comments. If your program does not include comments throughout our code, you will lose points. You must also include comments briefly describing each method you create. 1 True/False Exam (20 Points) Name the class: Exam Your computer science professor needs help grading a True/False exam (A computer science true/false exam? Please). The students’ IDs and test answers are stored in a file. The first entry in the file contains the answers to the exam in the following form: TFFTFFTTTTFFTFTFTFTT Every other entry in the file is the student’s ID, followed by a blank, followed by the student’s response. For example, the entry: 700123456 TFTFTFTT TFTFTFFTTFT 1

Upload: joe-dane

Post on 15-Nov-2015

42 views

Category:

Documents


1 download

DESCRIPTION

The fifth project for CS101 at WVU Tech

TRANSCRIPT

  • Computer Science 121

    Programming Project 5Due Monday, December 8th at 4 PM

    100 Points

    In this project, you will be asked to create five different Java programs. Anything submitted after thedeadline stated above will be considered late. Remember that there is a 10% penalty for every 24 hourslate. At the top of each Java source file, you must include the following comment:

    /** Your Name

    * Submission Date

    * CS 121

    * Name of Program

    ** Describe what the program does in one to two sentences.

    */

    Also, include additional comments throughout the code to provide proper documentation. You donot need to provide a comment for every single line of code, but you should explain different parts ofyour program using comments. If your program does not include comments throughout our code,you will lose points. You must also include comments briefly describing each method you create.

    1 True/False Exam (20 Points)

    Name the class: ExamYour computer science professor needs help grading a True/False exam (A computer science true/falseexam? Please). The students IDs and test answers are stored in a file. The first entry in the file containsthe answers to the exam in the following form:

    TFFTFFTTTTFFTFTFTFTT

    Every other entry in the file is the students ID, followed by a blank, followed by the students response.For example, the entry:

    700123456 TFTFTFTT TFTFTFFTTFT

    1

  • indicates that the students ID is 700123456 and the answer to Question 1 is True, the answer toQuestion 2 is False, and so on. The student did not answer Question 9. Note that a student ID may notnecessarily be only numbers, but it does not have spaces. The exam has 20 questions, and the classhas no more than 150 students. Each correct answer is awarded 2 points, each incorrect answer and noanswer gets 0 points.

    Write a program that processes the test data. The output should be the students ID, followed by theanswers, followed by the test score, followed by the test grade. Assume the following grade scale:

    90% - 100% A80% - 89% B70% - 79% C60% - 69% D0% - 59% F

    2 Election Results (20 Points)

    Name the class: ElectionWrite a program that allows the user to enter the last names of five candidates in a local election andthe votes received by each candidate. The program should then output each candidates name, the votesreceived by that candidate, and the percentage (rounded to 2 decimal places) of the total votes receivedby the candidate. Your program should also output the total number of votes and the winner of theelection. A sample output is:

    Candidate Votes Received % of Total VotesBaber 6022 1.33Buckley 7932 1.76Capito 280012 61.96Hudok 2543 0.56Tennant 155395 34.39Total 451904The Winner of the Election is Capito.

    Note: You must use an array for storing this information.

    3 Test Scores (20 Points)

    Name the class: ScoresRecall in Homework 1 that you were asked to write algorithms for processing test scores. Youre nowgoing to implement those algorithms.

    Write a program that allows the user to enter students names followed by their test scores and outputsthe following information (assume that the maximum number of students in the class is 50):

    2

  • a. Class average.

    b. Names of all the students whose test scores are below the class average, with an appropriate message.

    c. Highest test score and the names of all the students having the highest score.

    4 Adding Large Integers (20 Points)

    Name the class: IntegersIn Java, the largest int value is 2147483647. So an integer larger than this cannot be stored andprocessed as an integer. Similarly, if the sum or product of two positive integers exceeds 214748367,then the result will be incorrect (Try it and see what happens). One way to store and manipulate largeintegers is to store each individual digit of the number in an array.

    Write a program that inputs two positive integers and outputs the sum of the integers. Note: Read thenumbers as Strings and store the digits of the number in reverse order.

    5 Temperatures (20 Points)

    Name the class: TemperatureWrite a program that uses a two-dimensional array to store the highest and lowest temperatures for eachmonth of the year. The program should output the average high, average low, and highest and lowesttemperatures of the year. Your program must consist of the following methods:

    a. getData: This method reads and stores the data in the two-dimensional array.

    b. averageHigh: This method calculates and returns the average high temperature of the year.

    c. averageLow: This method calculates and returns the average low temperature of the year.

    d. indexHighTemp: This method returns the index of the highest temperature in the array.

    e. indexLowTemp: This method returns the index of the lowest temperature in the array.

    These methods must all have the appropriate parameters.

    How to SubmitYou will need to submit the .java file of each program onto eCampus. Be sure to attach all five .javafiles before you submit.

    3