Cgs-2060-18 (Akache) Project 1

weaverchurchΛογισμικό & κατασκευή λογ/κού

15 Αυγ 2012 (πριν από 5 χρόνια και 2 μήνες)

219 εμφανίσεις


Cop
-
2250
-
U
03
-
U0
4

Fall
2011

(Akache) Project
6



Note:

This project is to do problems
5

and
7

on pages
5
35, 5
36

of the
textbook
.


1.

If necessary, create in the Flash disk a folder with the name:

YourLastName_YourFirstName_Cop2250_U03
orU0
4
_
Fall
2011

2.

Create in
side the folder above a folder with the name:

Projects

3.

Start Netbeans to create a New Project for a Java Application with the


Name
:
Project
_6_1

Location:
Project
s

Folder created in step 2 above.

4.

Create a new Empty Java Class file with name

DriverExam.

Us
e the UML image down to
write the code for this class.

5.

Create a new Empty Java Class file with name
DriverTest
.

Write the code that will ask the
user to enter his answers to the 20 questions and then displays the results returned from
the DriverExam class’
s methods. (Validate the user

s entries to be A, B, C, or D as
answers).

6.

Start Netbeans to create a New Project for a Java Application with the


Name:
Project
_6_2

Location:
Projects Folder created in step 2 above.

7.

Create a new Empty Java Class file with n
ame
GradeBook
. Use the UML image below to
write the code for this class.

8.

Create a new Empty Java Class file with name
GradeBookTest
. Write the code that will
ask the user
for input. Make sure to validate the input.

9.

Use the skeleton file below.


Generate Ja
vadoc for the classes then print.


10.

Run
P
roject
_
6_1 and
Run
P
roject
_6_2

using
appropriate data
.

11.

Print
the Class
es

FROM WITHIN NetBeans
and

the Output as instructed in class.




All printouts and the
Flash

disk should be enclosed in an envelope 9”X12”.

IF n
ecessary use Word to enter your name, class, section, term at the top and
insert one of your photos then print. Tape the photo sheet on the front of
your envelope. (
20 POINTS OFF if not done)


Due Date
:

SectionU03 At the beginning of the Final Exam on
--

T
uesday

December
6
,
201
1
.

[[ Exam time: 1200
-
1400 PM]]

Due Date
: SectionU0
4

At the beginning of the Final Exam on
--

Tuesday

December
6,
2011
.

[[ Exam time:
5
-
7

PM]]





/* A demonstration of how to

Create Classes
and Arrays
and Test them.


* Your Name


* C
op2250
-
U03
or U0
4

Project
_6


* #
5 and # 7
on page
s

5
3
5
,
5
3
6

of the textbook


*

*/

This is the UML for DriverExam



This is the UML for GradeBook

Skeleton for problem 7.

/**


GradeBook class


Chapter 8, Programming Challenge 7

*/


public class GradeBo
ok

{


// Constant for the number of students


private final int NUM_STUDENTS = 5;




// Constant for the number of tests


private final int NUM_TESTS = 4;




// Array to hold student names


private String[] names = new String[NUM_STUDENTS];




// Array to hold student grades


private char[] grades = new char[NUM_STUDENTS];




// Create arrays of scores, one for each student.


private double[] scores1 = new double[NUM_TESTS];


private double[] scores2 = new double[NUM_TESTS];



private double[] scores3 = new double[NUM_TESTS];


private double[] scores4 = new double[NUM_TESTS];


private double[] scores5 = new double[NUM_TESTS];



/**


The setName method assigns a student's name.


@param studentNumber The student's

number.


@param name The student's name.


*/




public void setName(int studentNumber, String name)


{


// your code


}




/**


The setScores method copies an array of test scores


to a student's array of scores.


@p
aram studentNumber The student's number.


@param scores An array of test scores.


*/




public void setScores(int studentNumber, double[] scores)


{



//your code


}




/**


The getName method returns a student's name.


@p
aram studentNumber The specified student's number.


@return The student's name.


*/




public String getName(int studentNumber)


{



//your code


}




/**


The getAverage method returns a student's average


test score
.


@param studentNumber The specified student's number.


@return The student's average test score.


*/




public double getAverage(int studentNumber)


{


//your code


}




/**


The getLetterGrade method returns a stu
dent's


letter grade.


@param studentNumber The specified student's number.


@return The student's letter grade.


*/




public char getLetterGrade(int studentNumber)


{


//your code


}



/**


copyArray is a privat
e method that copies the contents


of one array to another.


@param to The array to copy to.


@param from The array to copy from.


*/




private void copyArray(double[] to, double[] from)


{


//your code


}




/**



calcAverage is a private method that calculates


the average of the values in an array of test scores.


@param scores The array with the test scores.


*/




private double calcAverage(double[] scores)


{


//your code


}





/**


assignGrade is a private method that determines and


assigns a letter grade to a specific student.


@param studentNumber The specified student's number.


*/




private void assignGrade(int studentNumber)


{


//y
our code


}



/**


determineGrade is a private method that determines


a letter grade for a test average.


@param average The test average.


@return The letter grade.


*/




private char determineGrade(double average)


{



//your code


}

}

/**


GradeBook
Test

program


This program tests the GradeBook class with user keyboard input.

*/

import java.util.Scanner;


public class GradeBook
Test

{


public static void main(String[] args)


{


// Create a Grade
Book object.


//your code



// Get the data from the user.


//your code




// Display the student data.


System.out.println("STUDENT DATA");


for (int i = 1; i <= 5; i++)


{


//your code


}


}



/**


The getData method gets student data from the user


and populates a GradeBook object.


@param gb The GradeBook object.


*/




public static void getData(GradeBook gb)


{


String name;


//

To hold a name


double[] scores = new double[4];

// An array of scores



// Create a Scanner object for keyboard input.


Scanner keyboard = new Scanner(System.in);




// Get info for each student.


for (int student = 1; s
tudent <= 5; student++)


{


// Get the name.


//your code




// Read the 4 test scores.


//your code



// Consume the remaining newline.




keyboard.nextLine();


}




System.out.println();



}

}