Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 05-19-2005, 08:04 PM   #1 (permalink)
iccaros
Registered User
 
Join Date: Apr 2005
Posts: 24
iccaros is on a distinguished road
questions on arrays

here is my first question on this board..

I have been learning c++ for 6 weeks now so I'll take all the advice I can get. so most of this code is experimenting with diffrent things.. like the license output is jsut so I caould play with diffrent ways of doing it. not that this crappy code needs copywrite protection .

I have a program that uses an array to collect Poll data. and I have two output methods
one looking like this

Code:
200 - 299              1
300 - 399              0
400 - 499              6
500 - 599              1
600 - 699              2
700 - 799              0

and one that looks like this..

Code:
200 - 299              *
300 - 399              
400 - 499              ******
500 - 599              *
600 - 699              **
700 - 799

my problem is I need to clear the array between displays or it just re-adds the data.

not I am populating a file with the initial data, and the file is read and calculations are done to the file.


here is the whole program to help.
warrnig its long, and I have not cleared out unused variables yet.

Code:
//csi 245 C++ 
//William S. Huskey
//A way overboard version of assinment 

//header files
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>

//declare name space
using namespace std;

//Function Prototype

//  needs to pass to compiler options , for Gcc its -DUNIX or -DWIN32 VC++ ?? no clue
void clear_screen();


//information functions
int PrompUser (const string&);


//output functions
void PrintLicense ();
void SalesInfo ();
void StarBar();
void GraphOut(const int[], const int[], const int);
void PrintToScreen( int[], const int[], const int);
void WelcomeScreen();
void SalesDump();


//global variables
const char* file_name = "salesinfo.txt"; //file where sales persons information will be stored
const char* LicenseFile = "license.txt"; //GNU GPL target


//main funtion
int main ()
{
    //local variables
    int UserInput = 0, holder = 0, MenuInput = 0;
    const int array_size = 9, poll_size = 10;
    bool Loop = true;
    //arrays
    int salaryRange [array_size] = {200,300,400,500,600,700,800,900,1000};
    int Polldata [poll_size] = {0};
    
    //create file salesinfo.txt
    ofstream newfile (::file_name);
    if (newfile.is_open())
     {
                             newfile <<  " ";
                             newfile.close();
     }                       
     
     
     //menu
     while (Loop == true) 
     {
     clear_screen();
     //header for menu
     WelcomeScreen();
     
     //menu chooices
     clear_screen();
StarBar();
cout <<  setw(74) << "*   Copyright (C) 2005 by William S. Huskey                               *" << endl;
cout <<  setw(74) << "*   www@iccaros-linux.org under the GPL                                   *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   Employee Sales Tracking Program                                       *" << endl;
cout <<  setw(74) << "*   Please Choose From an Option Below                                    *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   (1) Enter Sales's Persons information                                 *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   (2) Show chart of Salary Ranges                                       *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   (3) Show Graph of Salary range (note run this after option 2)         *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   (4) List Sales People and Salary                                      *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   (5) Print License                                                     *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   (6) Exit Program                                                      *" << endl;
StarBar();
     
     
          cout <<": ";
     MenuInput = PrompUser ("<Choice> ");
     cin.ignore();
          //switch and case MenuInput
     switch (MenuInput) 
     {
            case 1:
                 SalesInfo();
                 break;
            case 2:
                 PrintToScreen(Polldata, salaryRange, array_size);
                 break;
            case 3:
                 GraphOut(Polldata, salaryRange, array_size);
                 break;
            case 4:
                 SalesDump();
                 break;
            case 5:
                 PrintLicense();
                 break;
            case 6:
                 Loop = false;
                 cout << setw(48) << "Good-Bye !!" << endl;
                 break;
            default:
                    cout << setw(48) << "You did not enter a valid responce (1-6)";
                    break;
                    }
                    
                    }
return 0;
}

//Functions

//Clear screen function
void clear_screen()
{
              #if defined WIN32
              system("cls");
              #elif defined UNIX
              system("clear");
              #endif
}

