mmgoicochea 0 Light Poster

got it... :D I had to "initialize" row=2 :P thanks tho I couldnt figure out what was wrong... this book kinda sucks... it has only one dimentional arrays :/ so everything above (multidimentional) is up to our own research? lol.. collllleeggeee zzzz :(

mmgoicochea 0 Light Poster

it is adding all the values but it does it like this [0][0]+[0][1]....+[2][4]= 1000s ... it should add only values from [2][0]+[2][1]+[2][2][2][3]+[2][4]= which is 160 :/

gosh :(

mmgoicochea 0 Light Poster

So heres a portion of my program... the program has several functions (each doing diff. things)


Im having a problem I can not find the way to write the sum of the third row in costOfSports array.

the book says something like this:
for(col=0;col<5;col++)
{
for(row=0;row<3;row++) 
{
row_sum[row]=array[row][col];
}
}

//but it is not working... it does not generate bugs but it gives me an "address" instead of a number...
what can I do? any hint? trick? code? thanks to everyone

#include<iostream> 
using namespace std;
int main()
{    
const int NUM_SCHOOLS=5; 
   const int NUM_SPORTS=3;
    enum SportType {FOOTBALL,BASKET,VOLLEYBALL}; 
	int kidsInSports[NUM_SCHOOLS][NUM_SPORTS]={{5,7,10},  {2,5,1},				     {20,37,3},					    {40,2,5},					    {10,8,5}};				    {40,2,5},											    {10,8,5}}; 
	int costOfSports[NUM_SPORTS][NUM_SCHOOLS]={{25,30,45,50,55},					    {5,50,10,25,8},         					{13,70,25,47,5}};
 	int row,col;
	int col_sum[5]={0},row_sum[3]={0};	
	double sum; 
 cout<<endl; //THIS IS THE part im having problems with...	
cout<<"the sum is"<<' ';
	for(row=0;row<3;row++)
	{		
	for(col=0;col<5;col++)	
	{	 	
	row_sum[3]+=costOfSports[row][col];
		}   
system("PAUSE"); 
 return 0;
}
mmgoicochea 0 Light Poster

So heres a portion of my program... the program has several functions (each doing diff. things)


Im having a problem I can not find the way to write the sum of the third row in costOfSports array.

the book says something like this:
for(col=0;col<5;col++)
{
for(row=0;row<3;row++)
{
row_sum[row]=array[row][col];
}
}

//but it is not working... it does not generate bugs but it gives me an "address" instead of a number...
what can I do? any hint? trick? code? thanks to everyone :)

#include<iostream>

using namespace std;
int main()
{
    const int NUM_SCHOOLS=5;
    const int NUM_SPORTS=3;
    enum SportType {FOOTBALL,BASKET,VOLLEYBALL};

	int kidsInSports[NUM_SCHOOLS][NUM_SPORTS]={{5,7,10},
  {2,5,1},				     {20,37,3},
					    {40,2,5},
					    {10,8,5}};				    {40,2,5},
											    {10,8,5}};
                                              
	int costOfSports[NUM_SPORTS][NUM_SCHOOLS]={{25,30,45,50,55},
					    {5,50,10,25,8},
         					{13,70,25,47,5}};

	int row,col;
	int col_sum[5]={0},row_sum[3]={0};	
	double sum;
	

cout<<endl;

//THIS IS THE part im having problems with...
	cout<<"the sum is"<<' ';
	for(row=0;row<3;row++)
	{
			for(col=0;col<5;col++)
		{	
			
		row_sum[3]+=costOfSports[row][col];
		}

  system("PAUSE");
  return 0;
}
	}
mmgoicochea 0 Light Poster

Larry 8000 1.25 1000.00
Moe 5025 1.10 552.75
Shep 950 2.00 104.50
Curly 9980 1.15 1147.70

why dont you use
const int widgets=3
const int names=4

enum dudes { write those names hereee}
int array[names][widgets]={ write numbers... blah}
int row,int col;

input the values,then use a series of for loops to retrieve the numbers to then do the calculations... im new in c++ so do not take my recommendations if you think they are wrong :D.

mmgoicochea 0 Light Poster

