# C++ Homework Killing Me



## levicolerogers (Sep 10, 2004)

I am in a study on your own C++ begginners course, I have never been so freakin frustrated in my life. Anyone with any kind of knowledge regarding this stuff please, please, please, email me at (EDIT)levicolerogers AT hotmail DOT com(EDIT) with any help you have. I am seriously working myself to death trying to do this crap, sixty hour work weeks plus a couple hours per night after I get out of a three hour class, this is killing me. 


HELP PLEASE

LR


----------



## elf (Jul 19, 2002)

I know some...what do you need help with?


----------



## STINEHART (Jan 1, 2004)

public class Huh

// Yes.. Post your questions. 
/* Programming is fun */
{ :sayyes:


----------



## johnwill (Sep 26, 2002)

FYI, it's a REAL BAD idea to post your email address in a public forum! That's how your mailbox gets filled with SPAM.


----------



## POADB (Jul 28, 2004)

I got an A in my C++ programming assignment. I had to write a program that allowed employees, of different pay bands, to be able to check how much they got paid by how many hours they had done.

It had to be able work out tax deductions, overtime and pension schemes etc... which the user entered via Y/N to questions.... so on and so forth.

Basicaly.. it's best practice to write ur psuedo code out on paper, and then have some one look at it (once u've pitched ur questions)..

I can do basic loops and sub routines, and the outputs but I'm rusty. It was nearly 3 yrs ago when I did C++.


----------



## STINEHART (Jan 1, 2004)

I hear you. I'm in midterms cramming on C# today. If you want to show off your coding feel free to post it. :smooch: :laugh:


----------



## levicolerogers (Sep 10, 2004)

*UHH...your a little farther than me.*

First of all I would like to address the posting my email addy on a forum, considering I handle the inflow and outflow issues of mail on my ISP's server, meaning I head there internet support dept. (granted im not a network tech but still I got it) I'm not to worried about it. 


Second, I really appreciate you guys getting back on this. I will be asking questions frequently if anyone is interested in brushing up. Right now I am working on how to use the switch control. Any suggestions? 


Thanks, I m just glad this site is here I have pulled answers off of here for spyware related fixes that I never thought I would find. 


LR


----------



## matz_1305 (Mar 7, 2005)

*HELP ME!!I'm a beginner*

#include<iostream>
#include <conio.h>
using namespace std;
class Watch
{
private:
int hour;
int min;
int sec;
public:
Watch(void);
Watch(int,int,int);
void SetTime(int,int,int);
void ShowTime(void);
};

Watch::Watch (void)
{
hour=min=sec=0;
cout<<"Constructor running"<<endl; 
} 
Watch::Watch(int h,int m,int s)
{hour=h;
min=m;
sec=s;
}
int main(void) 
{Watch x;
Watch y(2,40,30);
x.ShowTime();
y.ShowTime();
getch();
return 0; 
}

what's wrong with my program... why the compiler said 
[Linked error] undefined reference to 'Watch::ShowTime(void)' :4-dontkno 
thanx you!!


----------



## mgoldb2 (Dec 16, 2004)

You never made the functions SetTime(int,int,int); and void ShowTime(void);

example the following code should work fine. 

#include<iostream>
#include <conio.h>
using namespace std;
class Watch
{
private:
int hour;
int min;
int sec;
public:
Watch(void);
Watch(int,int,int);
void SetTime(int,int,int);
void ShowTime(void);
};

Watch::Watch (void)
{
hour=min=sec=0;
cout<<"Constructor running"<<endl; 
} 
Watch::Watch(int h,int m,int s)
{hour=h;
min=m;
sec=s;
}
void Watch::SetTime(int h, int m, int s)
{
hour=h;
min=m;
sec=s;
}
void Watch::ShowTime(void)
{
cout<<hour<<":"<<min<<":"<<sec<<endl;
}
int main(void) 
{
Watch x;
Watch y(2,40,30);
x.ShowTime();
y.ShowTime();
getch();
return 0; 
}

While this program will work fine. 

It would ba a good programming habbit to break that program up in 3 files. one for class, one for class function declearations and one for main program.


----------



## matz_1305 (Mar 7, 2005)

thank you very much... this program is my lecture give me.. and i try to write this... ^^ and i got the problem... thank you very much :heartlove

#include<iostream>
#include <conio.h>
using namespace std;
class Watch
{
private:
int hour;
int min;
int sec;
public:
Watch(void);
Watch(int,int,int);
void SetTime(int,int,int);
void ShowTime(void);
};

Watch::Watch (void)
{
hour=min=sec=0;
cout<<"Constructor running"<<endl;
}
Watch::Watch(int h,int m,int s)
{hour=h;
min=m;
sec=s;
}
void Watch::SetTime(int h, int m, int s)
{
hour=h;
min=m;
sec=s;
}
void Watch::ShowTime(void)
{
cout<<hour<<":"<<min<<":"<<sec<<endl;
}
int main(void)
{
Watch x;
Watch y(2,40,30);
x.ShowTime();
y.ShowTime();
getch();
return 0;
}

if i want to set the time how to change this program...
I input the number just for the hour... and the minutes and second is otomatic set to 0.. 
ex; i input the hour and the cout is hour:min:sec ===> 10:00:00
im so sorry my english so bad..


----------



## mgoldb2 (Dec 16, 2004)

matz_1305 said:


> if i want to set the time how to change this program...
> I input the number just for the hour... and the minutes and second is otomatic set to 0..
> ex; i input the hour and the cout is hour:min:sec ===> 10:00:00
> im so sorry my english so bad..


You set the time by using the settime funtion

example
in main

Watch X() 'default constructor set time to 0:0:0
x.settime(hour, min, secound) 'set time ti hour:min:secound
example
x.settime(10, 15, 59) 'would set the time to 10:15:59