//SalesInfo will ask for Sales person information and store it in the salesinfo.txt file for retrivel latter. this file could be made beforehand
void SalesInfo()
{
     int Sales = 0;
     double commision = 0;
     char record_name[32];
     ofstream salesfile (::file_name, ios::app);
     
     if (salesfile.is_open())
     {
                             cout << "Enter Sales Persons Lastname first Initial \nexample William Huskey would be: Huskeyw \n:";
                             cin >> record_name;
                             Sales = PrompUser ( "Enter the amount of sales for this week: ");
                             
			     commision = Sales * .09;
                             salesfile << record_name << " " << Sales <<" " << commision <<" \n";
                             salesfile.close();
     }                       
}


//PrintToScreen will print a Poll information showing how many sales people salaries per range there were
void PrintToScreen( int Poll[] , const int Range[], const int array_size )
{
     int holder = 0, salary = 200, sales = 0, a = 0, b = 0 , c = 0, j = 9, WeekSalary = 0;
     double commision;
     char record_name[32];
     
          
     ifstream salesfile;
     
     salesfile.open(::file_name);
     if (! salesfile)
     {
           cout << "error opening file: " << ::file_name << endl;
           cout << "please use option (1) to create file" << endl;
           }
      
      while ( ! salesfile.eof())
      {
            salesfile >> record_name >> sales >>  commision >> ws;
            
            WeekSalary = salary + static_cast <int> (commision);
            
            if (WeekSalary >= 1000)
            holder = 9;
            
            else 
            holder =  ((WeekSalary / 100) -1);
            
            ++Poll[holder];
            
               }
               salesfile.close();
               //output 
               //clear_screen();
               StarBar();
	       for (int x = 1; x <= array_size -1; x++)
               {
               b = Range[x -1] + 99;
	       
               cout << setw(10) << Range[x-1] << " - " <<  b  << setw(10) << " " << setw(10) << Poll[x] <<endl;
               }
	        
	       cout << setw(10) << Range[j-1] << " - " << "above" << setw(8) << " " << setw(10) << Poll[j] << endl;  
	       
	       StarBar();
	       cout << "Press Enter to exit to menu";
               getchar (); // wait for input
  
               }


//GraphOut is the same as PrintToScreen, but insted of numbers it places stars next to each range      
void GraphOut(const int Poll[], const int Range [], const int array_size)
{
    int b, c;
    StarBar();
      for ( int x = 1 ; x <= array_size; x++)
      {
        b = Range[x-1] + 99;
        cout << setw(20) << Range[x-1] << " - " << b << setw(10) << " ";
	
	if ( Poll[x] >= 1) {
	c = Poll[x];
	for ( int y = 1 ; y <= c; y++)
	cout << "*";
	}
	
	cout << endl;
	}
	StarBar();

	       cout << "Press Enter to exit to menu";
               getchar (); // wait for input
         }


//SalesDump will list all sales people and the salary they have earned
void SalesDump()
{
     int holder = 0, salary = 200, sales = 0, a = 0, b = 0 , c = 0, WeekSalary = 0;
     double commision;
     char record_name[32];
     
          
     ifstream salesfile;
     
     salesfile.open(::file_name);
     if (! salesfile)
     {
           cout << "error opening file: " << ::file_name << endl;
           cout << "please use option (1) to create file" << endl;
           }
      StarBar();      
      while ( ! salesfile.eof())
      {
            salesfile >> record_name >> sales >>  commision >> ws;
            
	   std::cout << setw(10) << record_name << setw(10) << sales << setw(10) << commision << endl;
                     
              }
              
	       salesfile.close();
               //output 
               //clear_screen();
              
	       StarBar();
	       cout << "Press Enter to exit to menu";
               getchar (); // wait for input
  
               }
	             

//PrintLicense will output the GNU GPL license covering this program
void PrintLicense()
{
clear_screen();
StarBar();
cout <<  setw(74) << "*   Copyright (C) 2005 by William S. Huskey                               *" << endl;
cout <<  setw(74) << "*   www@iccaros-linux.org                                                   *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   This program is free software; you can redistribute it and/or modify  *" << endl;
cout <<  setw(74) << "*   it under the terms of the GNU General Public License as published by  *" << endl;
cout <<  setw(74) << "*   the Free Software Foundation; either version 2 of the License, or     *" << endl;
cout <<  setw(74) << "*   (at your option) any later version.                                   *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   This program is distributed in the hope that it will be useful,       *" << endl;
cout <<  setw(74) << "*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *" << endl;
cout <<  setw(74) << "*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *" << endl;
cout <<  setw(74) << "*   GNU General Public License for more details.                          *" << endl;
cout <<  setw(74) << "*                                                                         *" << endl;
cout <<  setw(74) << "*   You should have received a copy of the GNU General Public License     *" << endl;
cout <<  setw(74) << "*   along with this program; if not, write to the                         *" << endl;
cout <<  setw(74) << "*   Free Software Foundation, Inc.,                                       *" << endl;
cout <<  setw(74) << "*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *" << endl;
StarBar();

//anykey exit
cout << "Press any key to exit to menu" << endl;
getchar (); // wait for input

              }
              
