CS 1430: Programming in C++.

Slides:



Advertisements
Similar presentations
Class Scope class Student { private: string id; string firstName, lastName; float gpa; public: void Read() { cin >> id >> firstName >> lastName >> gpa;
Advertisements

Student Data Score First Name Last Name ID GPA DOB Phone... How to store student data in our programs? 1.
Enumeration Data Type enum Day {SUN, MON, TUE, WED, THU, FRI, SAT}; Day today; today = WED; if (today == FRI) cout
COMP102 – Programming Fundamentals I LA2B (Mon 5-7pm) LA2E (Fri 3-5pm) LA2F (Fri 5-7pm) TA: Jackie Lo.
Prof. amr Goneid, AUC1 CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 6. Simple and User Defined Data Types.
1 Lab Session-III CSIT121 Fall 2000 Setting Your Own Paths Setting Project Information Browse Information Generation Data types revisited Enumerated data.
/3024/ SUN MON TUE WED THU FRI SAT JANUARY 2011 February 2011 SMTWTFS
Define our own data types We can define a new data type by defining a new class: class Student {...}; Class is a structured data type. Can we define our.
Selection Sorting S[] : array of int or float Size: number of elements of s[] Pseudocode for i = 0 to size - 2 find the index of a smallest element between.
Class Constructors class Student { private: string id, firstName, lastName; float gpa; public: Student() Student(string sID) Student(string first, string.
2/19/2016IT 279, Chung-Chih Li1 Branching Condition Statement list 1 T F Statement list 2 Condition Statement list T F.
Class Method Read class Student { private: string id; string firstName, lastName; float gpa; public: // Will the method change any data members? // Yes!
Nested Structures struct TDate { int year, month, day; }; struct StudentType { string id, firstName, lastName; float gpa; TDate DOB; }; struct SectionType.
5 Day Forecast Mon Tues Wed Thu Fri.
Jeff West - Quiz Section 2
FK International School First Term(2017/2018)School Calendar
GANTT CHARTS Example Example Example Example text Tasks Example 1
Mon – 2Tue – 3Wed – 4Thu - 5Fri - 6Sat - 7Sun - 8 Mon – 9Tue – 10Wed – 11Thu - 12Fri – 13Sat – 14Sun -15 Mon – 16Tue – 17Wed – 18Thu - 19Fri – 20Sat –
CS 1430: Programming in C++.
Student Data Score First Name Last Name ID GPA DOB Phone ...
JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER
JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER

CS 1430: Programming in C++.
CS 1430: Programming in C++.
CS 1430: Programming in C++.
Enumeration Data Type enum Day {SUN, MON, TUE, WED, THU, FRI, SAT};
MON TUE WED THU
1   1.テキストの入れ替え テキストを自由に入れ替えることができます。 フチなし全面印刷がおすすめです。 印刷のポイント.
JANUARY FEBRUARY MARCH APRIL MAY JUNE JULY AUGUST SEPTEMBER
Logo Calendar – January 2012 TO DO LIST 01/04/2012 Example TO DO LIST
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
2017 Jan Sun Mon Tue Wed Thu Fri Sat
CS 1430: Programming in C++.

ANNUAL CALENDAR HOLIDAYS JANUARY FEBRUARY MARCH APRIL MAY JUNE
HOLIDAYS ANNUAL CALENDAR JANUARY FEBRUARY MARCH APRIL MAY JUNE
January Sun Mon Tue Wed Thu Fri Sat
January MON TUE WED THU FRI SAT SUN
January MON TUE WED THU FRI SAT SUN
Jan Sun Mon Tue Wed Thu Fri Sat
HOLIDAYS ANNUAL CALENDAR JANUARY FEBRUARY MARCH APRIL MAY JUNE
2008 Calendar.
S M T W F S M T W F
January MON TUE WED THU FRI SAT SUN
Sun Mon Tue Wed Thu Fri Sat
2 0 X X s c h e d u l e 1 MON TUE WED THU JANUARY 20XX FRI SAT SUN MEMO.
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
Calendar
Calendar – 2010 (October, November & December)
January MON TUE WED THU FRI SAT SUN
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
Sun Mon Tue Wed Thu Fri Sat
1/○~1/○ weekly schedule MON TUE WED THU FRI SAT SUN MEMO
January MON TUE WED THU FRI SAT SUN
S M T W F S M T W F
2016 | 10 OCT SUN MON TUE WED THU FRI SAT
Sun Mon Tue Wed Thu Fri Sat
JANUARY 1 Sun Mon Tue Wed Thu Fri Sat
WEB PAGES: Tables Welcome Back !.
1 January 2018 Sun Mon Tue Wed Thu Fri Sat
1 January MON TUE WED THU FRI SAT SUN MEMO 2 February MON TUE WED THU FRI SAT SUN.
Structures Chapter 4.
2008 Calendar.
S M T W F S M T W F
Selection Sorting S[] : array of int or float
S M T W F S M T W F
1 January MON TUE WED THU FRI SAT SUN MEMO 2 February MON TUE WED THU FRI SAT SUN.
Presentation transcript:

CS 1430: Programming in C++

Enumeration Data Type enum Day {SUN, MON, TUE, WED, THU, FRI, SAT}; Day today; today = MON; if (today == FRI) cout << "We have a quiz or a test!"; else if (today == THU) cout << “We have a Lab!"; else if (today == SAT) cout << “Party!"; else cout << “What to do?”;

Switch Statement enum Day {SUN, MON, TUE, WED, THU, FRI, SAT}; Day today; today = MON; . . . switch (today) { case FRI: cout << "We have a quiz or a test!"; case THU: cout << “We have a Lab!"; case SAT: cout << “Party!"; default: cout << “What to do?”; }

Must BREAK! today = MON; . . . switch (today) { case FRI: cout << "We have a quiz or a test!"; break; case THU: cout << “We have a Lab!"; case SAT: cout << “Party!"; default: cout << “What to do?”; }

Must BREAK! today = MON; . . . switch (today) { case FRI: cout << "We have a quiz or a test!"; break; case THU: cout << “We have a Lab!"; case SAT: case SUN: cout << “Party!"; default: cout << “What to do?”; }

Using enum Type in C++ Classes enum Status {FRESHMAN, SOPHOMORE, JUNIOR, SENIOR}; class StudentType { private: string id; string firstName, lastName; float gpa; Status standing; public: . . . };

C++ String string Standing() const { string s; if (standing == FRESHMAN) s = “FRESHMAN”; else if (standing == SOPHOMORE) s = “SOPHOMORE”; else if (standing == JUNIOR) s = “JUNIOR”; else s = “SENIOR”; return s; }

C++ String and Switch string Standing() const { string s; switch (standing) case FRESHMAN: s = “FRESHMAN”; break; case SOPHOMORE: s = “SOPHOMORE”; case JUNIOR: s = “JUNIOR”; default: s = “SENIOR”; } return s;

C String and Switch void Standing(char s[]) const { switch ( standing ) case FRESHMAN: strcpy(s, “FRESHMAN”); break; case SOPHOMORE: strcpy(s, “SOPHOMORE”); case JUNIOR: strcpy(s, “JUNIOR”); default: strcpy(s, “SENIOR”); } return;

Method Write of Class StudentType void Write() const { string status; Standing(status); cout << endl << setw(25) << id << endl << setw(25) << firstName << endl << setw(25) << lastName << endl << setw(25) << gpa; << endl << setw(25) << status; return; }

(for a total of 50 points on quizzes) Schedule Quiz8-1 By 10 PM Today! One Bonus Point (for a total of 50 points on quizzes)

Quiz 3 Wednesday, Dec 2 (week 14) Test 3 Wednesday (week 15) Schedule Quiz 3 Wednesday, Dec 2 (week 14) Test 3 Wednesday (week 15)