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

• 32

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
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
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
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
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Extended Precision Type double Floating Number Type float 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
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
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) { }
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
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Floating Data Type Example Consider expression

#### You've reached the end of your free preview.

Want to read all 32 pages?

• Fall '15

### What students are saying

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

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

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

Dana University of Pennsylvania ‘17, Course Hero Intern

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

Jill Tulane University ‘16, Course Hero Intern