+ All Categories
Home > Documents > The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon)...

The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon)...

Date post: 31-Mar-2015
Category:
Upload: zoie-lugg
View: 216 times
Download: 2 times
Share this document with a friend
Popular Tags:
26
The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm—8:30pm 9/11/2012 and 9/12/2012
Transcript
Page 1: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

The 3rd and 4th tutoring session-- A case study about using variables

Fall, 2012

Haidong(Haydon) Xue

5:30pm—8:30pm9/11/2012 and 9/12/2012

Page 2: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

• CSc2310 Tutoring• Time: 5:30pm-8:30pm• Tutor: Haidong Xue (You can call me Haydon)

There are 2 sections:1. Review 5:30pm – 6:30pmA case study, and make a program for this case.

2. Q&AIf you have any questions about Java programming, I am right here

Page 3: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Computing a course average -- Overview

• The CourseAverage program will calculate a class average, using the following percentages:Programs 30% // 8 programsQuizzes 10% // 5 quizzesTest 1 15% Test 2 15%Final exam 30%

• courseAverage = .30 programAverage 5 + .10 quizAverage 10 + .15 test1 + .15 test2 + .30 finalExam

• The user will enter the grade for each program (0–20), the score on each quiz (0–10), and the grades on the two tests and the final (0–100). There will be eight programs and five quizzes.

Page 4: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Computing a course average – A legal output

Welcome to the CSc2310 average calculation program.Enter program 1 score (0-20):20Enter program 2 score (0-20):20Enter program 3 score (0-20):20Enter program 4 score (0-20):20Enter program 5 score (0-20):20Enter program 6 score (0-20):20Enter program 7 score (0-20):20Enter program 8 score (0-20):20Enter quiz 1 score (0-10):10Enter quiz 2 score (0-10):10Enter quiz 3 score (0-10):10Enter quiz 4 score (0-10):10Enter quiz 5 score (0-10):10Enter test 1 score (0-100):100Enter test 2 score (0-100):100Enter final exam score (0-100):100The final grade is: 100

(Users’ inputs are in red font)

Page 5: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Computing a course average – What should we finish for it?

Page 6: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Computing a course average – What should we finish for it?

1. Print the introductory message ("Welcome to the CSc 2310 average calculation program").

2. Prompt the user to enter eight program scores.3. Compute the program average from the eight scores.4. Prompt the user to enter five quiz scores.5. Compute the quiz average from the five scores.6. Prompt the user to enter scores on the tests and final

exam.7. Compute the course average from the program average,

quiz average, test scores, and final exam score.8. Round the course average to the nearest integer and

display it.

Page 7: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!

• Please get your Eclipse ready• Create a class named CourseAverage with

main method

If you are not very confident, please download and open this code first (it is the finished program):http://www.cs.gsu.edu/~hxue1/csc2310Tutoring/CourseAverage.java

Page 8: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!

1. Print the introductory message ("Welcome to the CSc 2310 average calculation program").

Code:

Page 9: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!

1. Print the introductory message ("Welcome to the CSc 2310 average calculation program").

Code:// Print the introductory messageSystem.out.println("Welcome to the CSc2310 average calculation program.");

Page 10: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!

2. Prompt the user to enter eight program scores.

Code:

Page 11: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!

2. Prompt the user to enter eight program scores.

Code:

// Create a ScannerScanner s = new Scanner(System.in);

// Collect 8 program scoresSystem.out.print("Enter program 1 score (0-20):");double program1 = s.nextDouble();

System.out.print("Enter program 2 score (0-20):");double program2 = s.nextDouble();

Page 12: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

System.out.print("Enter program 3 score (0-20):");double program3 = s.nextDouble();

System.out.print("Enter program 4 score (0-20):");double program4 = s.nextDouble();

System.out.print("Enter program 5 score (0-20):");double program5 = s.nextDouble();

System.out.print("Enter program 6 score (0-20):");double program6 = s.nextDouble();

System.out.print("Enter program 7 score (0-20):");double program7 = s.nextDouble();

System.out.print("Enter program 8 score (0-20):");double program8 = s.nextDouble();

Page 13: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!

3. Compute the program average from the eight scores.

Code:

Page 14: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!

3. Compute the program average from the eight scores.

Code:

// Calculate the average program scoredouble programAverage = (program1 + program2 + program3 + program4 + program5 + program6 + program7 + program8)/8;

Page 15: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!4. Prompt the user to enter five quiz scores.Code:

Page 16: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!4. Prompt the user to enter five quiz scores.Code:

// Collect 5 quiz scoresSystem.out.print("Enter quiz 1 score (0-10):");double quiz1 = s.nextDouble();

System.out.print("Enter quiz 2 score (0-10):");double quiz2 = s.nextDouble();

System.out.print("Enter quiz 3 score (0-10):");double quiz3 = s.nextDouble();

System.out.print("Enter quiz 4 score (0-10):");double quiz4 = s.nextDouble();

System.out.print("Enter quiz 5 score (0-10):");double quiz5 = s.nextDouble();

Page 17: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!5. Compute the quiz average from the five

scores.Code:

Page 18: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!5. Compute the quiz average from the five

scores.

Code:

// Calculate the average quiz scoredouble quizAverage = (quiz1 + quiz2 + quiz3 + quiz4 + quiz5)/5;

Page 19: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!6. Prompt the user to enter scores on the tests

and final exam.Code:

Page 20: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!6. Prompt the user to enter scores on the tests

and final exam.

Code:

// Collect 2 test scoresSystem.out.print("Enter test 1 score (0-100):");double test1 = s.nextDouble();

System.out.print("Enter test 2 score (0-100):");double test2 = s.nextDouble();

// Collect the final test scoreSystem.out.println("Enter final exam score (0-100):");double finalExam = s.nextDouble();

Page 21: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!7. Compute the course average from the program average,

quiz average, test scores, and final exam score.

Code:

Page 22: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!7. Compute the course average from the program average,

quiz average, test scores, and final exam score.

Code:

// Calculate the course averagedouble courseAverage = .30 * programAverage * 5 + .10 * quizAverage * 10 + .15 * test1 + .15 * test2 + .30 * finalExam;

Page 23: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!8. Round the course average to the nearest

integer and display it.

Code:

Page 24: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Let’s code it step by step!8. Round the course average to the nearest

integer and display it.

Code:

// Output the course averageSystem.out.println("The final grade is: " + Math.round(courseAverage));

Page 25: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

Run this program

• Please run your code, and let me know your questions.

• The finished code is at:http://www.cs.gsu.edu/~hxue1/csc2310Tutoring/CourseAverage.java

Page 26: The 3 rd and 4 th tutoring session -- A case study about using variables Fall, 2012 Haidong(Haydon) Xue 5:30pm8:30pm 9/11/2012 and 9/12/2012.

If you have any questions about this program or java programming, I will be here till 8:30pm


Recommended