-=«MÄLÅÇhïtÊ»=-
Gender: MALE!!!
Nino, if u miss ur prac..u get 0...(assuming ur whole class was marked..which is rare)
Here's my code from last yr..juz so u guys know how commenting should be done.
****************************************************
* Author: -= Zhaostar=- 40333337
* Date Created: 18/03/03
* Purpose: COMP 115, Sem 1, 2003, Assignment 1
* A paper size determination program for
* the Copy Shoppe
****************************************************/
#include <iostream>
#include <cstdlib>
using namespace std;
// a function to determine paper size
int size(float, float);
int main()
{
// the input dimensions of the object
float dimension1, dimension2;
// variable x will be used later so values of dimension1
// and dimension2 can be swicthed
float x;
cin >> dimension1 >> dimension2; // do not change this line
// Write your code here
if (dimension1 > dimension2)
// switches values of dimension1 and dimension2
// avoids any confusion in defining which sides are height and width
{
x = dimension1;
dimension1 = dimension2;
dimension2 = x;
}
// variable result equals the return value from size(dimension1, dimension2)
int result = size(dimension1, dimension2);
if (result >= 0)
// for return values greater or equal to zero
{
cout << "A" << result << endl;
}
else
// for return values less than zero (ie. -1)
{
cout << "XX" << endl;
}
// PAUSE is a Dos command, so that window will not disappear
system("PAUSE");
return 0;
}//end main
int size(float h, float w)
// This function will determine the "number" size of
// a piece of paper required to copy an item of a given
// height. h. and width, w.
// Pre: h >= 0; w >= 0
// Post: -1 <= return <= 10
{
// Write your code here
// The return value will correspond to the number size of the paper
if (h <= 26 && w <= 37)
{
return 10;
}
else if (h <= 37 && w <= 52)
{
return 9;
}
else if (h <= 52 && w <= 74)
{
return 8;
}
else if (h <= 74 && w <= 105)
{
return 7;
}
else if (h <= 105 && w <= 148)
{
return 6;
}
else if (h <= 148 && w <= 210)
{
return 5;
}
else if (h <= 210 && w <= 297)
{
return 4;
}
else if (h <= 297 && w <= 420)
{
return 3;
}
else if (h <= 420 && w <= 594)
{
return 2;
}
else if (h <= 594 && w <= 841)
{
return 1;
}
else if (h <= 841 && w <= 1189)
{
return 0;
}
else if (h > 841 || w > 1189)
{
return -1;
}
} // end size
Here's my code from last yr..juz so u guys know how commenting should be done.
****************************************************
* Author: -= Zhaostar=- 40333337
* Date Created: 18/03/03
* Purpose: COMP 115, Sem 1, 2003, Assignment 1
* A paper size determination program for
* the Copy Shoppe
****************************************************/
#include <iostream>
#include <cstdlib>
using namespace std;
// a function to determine paper size
int size(float, float);
int main()
{
// the input dimensions of the object
float dimension1, dimension2;
// variable x will be used later so values of dimension1
// and dimension2 can be swicthed
float x;
cin >> dimension1 >> dimension2; // do not change this line
// Write your code here
if (dimension1 > dimension2)
// switches values of dimension1 and dimension2
// avoids any confusion in defining which sides are height and width
{
x = dimension1;
dimension1 = dimension2;
dimension2 = x;
}
// variable result equals the return value from size(dimension1, dimension2)
int result = size(dimension1, dimension2);
if (result >= 0)
// for return values greater or equal to zero
{
cout << "A" << result << endl;
}
else
// for return values less than zero (ie. -1)
{
cout << "XX" << endl;
}
// PAUSE is a Dos command, so that window will not disappear
system("PAUSE");
return 0;
}//end main
int size(float h, float w)
// This function will determine the "number" size of
// a piece of paper required to copy an item of a given
// height. h. and width, w.
// Pre: h >= 0; w >= 0
// Post: -1 <= return <= 10
{
// Write your code here
// The return value will correspond to the number size of the paper
if (h <= 26 && w <= 37)
{
return 10;
}
else if (h <= 37 && w <= 52)
{
return 9;
}
else if (h <= 52 && w <= 74)
{
return 8;
}
else if (h <= 74 && w <= 105)
{
return 7;
}
else if (h <= 105 && w <= 148)
{
return 6;
}
else if (h <= 148 && w <= 210)
{
return 5;
}
else if (h <= 210 && w <= 297)
{
return 4;
}
else if (h <= 297 && w <= 420)
{
return 3;
}
else if (h <= 420 && w <= 594)
{
return 2;
}
else if (h <= 594 && w <= 841)
{
return 1;
}
else if (h <= 841 && w <= 1189)
{
return 0;
}
else if (h > 841 || w > 1189)
{
return -1;
}
} // end size