//StarBar is a quick bar output function 
void StarBar()
{
      for (int x = 0; x <= 74; x++)
      cout << "*";
      cout << endl;
         }
//output welcome text
void WelcomeScreen()
{
StarBar();
cout.width(50);
cout  << " CIS 245 C++ Assinment 5" << endl;
cout.width(50);
cout << " William Huskey may 2005" << endl;
 
 }

//PrompUser is a Error checking for number inputs.. This is to stop someone from entering the wrong type of numbers
int PrompUser (const string& question)
{
 while (true) {
          int user_input;
          cout << question << flush;
          cin >> user_input;
          if (cin.fail()) {
                          cerr << "invalid input \n";
                          cin.clear();
                          cin.ignore();
                          }
          else
            return user_input;

   
}

}
iccaros is offline   Reply With Quote
Old 05-19-2005, 08:07 PM   #2 (permalink)
iccaros
Registered User
 
Join Date: Apr 2005
Posts: 24
iccaros is on a distinguished road
a note on above.. this assinment has already been turned in.. it only required a small part of the Poll data being populated.. this is me expanding on the assinment.
iccaros is offline   Reply With Quote
Old 05-19-2005, 08:46 PM   #3 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Can you explain what it all does? It says something about poll data, yet it collects sales data and calculates provision. So what am I looking at?
__________________
Valmont is offline   Reply With Quote
Old 05-20-2005, 04:38 AM   #4 (permalink)
iccaros
Registered User
 
Join Date: Apr 2005
Posts: 24
iccaros is on a distinguished road
yes.. then it shows how many sales people fell into a spacific range.. (to me that is a Poll.. you have 40 sales people.. 1 makes between 200 -299 a week pay, 3 make between 300 - 399 a week in pay..ect)

so hope I write this so its understandable..

first you input sales people by name , the amount of sales they do for the week.. sales people get 9% commision on sales.. and that is stored in the file, each person has their own line in the file.

next it takes the commision line and adds that to 200 (the base salasry) and then devides that by 100 if its under 1000 to get an arrary position to increment (see ++Poll[x]). if its >= 1000 we set the array position to 9 as that is to == employees making between $1000 - above.

then it desplayes them as weekly salary range and amount of emplyees who make this range.


thanks for any help
iccaros is offline   Reply With Quote
Old 05-20-2005, 12:11 PM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
There are a lot of (logic) errors in your code. That means basically that the correctness of your algorithms fails. Allow me to rewrite the whole thing.
__________________
Valmont is offline   Reply With Quote
Old 05-20-2005, 01:00 PM   #6 (permalink)
iccaros
Registered User
 
Join Date: Apr 2005
Posts: 24
iccaros is on a distinguished road
ok..... The math run and produces the correct output.. but I am new to this laguage so any help is appresated..

if your talking about stuff like cout << Poll[x-1] + 99;
then I understand its the wrong way.. as I am still writing this.. and for some rason I can only write if I an typing in code. .no fake code or flowcharts .. they drive me nuts.

but having said that I have lots to learn so anothers take on it can only help.. thanks.
iccaros is offline   Reply With Quote
Old 05-20-2005, 01:56 PM   #7 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
When it's done, you'll see. I am busy right now.
__________________
Valmont is offline   Reply With Quote
Old 05-20-2005, 10:03 PM   #8 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
You'll need to add option 5 and 6 yourself. We are throwing around variables, but that is the price of procedural programming. Once you learn the ways of classes, things become so much cleaner. Ask if you have questions:
Code:
//csi 245 C++
//William S. Huskey & Alex Bosman
//A way overboard version of assignment

//header files
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <sstream>
#include <ios>

