GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 11-Jul-2005, 10:35
SickFish SickFish is offline
New Member
 
Join Date: Jul 2005
Posts: 2
SickFish is on a distinguished road

parody: elp needed


can someone elp me pleease.
i hav this hollowing code and dunno what it does or what it shout do.
CPP / C++ / C Code:
#include <iostream>

double sactuateCalarys343jsd( double a4nwtgoet4bwhgg ) { double sgawantnups8ngs = 200; sgawantnups8ngs += 0.09*a4nwtgoet4bwhgg; return sgawantnups8ngs; }

int main(int argc, char* args[] ) { double egaaI8nn84tg4np; int ca4ngjse548eb5f[10]; int bTsggAeefsesggg; while( true ) { cout << "Memasukkan total nilai penjualan para karyawan (Memasukkan -1 untuk berhenti) :"; cin >> egaaI8nn84tg4np; if( egaaI8nn84tg4np == -1 ) break; cout << "Kemudian Gaji total untuk karyawan tersebut adalah: $" << sactuateCalarys343jsd( egaaI8nn84tg4np ) << endl; if( egaaI8nn84tg4np<200 ) egaaI8nn84tg4np = 200; if( egaaI8nn84tg4np>999 ) egaaI8nn84tg4np = 999; bTsggAeefsesggg = (int)(egaaI8nn84tg4np/100); ++ca4ngjse548eb5f[bTsggAeefsesggg]; } for(int i=2; i<10; ++i ) { cout << "Jumlah karyawan yang mendapat gaji " << 100*i <<" - " << 100*(i+1)-1 << " adalah "; cout << ca4ngjse548eb5f[i] << "orang.\n"; } return 0; }

pleease elp
  #2  
Old 11-Jul-2005, 11:48
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,791
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by SickFish
can someone elp me pleease.
i hav this hollowing code and dunno what it does or what it shout do.
[

Two questions here:

1. What does it do?

Answer: It does what it does.


2. What should it do?

Answer: Well, what "should" any of us do? Programs don't really know what they "should" do; they only do what the Programmer tells them to do. (So, I claim, we can't just look at a program and tell what it "should" do.)

One problem with compiling this program (if it is a program) with standard C++ compilers: namespace std is not specified, so cin, cout, and endl would not be recognized. (Unless the Programmer intended some other namespace, in which he could have defined cin, cout, and endl to do pretty much anything, he wanted, including formatting the hard disk of the machine running the program. In any case, the namespace should have been specified.)

By the way, regardless of what the program "should" do, there is a bug: the automatic array variable ca4ngjse548eb5f[] is not initialized, but values indexed by 2-9 are printed out. (The program also doesn't handle non-numeric inputs very well, since it goes into an infinite loop, but maybe that's not a bug --- maybe it's a "security feature".)



If I wanted to guess what it "should" do:

This Programmer might have wanted it to do something like this:

Get numeric input values from a user console (maybe this is the amount of a sale or something). Continue getting values until the user enters -1.

For each user input value, calculate a transaction fee (maybe a commission): 200 dollars plus 9% of the transaction amount.

Limit the fee to values greater than or equal to 200 and less than 1000.

Keep track of the number of fees between 200 and 299, 300 and 399, etc., in an array and print them out.

Regards,

Dave
  #3  
Old 11-Jul-2005, 13:08
SickFish SickFish is offline
New Member
 
Join Date: Jul 2005
Posts: 2
SickFish is on a distinguished road
thx Dave soo much. Now this little butiful butiful 2 line program...
CPP / C++ / C Code:
#include <iostream>
using namespace std;double sactuateCalarys343jsd(double a4nwtgoet4bwhgg){double sgawantnups8ngs=200;sgawantnups8ngs+=0.09*a4nwtgoet4bwhgg;return sgawantnups8ngs;}int main(int argc,char* argv[]){double egaaI8nn84tg4np;int ca4ngjse548eb5f[10]={0,0,0,0,0,0,0,0,0,0};int bTsggAeefsesggg;while(true){cout<<"Memasukkan total nilai penjualan para karyawan (Memasukkan -1 untuk berhenti) :";cin>>egaaI8nn84tg4np;if(egaaI8nn84tg4np==-1)break;cout<<"Kemudian Gaji total untuk karyawan tersebut adalah: $"<<sactuateCalarys343jsd(egaaI8nn84tg4np)<<endl;if(egaaI8nn84tg4np<200)egaaI8nn84tg4np=200;if(egaaI8nn84tg4np>999)egaaI8nn84tg4np=999;bTsggAeefsesggg=(int)(egaaI8nn84tg4np/100);++ca4ngjse548eb5f[bTsggAeefsesggg];}for(int i=2;i<10;++i){cout<<"Jumlah karyawan yang mendapat gaji "<<100*i<<" - "<<100*(i+1)-1<<" adalah ";cout<<ca4ngjse548eb5f[i]<<"orang.\n";}return 0;}
at least compiles. wau. anyon guess what it does..
programming is worderful. love you all.
  #4  
Old 11-Jul-2005, 15:49
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 4,791
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold
Quote:
Originally Posted by SickFish
thx Dave soo much. Now this little butiful butiful 2 line program...
[c++]
anyon guess what it does..
programming is worderful. love you all.

Maybe someone can translate the remaining text from Bahasa or whatever.
Since that's what the user sees, it could give a clue as to what the program is "supposed" to do.

Whitespace + consistent indentation can improve readability of program structure, but non-programming language semantics still come into play.

What else do you need?

CPP / C++ / C Code:
#include <iostream>

using namespace std;

double func(double arg1)
{
  double retval = 200;
  retval += 0.09 * arg1;
  return retval;
}

int main(int argc, char* argv[])
{
  double inval;
  int bins[10] = {0,0,0,0,0,0,0,0,0,0};
  int binval;

  while(true) {

    cout << "Memasukkan total nilai penjualan para karyawan (Memasukkan -1 untuk berhenti) :";
    cin >> inval;

    if(inval == -1)
      break;

    cout << "Kemudian Gaji total untuk karyawan tersebut adalah: $"
         << func(inval)
         << endl;

    if(inval < 200)
      inval = 200;
    if(inval > 999)
      inval = 999;

    binval = (int)(inval / 100);
    ++bins[binval];
  }

  for (int i = 2; i < 10; ++i) {
    cout << "Jumlah karyawan yang mendapat gaji "
         << 100 * i
         << " - " 
         << 100*(i+1)-1
         << " adalah ";
    cout << bins[i] << "orang.\n";
  }

  return 0;
}


Regards,

Dave
 
 

Recent GIDBlogUS Elections and the ?Voter?s Responsibility? by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Seeking 3rd party online processing system for Ukraine workoholic eCommerce / Merchant Account Forum 11 06-Jul-2005 08:58
Small Help Needed p_kumar81 C++ Forum 35 09-Nov-2004 11:03
Free 1st month / Free setup / No credit card needed...Plans start at 4.95 LarryIsaac Web Hosting Advertisements & Offers 0 11-Oct-2003 15:03

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 06:34.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.