情報基礎 b lecture 5 takeshi tokuyama tohoku university graduate school of information sciences...

16
情情情情 B Lecture 5 Takeshi Tokuyama Tohoku University Graduate School of Information Sciences System Information Sciences Design and Analysis of Information Systems

Upload: clare-tanney

Post on 14-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

情報基礎 B   Lecture 5

Takeshi TokuyamaTohoku University Graduate School of Information

SciencesSystem Information Sciences

Design and Analysis of Information Systems

SPREADSHEET 2

Copying Data

• Copy data by entering cell number (Numeric data, character data, formula)– G1 =English– G2 =G1– H2 =C1– H3 =E2

Comparing data

• Comparison– A15 =10>3– B15 =10<3– C15 =(10*2)<3– D15 =C1>C2– E16 =C7>E2

• Result is “TRUE” or “FALSE”

Simple Program

• Blanching by “TRUE” and ”FALSE”• IF function

– IF(criterion, action1, action2)• Proceed action1 when the criterion is true,

otherwise proceed action2

– =IF(logical_test, value_if_true, value_if_false)

Logical test or cell numberLogical test or cell numberCharacters with “” or numbersCharacters with “” or numbers

Simple Program

• Operand used in logical test– A=B A is equal to B– A>B A is larger than B– A>=B A=B or A>B– A<>B A is not equal to B– A<B A is smaller than B– A<=B A=B or A<B

Simple Program

value_if_truevalue_if_true

FALSEvalue_if_falsevalue_if_false

=IF(logical_test, value_if_true, value_if_false)=IF(logical_test, value_if_true, value_if_false)

TRUE

=IF(logical_test ,“ string”, “string”)•B16 = IF (A15, “True”, “False” )•C16 = IF (C1>C2, “Correct”, “Wrong” )  

=IF(logical_test , 1, 0)

•A16 = IF (A15, 1, 0 )

logical_test

Simple Program

• D16 =IF(A1>=80, “Pass”, “Fail”)

PassPass

FALSE

TRUE

FailFail

>=80

Exercise1Simple Program : Grading

• Program a grading system on excel which outputs “Pass” or “Fail”– Pass: if an Score of Japanese, English, Math is

more than 80– Fail: otherwise– Add “Result” on G1– Display “Pass” or “Fail” on G2 to G21

Branching

AATRUE

FALSETRUE

FALSE TRUE

FALSETRUE

FALSEFALSE

FF

BB

CC

DD

>=90

>=80

>=70

>=60

Branching

• Nesting “IF”

=IF(B2>=90, “A”, )=IF(B2>=90, “A”, )IF(B2>=80, “B”, [others])IF(B2>=80, “B”, [others])

AATRUE

FALSETRUE BB

[others][others]FALSE

>=90

>=90

Branching

AATRUE

FALSETRUE

FALSETRUE

FALSETRUE

FALSEFALSE

FF

BB

CC

DD

>=90

>=80

>=70

>=60

Grading

• Grade– A 100 > Score >= 90– B 90 > Score >= 80– C 80 > Score >= 70– D 70 > Score >= 60– F 60 > Score

=IF(B2>=90, ”A”, IF(B2>=80, ”B”, IF(B2>=70, ”C”, IF(B2>=60, ”D”, “F”))))

=IF(B2>=90, ”A”, IF(B2>=80, ”B”, IF(B2>=70, ”C”, IF(B2>=60, ”D”, “F”))))

Exercise2Simple Program : Grading 2

• Program a grading system on excel which outputs “A”, “B”, “C”, “D” or “F” for each Subject

○ A 100 > Score >= 90○ B 90 > Score >= 80○ C 80 > Score >= 70○ D 70 > Score >= 60○ F 60 > Score

– Add “Japanese”, “English” and “Math” each on G1, H1 and I1

– Display “A”, “B”, “C”, “D” or “F” on G2 to I21

Count

• How many student got A on Japanese?

=COUNTIF(range, criteria)

=COUNTIF(G2:G21, “A”)=COUNTIF(G2:G21, “A”)

Exercise3Simple Program : Counting

• Count numbers of student for each grade and subject

  Japanese English Math

A 6 4 5

B 4 7 6

C 3 4 2

D 3 1 2

F 4 4 5