If you wanted to put some error checking into the program you could change the program that if you put 61 for min it automatcally adds 1 to the hour and subtract 60 from the min. If you want this done and need to be shown how let me know.


----------



## matz_1305 (Mar 7, 2005)

how to change this program??i already got no idea to change this program... im si bad witg my programming


----------



## matz_1305 (Mar 7, 2005)

*somebody help me to make this program completed*

#include <iostream.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <conio.h>
using std::cout;
using std::endl;
using std::cin;

class Sb
{
private:
int x;
int y;
Sb *link;
public:
int on;
Sb(int,int);
friend class S;
};
Sb::Sb(int a,int b)
{
x=a;
y=b;
}
class S
{
private:
Sb *head;
Sb *t;
public:
S(void);
~S(void);
friend class Sb;
};
S::S(void)
{
Sb *newbody;
head=new Sb(5,5);

}
class snake
{
public:
int sx;
int sy;
snake(int,int);
};

void gotoxy(int,int);
void gotoxy(int x,int y)
{
SetConsoleCursorPosition (GetStdHandle (STD_OUTPUT_HANDLE),(COORD) 

{x - 1,
y - 1});
}
snake::snake(int Sx,int Sy)
{
sx=Sx;
sy=Sy;

int map=20;

cout<<"how much is map(10-20)? ";
cin>>map;
if(map>20)map=20;
else if(map<10)map=10;
system("cls");



system("cls");
cout<<endl;
int x[(0+map)][(0+map)];
for(int i=0;i<map;++i)
{
for(int j=0;j<map;++j)
{
x_[j]=0;
if(i==0||i==(map-1)||j==0||j==(map-1)) x[j]=1;
}
}
for(int i=0;i<map;++i)
{
for(int j=0;j<map;++j)
{
if(x[j]==0)cout<<" ";
if(x[j]==1)cout<<"X ";
}
cout<<endl;
}
for(int i=0;i<map;++i)
{
for(int j=0;j<map;++j)
{
if(x[j]==0) {gotoxy(i*2+1,j+2);cout<<" "; }
if(x[j]==1) {gotoxy(i*2+1,j+2);cout<<"X "; }
}
}
gotoxy(1,1);cout<<" use (8)(6)(4)(2)to move"; gotoxy(1,1);
int px,py;
int t=0;
px=map/2;
py=px;
char c;
int r;
int a[30000];
int b[30000];
int re=5;

int rn,a1,a2;
rn=1;
gotoxy(px*2+1,py+2);cout<<"o ";gotoxy(1,1);
a1=(rand()%(map-2))+1;
a2=(rand()%(map-2))+1;
gotoxy(a1*2+1,a2+2);cout<<"E ";gotoxy(1,1);x[a1][a2]=2;
for(;
{
c=getche();
x[px][py]=1;
if(c=='8'){py=py-1;r=8;}
else if(c=='2'){py=py+1;r=2;}
else if(c=='4'){px=px-1;r=4;}
else if(c=='6'){px=px+1;r=6;}
else if(r==8){py=py-1;}
else if(r==2){py=py+1;}
else if(r==4){px=px-1;}
else if(r==6){px=px+1;}
if(x[px][py]==1)break;
x[map/2][map/2]=0;

if(x[px][py]==2)
{re++;
o: a1=(rand()%(map-2))+1;
a2=(rand()%(map-2))+1;

if(x[a1][a2]==0&&(a1!=map/2||a1!=map/2))
{
gotoxy(a1*2+1,a2+2);cout<<"E ";gotoxy(1,1);x[a1][a2]=2;
}
else goto o;
}

gotoxy(px*2+1,py+2);cout<<"O ";gotoxy(1,1);
a[t]=px;
b[t]=py;
t++;
if(t>=re){
gotoxy(a[t-re]*2+1,b[t-re]+2);
cout<<" ";gotoxy(1,1);
x[a[t-re]][b[t-re]]=0;
}
gotoxy(10,2);cout<<"score "<<(re-5)*100;gotoxy(1,1);
}

}



int main(void)
{
int cix,ciy;
cout<<"position:"<<endl;cin>>cix;
cout<<"position Y:"<<endl;cin>>ciy;
j: snake snake(cix,ciy);
char ar;
ar='n';
system("cls");
cout<<"try again(Y/N)"<<endl;cin>>ar;
if(ar=='y'){ system("cls");goto j; }
system("PAUSE");
return 0;
}

please tell where is the problem with my program_


----------



## eebs (Sep 22, 2005)

*Beginner Lost*

I also am stuck with C++. I have an assignment due and i cant quite get it. Ive been working on it for hours and hours...sux 
My program needs to find the sum of two numbers but the numbers can be really large up to 300 digits. So im trying to get a grasp on pointers and all that. need some help


----------



## LoneWolf071 (Nov 10, 2004)

ok, we can't do it for you, if you ask a specific question, like what library or header to use, we can help, or if you post your code here we can help with a problem...


----------



## mgoldb2 (Dec 16, 2004)

Anouther thing if you want other people to read your code and debug it then you should comment it good. It not the debugger job to guess what the intention of the code or any piece of the code. Good documentation habbits is extremly important in the real world. Especially once you start writing longer programs.


----------



## elf (Jul 19, 2002)

mgoldb2 said:


> Anouther thing if you want other people to read your code and debug it then you should comment it good. It not the debugger job to guess what the intention of the code or any piece of the code. Good documentation habbits is extremly important in the real world. Especially once you start writing longer programs.


ditto...


----------



## LoneWolf071 (Nov 10, 2004)

So True...


----------



## johnwill (Sep 26, 2002)

This should give you a head start. :smile:


----------

