C/C++2006-12-10 (4*.cpp)

0 views
Skip to first unread message

zrq83...@gmail.com

unread,
Dec 9, 2006, 11:51:47 AM12/9/06
to 绿色精灵
//this program is help to print the customer's massage!
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
class Bman
{
private:
char name[25];
char sex[4];
char city[25];
char phoneNo[13];
public:
void print()
{
cout << endl <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << endl <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << endl << "名: " << name << " 姓:" <<
sex <<endl;
cout << endl << "城市: " << city << "
电话:" << phoneNo <<endl;
}
void get()
{
cout << "名: ";
cin >> name;
cout << endl << "姓: ";
cin >> sex;
cout << endl << "城市: ";
cin >> city;
cout << endl << "电话: ";
cin >> phoneNo;
}
};
int main(int nNumberofArgs,char* pszArgs[])
{
Bman object;
object.get();
object.print();
system ("PAUSE"); //use to pause the windows' print out screen
return 0;
}

//This program is test the students' score's levele.
//it will divide into three band (A,B,C):printout.
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
class Score
{
int scoreno;
public:
void Myscor()
{
cout << endl << "Enter your score:" << endl;
cin >> scoreno;
if(75 <= scoreno && scoreno <= 100)//please becareful
about this
cout << endl << "you are A" << endl;//step,u should
use 7<=x && x <=10;
if(50 <= scoreno && scoreno <= 74) //just like that!

cout << endl << "you are B" << endl;
if(0 <= scoreno && scoreno <= 49)
cout << endl << "you are C" << endl;
}
};
int main(int nNumberofArgs,char* pszArgs[])
{
Score s1;
s1.Myscor();
system("PAUSE");
return 0;
}


//this program is help to print the customer's massage!
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;
class Customer
{
private:
char mobileNo[12];
char name[25];
char dateOfBirth[10];
char billingAdd[50];
char city[25];
char phoneNo[13];
float amountOutstanding;
public:
void print()
{
cout << endl <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << endl <<
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
cout << endl << "Phone Number is: ";
cout << mobileNo << endl;
cout << endl << "Name: ";
cout << name << endl;
cout << endl << "Date of Birth: ";
cout << dateOfBirth << endl;
cout << endl << "BillingAdd: ";
cout << billingAdd << endl;
cout << endl << "city: ";
cout << city<< endl;
cout << endl << "Phone: ";
cout << phoneNo << endl;
cout << endl << "amountOutstanding: ";
cout << amountOutstanding << endl;
}
void get()
{
cout << "Phone number is: ";
cin >> mobileNo;
cout << endl << "Name: ";
cin >> name;
cout << endl << "Date of Birth: ";
cin >> dateOfBirth;
cout << endl << "BillingAdd: ";
cin >> billingAdd;
cout << endl << "City: ";
cin >> city;
cout << endl << "Phone: ";
cin >> phoneNo;
cout << endl << "amountOutstanding: ";
cin >> amountOutstanding;
}
};
int main(int nNumberofArgs,char* pszArgs[])
{
Customer object;
object.get();
object.print();
system ("PAUSE"); //use to pause the windows' print out screen
return 0;
}


//This program is to count the celsius!
#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;//foolish teaching book's example.

int main(int nNumberofArgs,char* pszArgs[])
{
int celsius;
cout << "enter:";
cin >> celsius;
int factor;
factor = 212 - 32;
int fahrenheit;
fahrenheit = factor * celsius/100 + 32;
cout << "Fahrenheit is:";
cout << fahrenheit << endl;
system("PAUSE");
return 0;
}

Reply all
Reply to author
Forward
0 new messages