using std::cout;
using std::cin;
using std::endl;
using std::setw;

//Function Prototypes.

//Needs to pass to compiler options , for Gcc its -DUNIX or -DWIN32. VCC?
void clear_screen();

//User interaction functions.
unsigned prompt_user();

//output functions
void welcome_screen();
void menu_screen();
void add_sales_info();
void request_sales_info(std::string& ID, unsigned& sales);
void update_file(const std::string& ID, const unsigned& sales);
void star_bar();
void stats_graphical_out(int[], const int);
void print_stats(int[], const int, const std::string& StatType);
void reset_polldata(int* polldata, unsigned sz);
void process_data(std::ifstream& ifs, int* polldata, std::string& ID,
  unsigned& Sales, double& Commision);
  
//Globals: we don't like them but this is the price for procedural coding.

//File where sales persons information will be stored.
const std::string FileName = "salesinfo.txt";
//GNU GPL target.
const std::string LicenseFile = "license.txt";
//Bonus provision.
static const double PROVISION = 0.09;
//Salaray groups.
static const int ArraySize = 9;
static const double SalaryRange[ArraySize] = {
  200, 300, 400, 500, 600, 700, 800, 900, 1000 };

int main ()
{
  int Polldata[ArraySize] = {0};
  welcome_screen();
  
  //The menu.
  bool running = true;
  do
  {
    menu_screen();
    unsigned userChoice = prompt_user();
    switch (userChoice)
    {
    case 1: add_sales_info(); break;
    case 2: print_stats(Polldata, ArraySize, "numeric"); break;
    case 3: print_stats(Polldata, ArraySize, "graphic"); break;
    case 4: /* TODO: sales_dump */ break;
    case 5: /* TODO: license */ break;
    case 6: std::cout << "Exiting menu..." << std::endl; running = false;
    }
  } while(running);
  return 0;
}

//---------------------------------------------------

void welcome_screen()
{
  star_bar();
  cout <<  setw(74) << "*   Copyright (C) 2005 by William S. Huskey            "
  "                  *" << endl;
  cout <<  setw(74) << "*   www@iccaros-linux.org under the GPL                "
  "                  *" << endl;
  cout <<  setw(74) << "*                                                      "
  "                  *" << endl;
  cout <<  setw(74) << "*   Employee Sales Tracking Program                    "
  "                  *" << endl;
  cout <<  setw(74) << "*   Please Choose From an Option Below                 "
  "                  *" << endl;
  cout <<  setw(74) << "*                                                      "
  "                  *" << endl;
  cout <<  setw(74) << "*                                                      "
  "                  *" << endl;
  cout <<  setw(74) << "*                                                      "
  "                  *" << endl;
  star_bar();
  std::cout<<endl;
}

//-----------------------------------------------

void menu_screen()
{
    star_bar();
    cout <<  setw(74) << "*   (1) Enter Sales representative information       "
    "                    *" << endl;
    cout <<  setw(74) << "*                                                    "
    "                    *" << endl;
    cout <<  setw(74) << "*   (2) Show chart of Salary Ranges                  "
    "                    *" << endl;
    cout <<  setw(74) << "*                                                    "
    "                    *" << endl;
    cout <<  setw(74) << "*   (3) Show Graph of Salary range                   "
    "                    *" << endl;
    cout <<  setw(74) << "*                                                    "
    "                    *" << endl;
    cout <<  setw(74) << "*   (4) List Sales People and Salary                 "
    "                    *" << endl;
    cout <<  setw(74) << "*                                                    "
    "                    *" << endl;
    cout <<  setw(74) << "*   (5) Print License                                "
    "                    *" << endl;
    cout <<  setw(74) << "*                                                    "
    "                    *" << endl;
    cout <<  setw(74) << "*   (6) Exit Program                                 "
    "                    *" << endl;
    star_bar();
}

//---------------------------------------------------

//Clear screen function
void clear_screen()
{
#if defined WIN32
  system("cls");
#elif defined UNIX
  system("clear");
#endif
}

//---------------------------------------------------

//StarBar is a quick bar output function
void star_bar()
{
  for (int x = 0; x <= 74; ++x)
  {
    cout << "*";
  }
  cout << endl;
}

//---------------------------------------------------