second attempt to finish this assignment//// :/ ....... anddd didnt work.
there is a similar program called "from morse code to english" but the people that made it didnt write the final edit to his program so I cant use it....

............................................................................................
This program encodes a message that consists only of letters (char).."abcdefghijklmnopqrstuvwxyz" and the second table is qwertyuiopasdfghjklzxcvbnm . all the words in the message are separated by at least one space from each other.The message may include upper and lower case letters. the output can be entirely in uppercase or in lowecase the message is encoded by substituting each letter in the message.....
I have to use "string manipulation(characters)" sooo

Im using this "strcpy_s(letter,encoded);" as a way to try to convert values from array 1 to the second.. but it is not working... It is displaying all the values in "encoded" instead of showing only one character per letter... in other words there is no conversion at all ... it is not working :(.
I still have to do some other things to the program such as functions,reverse the order ,etc... I know I can do that but I got stucked in the first part ....
I hope someone can help meee thank you so MUch!!! :)

[#include<string>
#include<iostream>
#include<cctype>

using namespace std;

void inpput(char*letter,char*encoded,char *name);
int main()
{
	string answer;
	char letter[28]={"abcdefghijklmnopqrstuvwxyz\0"};
	 char encoded[28]={"qwertyuiopasdfghjklzxcvbnm\0"};	
	 char name[101];
	

	inpput(letter,encoded,name);


//exit.
while (true)
{

	cout<<"Do you want to exit the program?[exit/NO]:";
	cin>>answer; …
mmgoicochea 0 Light Poster

Hi everyone
I m openning this theat because I want to see if any of you can help me... well lets see ... I got my full time back at work (after 2 years :o ) and Im worry about college because I do not have enough time to complete my homework,study,work etc... I have to do this homework which is due this tuesday(Im planning to turn it in late "thursday" because we recieve -2 point penalty only :D... as i said I do not have enough time :(.. ) ok ok ok... so the program goes like this.
............................................................................................
This program encodes a message that consists only of letters.."abcdefghijklmnopqrstuvwxyz" and the second table is qwertyuiopasdfghjklzxcvbnm all the words in the message are separated by at least one space from each other.The message may include upper and lower case letters. the output can be entirely in uppercase or in lowecase the messages is encoded by substituting each letter in the message. I also have to store the values in an empty array(I do not know how to so I wont ...)

Im using this "strcpy_s(letter,encoded);" as a way to try to convert values from array 1 to the second.. but it is not working... It is displaying all the values in "encoded" instead of showing only one character per letter... in other words there is no conversion at all ... it is not working :(.
I still have to do some other things to the …

mmgoicochea 0 Light Poster

Hi jonsca I finally finished it ... thank you and thanks achieve_goals for the help. I couldnt go to college the day the prof. explained this topic because I was selling my old baby(aka car bmw 325 1987). the prof. usually uses handouts rather than the book because the book is way too basic and its used as reference rather than to resolve tasks and complicated stff. I had to research everything myself so thats the main reason It took me this long :D. thanks again-

what I did was to write a single while loop using && to use conditions for both files instead of passing information from while loop to the other while loop via variables and so on...
so the while loop reads from infile and writes back to outfile.

Mario G.

mmgoicochea 0 Light Poster

Hi thx for the help. Ive been trying to do this assignment for more than 3 days now... yeah I tried to do what you told me but now I do not even know if i did what you told me or not... the reason? well i changed a lot of things copied, deleted and even used some "brute force" that will be corrected once i get to know how to get all the characters from a variable(name, that converts lower cases to uppercases )to then print it in a new file?
It is printing only the first letter of my name to the new file. e.g
Old file:
Mario

new file:
M

I mean something should be correct to print something in the new file but something should be so WRONG to do not copy all the characters =?

heres my edit.....
//////////////////////////////////////////////////////////////////////////////////

#include<iostream>
#include<cctype>
#include<fstream>
#include <string> 
#include<iomanip>

using namespace std;

int openfile(char & ch,char name,ifstream & fin);
void process(char name,char ch,ofstream & fout);


int main()
{
	char ch;
	char name=1;
	ifstream fin;
	ofstream fout;
 
	openfile(ch,name,fin);
	process(name,ch,fout);

	system("pause");
	return 0;
}
int openfile(char & ch,char name,ifstream & fin)
{

	ifstream infile("infile.txt");
	//opens the file
	if(!infile.good()) throw "I/O error";
	while(!infile.eof()) 
	{
		infile.get(ch);
		fin>>ch;	
		name=toupper(ch);	
		cout<<name;
	}
	
fin.close();
	
return name;
}//reads from a previously created file that contains my name and lastname

void process(char name,char ch,	ofstream & fout)
{	ifstream fin;
	ifstream infile("infile.txt");
	fout.open("outfile.txt");
	if(!fout.good()) throw "I/O error";
			infile.get(ch);
		fin>>ch; …
mmgoicochea 0 Light Poster

It would be great if someone could give me a hint if not then i will be here tomorrow trying to do it XD :(

mmgoicochea 0 Light Poster

ok couldnt figure out how to print it in outfile.txt :@ its 5 am ive been trying since 11pm and I just need to go to sleeeep :/

#include<iostream>
#include<cctype>
#include<fstream>
#include <string> 

using namespace std;

void closefile();
void process(char name);
int openfile(char ch,char name);

int main()
{   char ch=0;
	char name=0;
	openfile(ch,name);
	process(name);
	closefile();

	system("pause");
	return 0;
}
int openfile(char ch,char name  )
{
	ifstream fin;
	ifstream infile("infile.txt");
	//opens the file
	if(!infile.good()) throw "I/O error";
	while(!infile.eof()) 
	{
		infile.get(ch);
		fin>>ch;
		name=toupper(ch);
		cout<<name;
	}
return name;
}//reads from a previously created file that contains my name and lastname

void process(char name)
{	
	ofstream fout;
	ofstream outfile("outfile.txt");
	if(!outfile.good()) throw "I/O error";
		while(!outfile.eof())
		{
		fout<<name<<endl;
		break;
		}
}//this part creates the output file and should write my lastname but this time it should be in UPPER cases

void closefile()
{
	ifstream infile;
	ofstream outfile;
	infile.close();
	outfile.close();
}
//closes all the files.
mmgoicochea 0 Light Poster

wow yeah I tought using a break but didnt work the first time. now it prints it in the command prompt . It does not copy it to the file... hmm i will try to use functions now. maybe if i return the variable that contains the upper cases ... :P let me see. oh and btw thats for the help ;)

mmgoicochea 0 Light Poster

I do lol.. but it says it does not have bugs which means I did something legal but doesnt mean it was correct whichh sucks :D lol :(

------ Build started: Project: assignment14, Configuration: Debug Win32 ------
Compiling...
assignment14.cpp
Linking...
Embedding manifest...
Build log was saved at "file://h:\CS110\assignment14\Debug\BuildLog.htm"
assignment11 - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

mmgoicochea 0 Light Poster

Thats exactly what is happening. the cout will be delete it once I figure out how to get it to work. so this is what is happening (I think you said it already )

Mario


//then here comes the TOUPPER(ch)
.....
it does not print it in the console and it does not copy it to the file.


EDIT.
I changed the position of the << and it prints AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA which means its getting only the last character from my lastname hmmm i think Iam almost done... gotta figure it out how to get all the CHARACTERS =/

mmgoicochea 0 Light Poster

I "changed it to uppercase but It still prints lower cases

mmgoicochea 0 Light Poster

I want to say something like... while characters are still in lower case...
{
convert to upper case;
print it to the outfile.txt;
}

mmgoicochea 0 Light Poster

you are right and its toupper. I changed it and it still doesnt work. I believe that the problem is in the second while loop(statement) but i do not know how to change it :(

mmgoicochea 0 Light Poster

So this is assignment number 14 and this is the fourth time Im bothering you...I hope you can help me.
I think Im almost done with it but I can not get "toupper" my name and lastname so it would be copied to the outfile.txt file.

Description: The program writes a while loop that copies all the characters from an input file stream(The file will have my name and lastname) to an output file stream.The only exeption will be that every lowecase is converted to uppercase.the loop should terminate when end-of-file is detected. the information should be writen to the new file.

#include<iostream>
#include<cctype>
#include<fstream>
#include <string>

using namespace std;
int main()
{

char ch=0;	
char name=touppercase(ch);
//reads from a previously created file that contains my name and lastname

ifstream fin;
ifstream infile("infile.txt"); //opens the file
if(!infile.good()) throw "I/O error"; 

while(!infile.eof()) //while loop as specified by the teacher.
{

infile.get(ch);
fin>>ch;
cout<<ch;

}
infile.close();

//process

//this part creates the output file and should write my lastname but this time it
//should be in UPPER cases. this is where I cant get it to work!!!! HELP!

ofstream outfile;
outfile.open("outfile.txt");
if(!outfile.good()) throw "I/O error";
while (!outfile.eof())
{
	name=tolower(ch);
cout<<name;
outfile>>name<<endl;
}
outfile.close();


//close file
//opens the file and reads the content to then close the file and program.

ifstream outf;
outf.open("outfile.txt");
if(!outf.good()) throw "I/O error";
while (!outf.eof())
{
outf<<name;
cout<<name;

}

system("pause");
return 0;
}
mmgoicochea 0 Light Poster

this is my "neanderthal" c++ version of the neat program you made hahha ... but oh well it runs.. :D

#include<cmath>
#include<iostream>
using namespace std;

void sumsq(int & number,int & sum,int & i,int & square);
void errorcheck(int number,int sum,int i,int & square);
int inpput(int & number);
//functions

int main()
{
  int number;
  int sum;
  int i;
  int square;

//variables

  inpput(number);

  sumsq(number, sum,i,square);
errorcheck( number,sum, i, square);
//function calls
  system("pause");
  return 0;
} 
void sumsq(int & number,int & sum,int & i,int & square)
{

    for (i =1; i < number; i++)  
    {
      square=i*i;
      sum=(number*(number+1)*((2*(number))+1)/6);
          //this is a formula I got.it finds the sum of squares of
          //a given number.

    cout<<square;

    if (i!=number-1)
    {
        cout<<" + ";
    }
    else if(i==number-1) 
        {   
          cout<<" = "<<sum<<endl;

        }

    }
//  function sumsq 

} 

//
void errorcheck(int number,int sum,int i, int & square)
{   

   while(number>0)
   {
       inpput(number);
        sumsq(number, sum,i,square);
       errorcheck(number,sum,i,square);

   }

}
//function errorcheck

int inpput(int & number)
{
    cout<<endl;
    cout << "Enter number : ";
    cin >> number;

    while (number<0)
    {
                                cout<<endl;

        cout<<endl;
        break;
                                break;
    }
return number;
}
mmgoicochea 0 Light Poster

wow thanks I will try that! ithat code of yours look similar but different to the code I wrote... yours seem to be more efficient :P gotta try it tomorrow... its 2am here and I so need to sleep :D

mmgoicochea 0 Light Poster

The program asks to input an integer larger than one. the number is
then passed into a function that calculates the sum of squares from
1 to that integer the output should be the value of the integer and the
sum(labeled).
A negative input value signals the end of the data.


so far I got to the point where I can add all the numbers (sum of squares) of any
number input by the user...
I have to show the numbers being added but I so do not know how to do it :/
so for example if I input this
integer 5
the sum of squares is 55....


what I want to know is how to diplay 1+4+9+16+25 next to the 55 (above).
any idea(s)?.

#include<cmath>
#include<iostream>

using namespace std;

int sumsq(int & number,int & sum,int & i);
void errorcheck(int number);

int main()
{
int number;
int sum;
int i;

	cout << "Enter number (>= 0): ";
	cin >> number;
	errorcheck(number);
	sumsq(number, sum,i);

system("pause");
return 0;
}

int sumsq(int & number,int & sum,int & i)
  {
	do
	{
	  for (i =1; i <= number; i++)
        sum =(number*(number+1)*((2*number)+1))/6;
	  cout<<"the sum of squares is"<<sum<<i++<<endl;
	i++;
	}
	while ( i<=number);
    return sum;
  } // sumsq


void errorcheck(int number)
{
	while (number<=1)
	{cout<<"wrong input..";
	cin.clear();
	cin.ignore(1000);
	
	}

}
mmgoicochea 0 Light Poster

Why do you refuse to read the useful replies in this thread?
MosaicFuneral and myself gave you the alogorithm you need. It takes only about 10 lines of code. Seriously: read it, program it, and come back in 30 minutes thanking us all because it'll work ;)

haha you were right... its almost 4am here but I did it XD oh god I hate being in intro to programming :( lol it can be frustrating when something does not work :P ok gotta go to sleep (5hrs) i have class at 11 am / thank you so much ;)

mmgoicochea 0 Light Poster

yea sorry about that :) I just gave up lol I've been trying to do this for 2 days and I so could not get it right. :( oh well im getting an F in this assignment ... not a big deal thanks to everyone that tried to help :)

mmgoicochea 0 Light Poster

//so I got this code, made several changes but apparently the "number" variable is not passing the number to the loop... it does not save it in memory and the whole while loop got screwed :/

#include <iostream>
#include<cmath>
#include <cmath>

using namespace std;

void errorCheck(int number);
void counting(int number,int count);
void askNumber(int number,int & a,int & b);
void calcEven (int number,int & a);
void calcOdd (int number,int & b);
//function prototypes
int main()
{
  
int number=0;
int count=0;
int a;
int b;

  //variable declarations



	askNumber(number,a,b);
	calcEven (number,a);
	calcOdd (number,b);
	errorCheck(number);
	counting(number,count);
	
  //function calls

system("pause");
return 0;
}
//pause and wait for an action by the user

void errorCheck(int number)
{


while (!(number>=1))
{
cout<<"input error";
cin.clear();
cin.ignore(1000,'\n');
}


}
//function definition errorcheck
void counting(int number,int count)
{

while(number !='1')
{

count++;
cin.ignore(100,'\n');

}

}
//function definition counting
void askNumber(int number,int & a,int & b)
{
number=0;
  cout<<"input a number";
  cin>>number;


while (number != 1)
{  
	if (number % 2 == 0)
		// even
		a;  
	else 
		// odd
		b; 
}
}
//function definition ask number
void calcEven (int number,int & a)
{a=(number/2);
}

//function definition calcEven
void calcOdd (int number,int & b)
{b=((number*3)+1);}

//function definition calcOdd
mmgoicochea 0 Light Poster

Hello everyone so this is the piece of code i'm wokingon..

the program ask to input an integer. If the integer is even the program will divide it by two and if the integer is odd the number will be multiplied by three and then after it is multiplied it will be added by one. if the input value is less than one , an error message will be displayed...
at the end I tried to print out how many of these operations were performed but this seems to do not want to work :(.
-several functions were added.

any help will be appreciated :). at the end I will be posting the final edit so someone else could benefit from this code ...

#include <iostream>
#include<cmath>
#include <cmath>

using namespace std;

void errorCheck(int number);
void counting(int number,int count);
void whileLoop(int number,bool finished);
void askNumber(int number);


int main()
{
  
int number;
int count;
bool finished;
  //variables



//asking the twice


	errorCheck(number);
	whileLoop(number,finished);
	counting(number,count);
	askNumber(number);
  
system("pause");
return 0;
}


void errorCheck(int number)
{

int number=0;
while (!(cin >> number))
{
cout<<"input error";
cin.clear();
cin.ignore(1000,'\n');
}


}
void counting(int number,int count)
{
count=0;
number=0;
cin.get(number);
while(number !='1')
{

count++;
cin.get(number);

}

}
void whileLoop(int number,bool finished)
{
number=0;
while (number%2)!==0
{
  cin>>number;
  (number/2);


}

	number=0;
  while(number%2)!=0
  {
  cin>>number;
  ((number*3)+1);
  
  }

  if(number==1)
  {
    finished=true;

}




}
void askNumber(double number)
{

  cout<<"input a number"<<endl;
  cin>>number;

}
mmgoicochea 0 Light Poster

sorry for the spamming...
multiple curly braces were applied in my last edit... else if statement were replaced by if () statements :) and now it really works.
{

}

mmgoicochea 0 Light Poster

DONE thank you guys!! heres the solution ;) :)

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

void salesValue(double dollars);
void commission (double dollars,double & first,double & second,double & third);
void calculate (double dollars,double & first,double & second,double & third);
//function prototypes

int main ()
{
	double dollars;
	double first;
	double second;
	double third;

	cout<<"What is the sale value?";
		cin>>dollars;


salesValue (dollars);
commission (dollars, first, second, third );
calculate (dollars, first, second, third);

	system("pause");
	return 0;

}

void salesValue (double dollars)
{
	cout<<"The sale value was"<<dollars<<endl;
	

}

void commission (double dollars,double & first,double & second,double & third)
{
	first=(dollars*0.02);
    second=(dollars*0.03);
    third=(dollars*0.05);
}

void calculate (double dollars,double & first,double & second,double & third)

{

	if (dollars < 1000)
		cout<<"Comission was 2% "<<"and the calculation is"<<first<<endl;
		
	  else if (dollars > 1000 && dollars <=10000)
				cout<<second<<"commission was 3%"<<endl;
				else if (dollars >=10001)
					cout<<third<<"commission was 5%"<<endl;
		     		else if  (dollars >= 50000)
						cout<<"This store does not allow sells over 50000"<<endl;
					else 
						cout<<"Wrong imput"<<endl; 
}
mmgoicochea 0 Light Poster

oh nevermind it does not work the way I intended it :S

mmgoicochea 0 Light Poster

ok so I initialized them :S
double dollars;
double first=0;
double second=0;
double third=0;

the program runs, no bugs at all but the teacher DID not teach us this yet :/ I think it was her fault for not telling us so I will ask her for sure :) thank you both tho... couldnt done it without you guys... sorry for being a selfish dude tho :D good night!

mmgoicochea 0 Light Poster

This program will calculate commision based on the value of sales made...

im getting three errors so far...

1>h:\cs110\assignment6\assignment6.cpp(22) : warning C4700: uninitialized local variable 'third' used
1>h:\cs110\assignment6\assignment6.cpp(22) : warning C4700: uninitialized local variable 'second' used
1>h:\cs110\assignment6\assignment6.cpp(22) : warning C4700: uninitialized local variable 'first' used.

I was reading some books and some webpages but could find a place to find the "easy" error as they called it :(

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

void salesValue(double dollars);
void commission (double dollars,double first,double second,double third);
void calculate (double dollars,double first,double second,double third);
//function prototypes

int main ()
{
	double dollars;
	double first;
	double second;
	double third;

	cout<<"What is the sale value?"<<endl;
		cin>>dollars;

commission (dollars, first, second,  third);
salesValue (dollars);
calculate (dollars, first, second, third);

	system("pause");
	return 0;

}

void salesValue (double dollars)
{
	cout<<"The sale value was"<<dollars<<endl;
	

}

void commission (double dollars,double first,double second,double third)
{
	first=(dollars*0.02);
    second=(dollars*0.03);
    third=(dollars*0.05);
}

void calculate (double dollars,double first,double second,double third)

{

	if (dollars < 1000)
		cout<<first<<"Comission was 2% "<<endl;
		
	  else if (dollars > 1000 && dollars <=10000)
				cout<<second<<"commission was 3%"<<endl;
				else if (dollars >=10001)
					cout<<third<<"commission was 5%"<<endl;
		     		else if  (dollars >= 50000)
						cout<<"This store does not allow sells over 50000"<<endl;
					else 
						cout<<"Wrong imput"<<endl; 
}
mmgoicochea 0 Light Poster

So this is the "invoice " program. Tought someone might want it or might improve it or w.e. I got 100% * the program is veeery basic and can be improved with advanced techniques and w.e. for now this is the best I can do at my 3 week experience in c++ XD

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

//including iostream, iomanip and cmath and using namespace std.
//namespace std is very helpful because if we do not use this the cout will be way 
//longer than they are. iomanip is used to setw so we could add spaces.

void numbr(long invoiceNumber);
void labels();
void separator();
void results(int quantity, float unitPrice, double tot);
// function prototypes numbr, labels separator and results.

int main()


{
	long invoiceNumber;
	int quantity;
	float unitPrice;
	double tot;
//variable declarations.
//local variables.
	cout<<"what is the invoice number?:";
	cin>>invoiceNumber;

	cout<<"What is the quantity ordered?:";
	cin>>quantity;

	cout<<"What is the price of the unit ordered?:";
	cin>>unitPrice;
	cout<<endl;
	cout<<endl;
	tot=(quantity*unitPrice);
 //gets the numbers to be used later.
// and then the program sets the formula to calculate total.
//total will be used later.

	numbr(invoiceNumber);
	cout<<endl;
	cout<<endl;
	labels();
	separator();
	results(quantity, unitPrice, tot);
	cout<<endl;
	cout<<endl;
//function calls. numbr and results have their own arguments.
system("pause");
return 0;
 }

void numbr (long invoiceNumber)
{
	cout<<"invoice number:"<<invoiceNumber<<endl;
}

void labels()

{
cout<<"Qty "<<setw(20)<<"Unit price"<<setw(20)<<"Total"<<endl;
}

void separator()
{
cout<<"------"<<setw(18)<<"---------"<<setw(21)<<"---------"<<endl;
}

void results (int quantity, float unitPrice, double tot)

{
	cout<<quantity<<setw(20)<<unitPrice<<setw(20)<<tot<<endl;

}

//function definition for numbr, separator,results and labels.
//some of …
mmgoicochea 0 Light Poster

When defining functions, you need to be sure that the prototype's and definition's arguments match exactly.

By not making sure they match, you unintentionally overloaded num() and results() to num(long) and results(int, float, double) ... sort of..... Which confuses the compiler.

:D thx I already made those and other changes... so now the program runs without problems ;)

mmgoicochea 0 Light Poster

Hello my name is Mario Goicochea I'm from peru and im in college hopping to earn a computer science degree and then move on and get a real nice job. I've been saving for years to open my own business and I think thats what Im going to do after college... so why am I studying to be a programmer? well I always loved it and I like solving things, I was told that computer science classes were mostly "lab" classes rather than memorizing, taking test hopping to pass a class... I love doing things . I so do not love memorizing stuff I know I will forget in few weeks so yeah thats the main reason I chose programming. I will open an ice cream,snacks,minibar store and my biggest dream is to create a programm to run everysingle detail of my store. since invoices, schedules, costumer databases, punch in punch outs for employees, etc..... a program that would say build by Mario Goicochea! not because I want to show it off , not at all! I just want it so bad anddd i do not know why XD :) .

oh and yeah sorry my English is horrible I know I know lol so yeah im out and thx for reading.... and sorry for grammar, and so on :)

mmgoicochea 0 Light Poster

that makes a lot of sense thank you :D.

mmgoicochea 0 Light Poster

I have this code and Im getting two errors when debugging... Im trying to change
it to arrange it but I think I have a major error.My "experience" in c++ is
veeery basic this is my third week in college :( I need help please

the errors are:


>assignment5.obj : error LNK2019: unresolved external symbol "void __cdecl results(void)" (?results@@YAXXZ) referenced in function _main
1>assignment5.obj : error LNK2019: unresolved external symbol "void __cdecl num(void)" (?num@@YAXXZ) referenced in function _main
1>H:\CS110\assignment5\Debug\assignment5.exe : fatal error LNK1120: 2 unresolved externals

code:

#include <iostream>
#include <iomanip>
#include <cmath>

using namespace std;

void num();
void labels();
void separator();
void results();

int main()

//variable declaration
{
	long invoiceNumber;
	int quantity;
	float unitPrice;
	double tot;

cout<<"what is your invoice number?:";
cin>>invoiceNumber;

cout<<"What is your quantity ordered?:";
cin>>quantity;

cout<<"What is the price of the unit ordered?:";
cin>>unitPrice;

	tot=(quantity*unitPrice);
 
	cout<<endl;
	cout<<endl;
	num();
	labels();
	separator();
	results();

system("pause");
return 0;
 }

void num (long invoiceNumber)
{

 cout<<"invoice number"<<invoiceNumber<<endl;
}

void labels()

{
cout<<"Quantities"<<setw(8)<<"unit Price"<<setw(8)<<"Total"<<endl;
}

void separator()
{
cout<<"------"<<setw(8)<<"--------"<<setw(8)<<"------"<<endl;
}

void results (int quantity, float unitPrice, double tot)

{
	cout<<quantity<<setw(8)<<unitPrice<<setw(8)<<tot<<endl;

}