1 / 26

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

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 . CSc2310 Tutoring Time: 5:30pm-8:30pm Tutor: Haidong Xue (You can call me Haydon) There are 2 sections: 1. Review 5:30pm – 6:30pm

kaloni
Télécharger la présentation

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

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. CSc2310 Tutoring • Time: 5:30pm-8:30pm • Tutor: HaidongXue (You can call me Haydon) There are 2 sections: 1. Review 5:30pm – 6:30pm A case study, and make a program for this case. 2. Q&A If you have any questions about Java programming, I am right here

  3. Computing a course average -- Overview • The CourseAverage program will calculate a class average, using the following percentages: Programs 30% // 8 programs Quizzes 10% // 5 quizzes Test 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.

  4. Computing a course average – A legal output Welcome to the CSc2310 average calculation program. Enter program 1 score (0-20):20 Enter program 2 score (0-20):20 Enter program 3 score (0-20):20 Enter program 4 score (0-20):20 Enter program 5 score (0-20):20 Enter program 6 score (0-20):20 Enter program 7 score (0-20):20 Enter program 8 score (0-20):20 Enter quiz 1 score (0-10):10 Enter quiz 2 score (0-10):10 Enter quiz 3 score (0-10):10 Enter quiz 4 score (0-10):10 Enter quiz 5 score (0-10):10 Enter test 1 score (0-100):100 Enter test 2 score (0-100):100 Enter final exam score (0-100):100 The final grade is: 100 (Users’ inputs are in red font)

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

  6. 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.

  7. 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

  8. Let’s code it step by step! 1. Print the introductory message ("Welcome to the CSc 2310 average calculation program"). Code:

  9. Let’s code it step by step! 1. Print the introductory message ("Welcome to the CSc 2310 average calculation program"). Code: // Print the introductory message System.out.println("Welcome to the CSc2310 average calculation program.");

  10. Let’s code it step by step! 2. Prompt the user to enter eight program scores. Code:

  11. Let’s code it step by step! 2. Prompt the user to enter eight program scores. Code: // Create a Scanner Scanner s = new Scanner(System.in); // Collect 8 program scores System.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();

  12. 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();

  13. Let’s code it step by step! 3. Compute the program average from the eight scores. Code:

  14. Let’s code it step by step! 3. Compute the program average from the eight scores. Code: // Calculate the average program score double programAverage = (program1 + program2 + program3 + program4 + program5 + program6 + program7 + program8)/8;

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

  16. Let’s code it step by step! 4. Prompt the user to enter five quiz scores. Code: // Collect 5 quiz scores System.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();

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

  18. Let’s code it step by step! 5. Compute the quiz average from the five scores. Code: // Calculate the average quiz score double quizAverage = (quiz1 + quiz2 + quiz3 + quiz4 + quiz5)/5;

  19. Let’s code it step by step! 6. Prompt the user to enter scores on the tests and final exam. Code:

  20. Let’s code it step by step! 6. Prompt the user to enter scores on the tests and final exam. Code: // Collect 2 test scores System.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 score System.out.println("Enter final exam score (0-100):"); double finalExam = s.nextDouble();

  21. 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:

  22. 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 average double courseAverage = .30 * programAverage * 5 + .10 * quizAverage * 10 + .15 * test1 + .15 * test2 + .30 * finalExam;

  23. Let’s code it step by step! 8. Round the course average to the nearest integer and display it. Code:

  24. Let’s code it step by step! 8. Round the course average to the nearest integer and display it. Code: // Output the course average System.out.println("The final grade is: " + Math.round(courseAverage));

  25. 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

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

More Related