//This function has four roles:
//1) Prompt the user for input.
//2) Validate the user entered a positive number only.
//3) If it is a pos number: validate its range.
//4) If not positive number or range is not good, then ask again for new input.
//You could modify this function to pass ranges. That's perhaps better.
unsigned prompt_user()
{
  std::cout<<"<Choice>: ";
  std::string input;
  std::getline(std::cin, input);
  std::istringstream Iss( input );
  unsigned Value;
  //We want a strict unsigned integer or the (i)string stream will fail.
  while( !( ( Iss >> Value >> std::ws ) && Iss.eof() ) )
  {
    std::cout<<"ERROR: no unsigned integer found."<<std::endl;
    //No good stream: reset the stream state.
    Iss.clear();
    //Let the user try inputting again.
    std::cout<<"<Choice>: ";
    std::getline(std::cin, input);
    Iss.str(input);
  }
  //So we have a positive number. But is it in range?
  if(Value < 1 || Value > 6)
  {
    //Not in range.
    std::cout<<"ERROR: selection out of range."<<std::endl;
    //Recursion.
    prompt_user();
  }
  //We hava a positive value, and it is also in range.
  return Value;
}

//----------------------------------------------------
//Let this function merely call helper functions to do specific tasks.
void add_sales_info()
{
  std::string ID;
  unsigned sales;
  request_sales_info(ID, sales);
  update_file(ID, sales);
}

//----------------------------------------------------

void request_sales_info(std::string& ID, unsigned& sales)
{
  std::cout<<"Add sales representative ID."<<std::endl;
  std::cout<<"Example: John Doe = Doej"<<std::endl;
  std::cout<<"<ID>: ";
  std::cin>>ID;

  std::cout<<std::endl;
  std::cout<<"Enter number of sales for this representative."<<std::endl;
  std::cout<<"<Sales>: ";
  //Should add unsigned integer validation here. See function prompt_user().
  std::cin>>sales;
  std::cin.get();
}

//----------------------------------------------------

void update_file(const std::string& ID, const unsigned& sales)
{
  std::ofstream ofs(::FileName.c_str(), std::ios_base::app);
  if(!ofs)
  {
    std::cerr<<"ERROR: could not open/create file."<<std::endl;
    std::cerr<<"Exiting Application..."<<std::endl;
    //Non-zero exit status is a fail state.
    exit(1);
  }
  
  ofs<<ID<<" "<<sales<<" "<<sales*PROVISION<<std::endl;
  ofs.close();
}

//----------------------------------------------------

void print_stats(int* polldata, const int size, const std::string& StatType)
{
  reset_polldata(polldata, size);
  std::ifstream ifs(::FileName.c_str());
  std::string ID;
  unsigned Sales;
  double Commision;
  //Reads the file and processes the data.
  process_data(ifs, polldata, ID, Sales, Commision);
  ifs.close();
  clear_screen();
  std::cout<<"stats ("<<StatType<<")"<<std::endl;
  double sr;
  
  //You could (and maybe should) easely split this up in seperate functions.
  //----numerical----
  if(StatType=="numeric")
  {
    for (unsigned i = 0; i < size -1; ++i)
    {
      sr = SalaryRange[i];
      std::cout << std::setw(10) << sr << " - " <<  sr + 99 <<
        " " << setw(5) << polldata[i] <<endl;
    }
    std::cout << std::setw(10) << SalaryRange[8] << " -  > " <<
      " " << setw(5) << polldata[8] <<endl;
  }
  
  //----Graphic----
  if(StatType=="graphic")
  {
    unsigned pdSize;
    for (unsigned i = 0; i < size -1; ++i)
    {
      sr = SalaryRange[i];
      std::cout<<sr<<" - "<<sr+99<<"\t";
      //Draw the stars.
      pdSize = polldata[i];
      for (unsigned j = 0; j < pdSize; ++j)
      {
        std::cout<<"*";
      }
      std::cout<<std::endl;
    }
    std::cout<<SalaryRange[8]<<" -  > "<<"\t";
    for (unsigned j = 0; j < polldata[8]; ++j)
    {
      std::cout<<"*";
    }
  }
  
  //Clean up.
  std::cout<<endl;
  std::cout<<"Please press <enter> to continue...";
  std::string buf;
  std::getline(std::cin, buf);
  clear_screen();
}

