Lecture12-w05-LIN-09302019-Exp-Floating-MixDataType-DoWhile.pdf - Computing I COMP.1010 Fall 2019 Lecture 12 Expression(Cont’d Floating Data Type

Lecture12-w05-LIN-09302019-Exp-Floating-MixDataType-DoWhile.pdf

This preview shows page 1 - 11 out of 32 pages.

Computing I By: Sirong Lin, PhD University of Massachusetts Lowell COMP.1010, Fall 2019 Lecture 12: Expression (Cont’d), Floating Data Type, Mixed Data type, Do-while
Image of page 1
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin 2 Upcoming Due Dates Due Date Daily 10 09-30-2019 (M), 9:00pm Week 05 Readings MWF, 9:00am Week 05 Practice 10-06-2019 (Su), 9:00pm Daily 11 10-02-2019 (W), 9:00pm HW1 10-02-2019 (W), in class Daily 12 10-04-2019 (F), 9:00pm Program 1 10-09-2019 (W), 9:00pm
Image of page 2
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Announcement Lab this week: Lab 09 (Linux) instead of Lab 05 (Elevator) Office hours this week: Monday/Wed.: 1:55pm - 3:30pm no hours on Friday (Oct. 4) 3
Image of page 3
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Outline Floating Data Type & Mixed Data type Expression do-while loop 4
Image of page 4
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Extended Precision Type double Floating Number Type float 5
Image of page 5
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin A problem to solve Write a program to read a total score and the number of scores from the user. Both numbers should be positive. Calculate and output the score average. How to make sure the user enters positive values? What data type to use for these variables? 6
Image of page 6
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin A problem to solve (Cont’d) Valid input condition: both numbers positive (totalScore > 0 && numScore > 0) Invalid input condition: opposite of valid condition !(totalScore > 0 && numScore > 0) or either one of them is not positive, i.e., (totalScore <= 0 || numScore <= 0) 7
Image of page 7
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin A problem to solve (Cont’d) while user enters invalid input, we’ll keep asking them to enter a new number 8 while (totalScore <= 0 || numScore <= 0) { }
Image of page 8
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin A problem to solve (Cont’d) totalScore can be floating type, or int type (any difference?) numScore int type average floating type, e.g., double 9
Image of page 9
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Floating Data Type Example Consider expression
Image of page 10
Image of page 11

You've reached the end of your free preview.

Want to read all 32 pages?

  • Fall '15

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors