x
notes
#
nested loops
#include 

using namespace std;

int main(){

int myTest;
int countTwentyEight;
int hundred;

hundred = 0;
countTwentyEight = 0;
myTest = 0;

while ( hundred < 10 ){
cout << endl << "Please insert a number" << endl;
cin >> myTest;


if ( myTest == 28 ){
countTwentyEight++;
cout << endl << countTwentyEight << endl;8

}
hundred++;
}

return 0;
}
 
#
It works! Yippeee :)
//////////////////////////////////////////////////
// This program is designed to take the input of//
// the day in Julian Date format and return the //
// day of the week. It should be noted that this//
// is my second version which uses switch statements //
// while my first version used if statements //
// statement. //
//////////////////////////////////////////////////

#include

using namespace std;

int main(){

long julDate;
int dayOfTheWeek;

cout << "\nInsert the Julian Date.\n";
cin >> julDate;

dayOfTheWeek = (julDate + 1) % 7;

switch (dayOfTheWeek) {

case 0 : cout << "\nJulian Date " << julDate << " is on a Sunday\n";
break;
case 1 : cout << "\nJulian Date " << julDate << " is on a Monday\n";
break;
case 2 : cout << "\nJulian Date " << julDate << " is on a Tuesday\n";
break;
case 3 : cout << "\nJulian Date " << julDate << " is on a Wednesday\n";
break;
case 4 : cout << "\nJulian Date " << julDate << " is on a Thursday\n";
break;
case 5 : cout << "\nJulian Date " << julDate << " is on a Friday\n";
break;
case 6 : cout << "\nJulian Date " << julDate << " is on a Saturday\n";
break;
default: cout << "\nI'm not sure what the day of the week is. I might be broken \n";

return 0;
}
}
No replies - reply
 
#
//////////////////////////////////////////////////
// This program is designed to take the input of//
// the day in Julian Date format and return the //
// day of the week. It should be noted that this//
// is my first version which uses if statements //
// while my second version will use the switch //
// statement. //
//////////////////////////////////////////////////

#include

using namespace std;

int main() {

long julDate;
int dayOfTheWeek;

cout << "\nInsert the Julian Date.\n";
cin >> julDate;

dayOfTheWeek = (julDate + 1) % 7;

if (dayOfTheWeek == 0)
cout << "Julian Date " << julDate << " is on a Sunday";
if (dayOfTheWeek == 1)
cout << "Julian Date " << julDate << " is on a Monday";
if (dayOfTheWeek == 2)
cout << "Julian Date " << julDate << " is on a Tuesday";
if (dayOfTheWeek == 3)
cout << "Julian Date " << julDate << " is on a Wednesday";
if (dayOfTheWeek == 4)
cout << "Julian Date " << julDate << " is on a Thursday";
if (dayOfTheWeek == 5)
cout << "Julian Date " << julDate << " is on a Friday";
if (dayOfTheWeek == 6)
cout << "Julian Date " << julDate << " is on a Saturday";

return 0;

}
No replies - reply
 
#
Chapter 5 (pg 202)


C++ Control Structures

if
if else
switch


------
Logical expressions are also called boolean expressions. This is because they can only be true or false.

new statement: bool

it is a built-in value consisting only of two types. True and False. eg 0 or 1

------

Relational operators:

== equal to
!= not equal to
> greater than
< less than
>= greater than or equal to
<= greater than or less than


Logical operators:
&& and
|| or
! not



----------

1) (taxRate > 0.25) && ( income < 20000 )

2) (temperature <= 75) || (humidity < 0.70)

3) (age > 21) && (age < 60)

4)
No replies - reply
 
#
#include // woop woop!

ofstream ("output file stream")
ifstream ("input file stream")

To use disk i/o you must:

--> use #include
--> choose valid _identifiers_ for your filestreams and declare them
--> open the files and associate them with disk names
--> use your filestream identifiers in your i/o statements (using >> and <<, manipulators, get,

ignore)
--> close the damned files!

//############################
//EXAMPLE
//############################

#include

using namespace std;

int main()

ifstream myInfile;
ofstream myOutfile;

myInfile.open("A:\\myIn.dat");
myOutfile.open("A:\\myOut.dat");

myInfile.close();
myOutfile.close();

return 0;

}

#############################


- Pay attention above. If you want a slash in the filename you have to put two. eg:
("A:\\myOut.dat")

- Closing a file does not require arguments. eg myInfile.close() <-- empty parentheses


//############################
//Time
///////////////////////////

#include

ifstream inFile;

string fileName;

cout << "Enter input file name: " << endl; // prompt
cin >> fileName;

//convert string fileName to a C string type

inFile.open( fileName.c_str()); // the c_str() is a seperate function that performs a
// manipulation on the filename in order to make it work.
// JUST ACCEPT IT AND MOVE ON.

//########################################


- if the output file does not exist on disk, a new file with that name is created.


----------------------------------------------------------------------------------

ENTER Object-oriented design principles
ENTER Functional Decomposition methodology

Read the slides for PT 2 of chapter four for definitions of these.

FD (functional decomposition) starts with a:
-Concrete Step - A step for which implementation
details are fully specified.
-Abstract step - A step for which some implementation details remain unspecified
-Module - A self-contained
No replies - reply
 
Profile
notes @ MindSay
No picture
View My Full Profile
RSS Feed
Calendar

November 2009
1234567
891011121314
15161718192021
22232425262728
2930

May 2004
1
2345678
9101112131415
16171819202122
23242526272829
3031

April 2004
123
45678910
11121314151617
18192021222324
252627282930


Older

Recent Visitors

May 7th
google

May 5th
google

May 3rd
google

April 28th
google

April 19th
google

April 15th
google

April 8th
google

March 23rd
google

March 9th
google

March 8th
google

March 4th
google

January 8th
google

January 5th
google

January 2nd
google