Popular Download

Jul 21, 2011

encrypt or decrypt number

encrypt or decrypt code by: John Gerald Catague
Program language dev C++
proposes to compute the water expenses
note Dis code is open source you can edit the code as lone you want but
do note remove the copyright comment in the code thank you
*for Educational purposes only
code below
note dont forget the brace in
#include iostream
#include iomanip
#include cmath
**********************************************************************************

#include iostream
#include iomanip
#include cmath
using namespace std;
char action;
//code by John GErald Catague
//visit http://cataguegerald.blogspot.com for more info
int main ()

{
int number;

cout << "Enter e to encrypt or d to decrypt?" << endl; cin >> action;

if( action == 'e')
{
cout << " Enter a 4 digit number to encrypt: " << endl; cin >> number;

int digit1 = ( number / 1000 + 7) % 10;
int digit2 = ( number % 1000 / 100 + 7) % 10;
int digit3 = ( number % 100 / 10 + 7 ) % 10;
int digit4 = ( number % 10 + 7) % 10;

int encryptedNumber =
digit1 * 10 + digit2 + digit3 * 1000 + digit4 * 100;

cout << " Encrypted Number is:" << encryptedNumber << endl; } else if ( action == 'd'); cout << "Enter a 4-digit number to decrypt: " << endl; cin >> number;


// decrypt ( digit numbers are counted from left)
int digit1 = ( number / 1000 + 3) % 10;
int digit2 = ( number % 1000 / 100 + 3) % 10;
int digit3 = ( number % 100 / 10 + 3 ) % 10;
int digit4 = ( number % 10 + 3) % 10;

int decryptedNumber =
digit1 * 10 + digit2 + digit3 * 1000 + digit4 * 100;

cout << " Decrypted Number is:" << decryptedNumber << endl;
system("pause");
}

water Billing

Water Billing code by: John Gerald Catague
Program language dev C++
proposes  to compute the water expenses
note Dis code is open source you can edit the code as lone you want but
do note remove the copyright comment in the code thank you
*for Educational purposes only
code below
note dont forget the brace in #include iostream
**********************************************************************************
#include iostream
using namespace std;
//code by John GErald Catague
//visit http://cataguegerald.blogspot.com for more info
float computeBill(char, float);


int main ()
{
int accountNo;
char useCode;
float gallons;
float amountDue;

cout << "Please enter your account number:";
cin >> accountNo;

cout << "\n*************************************************************\n";

cout << "\nEnter \nH for Home\nC for commercial\nI for industrial";

cout << "\n\nPlease enter your use code:";
cin >> useCode;
if ((useCode == 'H' || useCode == 'h'))
{
cout << "\n***************** User Type[Home] ***************************\n\n";

}

if ((useCode == 'C' || useCode == 'c'))
{
cout << "\n***************** User Type[Commercial] *********************\n\n";

}

if ((useCode == 'I' || useCode == 'i'))
{
cout << "\n***************** User Type[Industrial] *********************\n\n";

}
cout << "Please enter the number of gallons you used:";

cin >> gallons;
if ((useCode == 'H' || useCode == 'h'))
{
cout << "\n\n***************** REPORT for User[Home ]*******************\n";

}

if ((useCode == 'C' || useCode == 'c'))
{
cout << "\n\n***************** REPORT for User[Commercial]**************\n";

}

if ((useCode == 'I' || useCode == 'i'))
{
cout << "\n\n***************** REPORT for User[Industrial]]*************\n";

}
amountDue = computeBill(useCode, gallons);

cout << "Account Number: " << accountNo << endl;
cout << "Use Code: " << useCode << endl;
cout << "Gallons Used: " << gallons << endl;
cout << "The Bill is: " << amountDue << endl;

system ("pause");

return 0;
}

float computeBill(char useCode, float gallons)

{
if ((useCode == 'H' || useCode == 'h') && (gallons <= (float)1000000))

{
return 2250.00;
}
if ((useCode == 'H' || useCode == 'h') && (gallons > (float)1000000))

{
return ((gallons - 1000000) * 0.002) + 2250;
}


if ((useCode == 'C' || useCode == 'c') && (gallons <= (float)4000000))

{
return 5000.00;
}
if ((useCode == 'C' || useCode == 'c') && (gallons > (float)4000000))

{
return ((gallons - 4000000) * 0.002) + 5000;
}


if ((useCode == 'I' || useCode == 'i') && (gallons <= (float)4000000))

{
return 5000.00;
}
if ((useCode == 'I' || useCode == 'i') && (gallons > (float)4000000))

{
return 10000.00;
}



if ((useCode == 'I' || useCode == 'i') && (gallons <= (float)10000000))

{
return 10000.00;
}
if ((useCode == 'I' || useCode == 'i') && (gallons > (float)10000000))

{
return 15000.00;
}


}



+********************************************************************************