//----------------------------------------------------

void reset_polldata(int* polldata, unsigned sz)
{
  for(unsigned i = 0; i < sz; ++i)
  {
    polldata[i]=0;
  }
}

//----------------------------------------------------

void process_data(std::ifstream& ifs, int* polldata, std::string& ID,
  unsigned& Sales, double& Commision)
{
  if(!ifs)
  {
    std::cerr<<"ERROR: could not open file."<<std::endl;
    std::cerr<<"Exiting Application..."<<std::endl;
    //You have to test if this is the proper action to do.
    return;
  }
  double WeekSalary(0.0);
  unsigned PollIndex;
  while(ifs>>ID>>Sales>>Commision)
  {
    //SalaryRange[0] implies starting salary (without commision).
    WeekSalary = SalaryRange[0] + Commision;
    PollIndex = static_cast<unsigned>((WeekSalary/100)-2);
    if(PollIndex < 9)
    {
      ++polldata[PollIndex];
    }
    else
    {
      ++polldata[9];
    }
  }
  //Did read of stream stop for unknow reason?
  if(!ifs.eof())
  {
    //Stream could not be read. Perhaps corrupt stream/locked/network problems.
    std::cerr<<"ERROR: could not read stream (but file was opened)."<<std::endl;
    ifs.close();
    //You have to test if this is the proper action to do.
    return;
  }
}
__________________
Valmont is offline   Reply With Quote
Old 05-21-2005, 01:15 PM   #9 (permalink)
iccaros
Registered User
 
Join Date: Apr 2005
Posts: 24
iccaros is on a distinguished road
Thanks that is much cleaner.. IT will take me a day or so to go through all of it..
The biggist thing I see out front is better consolidation, and better declerations.
It is ovious the diffrence between my 5 week experiance and your years..

I'm glad I found this board.
iccaros is offline   Reply With Quote
Old 05-21-2005, 02:40 PM   #10 (permalink)
teknomage1
Jack of all trades
 
teknomage1's Avatar
 
Join Date: Feb 2005
Location: Los Angeles
Posts: 598
teknomage1 is on a distinguished road
Send a message via AIM to teknomage1
Nice Valmont, that was very helpful to me as well.
__________________
Stop intellectual property from infringing on me
teknomage1 is offline   Reply With Quote
Old 05-21-2005, 05:47 PM   #11 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
The WeekSalary calculation is wrong though. I took it from the original without thought...
__________________
Valmont is offline   Reply With Quote
Old 05-21-2005, 06:05 PM   #12 (permalink)
cheawick
Regular Contributor
 
cheawick's Avatar
 
Join Date: Dec 2003
Location: Mary Esther, FL
Posts: 189
cheawick is on a distinguished road
Wow Valmont! You are busy. You had given some input on my "How to make a test maker" thread, I'm still trying to figure things out.

Gah! I can't type what I'm trying to say.

I'm wondering if arrays and classes will help with my request. I tried to copy just the code you posted here so I could print it to figure out how it works, but all I printed was the thread. Any advice?
cheawick is offline   Reply With Quote
Old 05-21-2005, 11:42 PM   #13 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
Quote:
I'm wondering if arrays and classes will help with my request.
Most likely. Just study.
Quote:
I tried to copy just the code you posted here so I could print it to figure out how it works, but all I printed was the thread. Any advice?
What?
Just select with the mouse all of the code in the code window. Then copy and paste it in your document, or IDE.
__________________
Valmont is offline   Reply With Quote
Old 05-22-2005, 07:20 AM   #14 (permalink)
iccaros
Registered User
 
Join Date: Apr 2005
Posts: 24
iccaros is on a distinguished road
Quote:
Originally Posted by Valmont
The WeekSalary calculation is wrong though. I took it from the original without thought...
I havent compiled yours.. but I saw where you mutiplied sales x .09 = commision and then added that to the $200 base salary (commision + salary).. that should be correct.
no??
iccaros is offline   Reply With Quote
Old 05-22-2005, 09:17 AM   #15 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,544
Valmont is on a distinguished road
No.
Weeksalary = StartingSalary+(Sales*StartingSalary*percentage)

Otherwise you're trying to add a percentage unit with a monetary unit:
9%+$200=? //One sale: 1 * 9% = 9%
__________________
Valmont is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes