Last Assignment

Back ] Up ]

Discussion group, leave your messages

Home
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Last Assignment

150 pts

Implement a small student database system

In this assignment you will implement a small database containing 3 student objects. The information about each student object will have the student's name, grade for exam 1, grade for exam 2 and grade for exam 3. You will build a menu using the switch statement to perform calls to several methods. Your menu will stay constant on the screen until the user chooses to quit. Add the classes that allows user input from Keyboard.

 An example: (You may want to copy this and run it)

// Homework.java

/******************************************************************
 * Homework Assignment Info
 * 
 * Programmer: Michele Clark
 *
 * Description: This program displays information about
 * homework assignments based on a user-entered choice.
 * It demonstrates do loops and switch statements.
 *
 * Input: The user inputs their choice of info to view.
 *
 * Output: The information is presented to the user.
 *
 ******************************************************************/

import java.io.*;
import java.text.*;

public class Homework
{

    public void showAssignment() 
//Displays next assignment on screen.
{
    System.out.println ("\nshowAssignment not implemented");
}

    public void showGrade()
//Asks for a student number and gives the corresponding grade.
{
    System.out.println ("\nshowGrade not implemented");
}

    public void giveHints()
//Displays a hint for the current assignment.
{
    System.out.println ("\nAssignment hints:\n"
      + "Analyze the problem\n"
      + "Write an algorithm in pseudocode.\n"
      + "Translate the pseudocode into a C++ program.");
}


    public static void main (String[] args) throws IOException
{
    BufferedReader stdin = new
BufferedReader (new InputStreamReader (System.in));

    // hmwk is an instance of the Homework class
    Homework hmwk = new Homework();
    int choice;

    do
{
    // display choices for user
    System.out.print ("\n" +
   "Choose 1 to see the next homework assignment.\n"
+ "Choose 2 for your grade on the last assignment.\n"
+ "Choose 3 for assignment hints.\n"
+ "Choose 4 to exit this program.\n"
+ "Enter your choice and press return: ");

    // read an integer from the user
    choice = Integer.parseInt (stdin.readLine());
    
    // call the appropriate method for the choice
    switch (choice)
{
case 1:
    hmwk.showAssignment();
    break;
case 2:
    hmwk.showGrade();
    break;
case 3:
    hmwk.giveHints();
    break;
case 4:
    System.out.println ("End of Program.");
    break;
default:
    System.out.println ("Not a valid choice.\n"
+ "Choose again.");
}
    // repeat the loop until the user enters 4
} while (choice != 4);


System.out.println ("\n\n\nPress Enter to close window");
System.in.read();
}
}



Details

As it happens in the real world, sometimes you want to compare students' scores  and also take averages of exams. Your job will be to create a class called Student and implement the following methods, you may want to create more methods if you wish, but remember simplicity. Also make sure to implement the proper driver.

Your switch statement will be surrounded by some control structure like the while loop and it will repeat itself until the user selects and option to quit the menu (if you implement the keyboard input there will a selection like x, if not, then on your main program you take care of quitting the program, but also done inside the switch)

Make sure to implement all the preconditions/postconditions as part of your documentation, use proper design and create a small test plan with 10 cases. You should create a small Driver that automatically with test your code.  Remember that we spent a large amount of class time in design, so please make sure to apply it on your program since this assignment will be grade as follows:

bullet

50% design, was the program design keeping in mind separating the driver from the server. Formatting, etc.

bullet

30% implementation, used good and correct solution for the given problem, creative, innovative.

bullet

20% testing, test case implemented correctly, is the program fully tested avoiding simple programming errors.

Constructor - It will initialize the student objects with a names, SSN, score for Exam 1, 2 and 3. The user will have to input them.

DisplayExamGrade - It will display any given exam for any student.

DisplayStudentGrades - It will display the information about a desired student only.

DisplayStudentSummary - method to show the student information and their scores for each exam.

Output: (you can create your own names and scores)

Tom Jones
Exam1: 84
Exam2: 99
Exam3: 33

Mary Lou
Exam1: 54
Exam2: 89
Exam3: 85

Walt Morale
Exam1: 84
Exam2: 99
Exam3: 92

CompareGrade -  compare scores for any particular exam. Your switch statement  will have some sample comparisons like: Compare exam 1 for student 1 with exam 1 for student 2 (Have 3 comparisons on your switch menu. The ideal situation would be allowing the user to select which comparison they would want to make and take those values as parameters to the CompareGrade method.

Output (you may have other variations)
Mary Lou scored 54 on Exam 1 
Walt Morale scored 84 on Exam 1
Therefore Walt score was higher

AverageScore - this method will take the values for each score for each exam and average and display them. (this will also be an option on the switch menu)

Output:

The average for all three exams were:
Exam1 average: ??
Exam2 average: ??
Exam3 average: ??

bullet

Create a main method and this client should go through this process:

  1. Create 3 student objects

  2. (Switch option a) Display the student's names, and grade for each exam (summary)

  3. (Switch option b) Display student ?? grades

  4. (Switch option c) Display grade ? for student ?

  5. (Switch option d, e, f) Compare grades, i.e. Student 1 Exam 1 With exam 1 for Student 2

  6. (Switch option g) Display exam averages (most likely there will be a method to do it) 

  7. (Switch option x) Exit menu/program 

Any questions, let instructor know before the assignment is due, remember that if you show this to the instruction prior to the due date you can almost guarantee full points on it!.

TURN IN:

Place it all in a large envelope

(place all in large envelope)

bullet

Your floppy disk with the program

bullet

The hard copy of your source code

bullet

A hard copy of a sample output

bullet

Test plan sheet (s) with the results.

Links that may help you
Java control Structures

bulletlink 1
bulletlink 2
bulletControl flow constructs
bulletControl Structures: Decision and Looping
bulletControl Flow Statements Sun site

 

 

Back to CS161 JAVA Homepage
This page was last modified January 10, 2002
wmorales@pcc.edu