Homework. Please help

Having trouble figuring out these 4 debugs for class. Can someone please help me fix them.




Number 1
//Chapter 6 Debug 1
#include<iostream>
class Auto
{
private:
int autoId;
char mechanicName[20];
double fee;
public:
Auto(int id = 999, char name[], double amt = 25.00);
void showAuto();
};
Auto(int id, char name[], double amt)
{
autoId = id;
strcpy(mechanicName, name);
fee = amt;
}
void showAuto()
{
cout<<"Auto #"<<autoId<<" worked on by "<<mechanicName<<" Amount due $"<<fee<<endl;
}

void main()
{
cout<<"Mike's Service "<<endl<<"Autos Worked on Today"<<endl<<endl;
cout<<"Mike works on most cars. Occasionally he assigns a job to another mechanic"<<endl;
cout<<"Minimum charge $25"<<endl<<endl;
Auto car1, car2(321), car3(456,"Amy"), car4(567,"Jeremy",149);
car1.showAuto();
car2.showAuto();
car3.showAuto();
car4.showAuto();

system("pause");
}








number 2
//Debug 6-2
#include<iostream>
class BirthdayCake
{
private:
int orderNumber;
char cakeFlavor[20];
char frostingFlavor[20];
int numCandles;
BirthdayCake(int num, char cake[]="white", char frost[] = "vanilla", int numCandles = 1);
void displayBirthdayCake();
};
BirthdayCake::BirthdayCake(int num, char cake[] = "white", char frost[] = "vanilla", int candles)
{
orderNumber = num;
cakeFlavor =cake;
frostingFlavor =frost;
numCandles = candles;
}
void BirthdayCake::displayBirthdayCake()
{
cout<<"Order #"<<orderNumber<<" "<<cakeFlavor<<" cake with "<<
frostingFlavor<<" frosting and "<<numCandles;
if(numCandles == 1)
cout<<" candle";
else cout<<" candles";
cout<<endl;
}
void main()
{
cout<<"Cakes are white with vanilla frosting and 1 candle unless otherwise indicated"<<endl;
BirthdayCake a(111,"chocolate","chocolate",8);
BirthdayCake b(222,"yellow", "chocolate");
BirthdayCake c(333,"banana");
BirthdayCake d(444);
a.displayBirthdayCake();
b.displayBirthdayCake();
c.displayBirthdayCake();
d.displayBirthdayCake();
system("pause");
}







number 3
//Debug 6-3
#include<iostream>
class ClubMember
{
private:
static int count;
char name[20];
public:
ClubMember();
~ClubMember();
};
int ClubMember::count = 0;
ClubMember::ClubMember(char name)
{
++count;
strcpy(name,name);
cout<<"ClubMember #"<<count<<" created: ";
cout<<name<<" has joined the club"<<endl;
}
ClubMember::~ClubMember(char name)
{
--count;
cout<<name<<" has left the club"<<endl;
cout<<count<<" ClubMembers left"<<endl;
}
void main()
{
{
cout<<"This program shows five club members"<<endl<<"joining, then leaving, the club"<<endl;
ClubMember club[5] = {ClubMember("Jim"),ClubMember("Tom"),
ClubMember("Julie"),ClubMember("Jane"),ClubMember("Kate")};
}
system("pause");
}







number 4
// Debug 6-4
#include<iostream>
class Dress
{
private:
char material[20];
int size;
char style[10];
double price;

public:
Dress(char mtrl[] = "cotton",char stl[] = "daytime");
void displayDress();
};
Dress::Dress(char mtrl[], int sz, char stl[])
{
strcpy(material,mtrl);
sz = size;
strcpy(style,stl);
price = 29.99;
if(strcmp(material,"silk") == 0)
price += 20.00;
if(strcmp(style, "evening")==0)
price += 40.00;
}

void Dress::displayDress()
{
cout<<"A size "<<size<<" dress made of "<<material<<" and suitable for "<<
style<<" wear costs $"<<price<<endl;
}

void main()
{
cout<<"Dress sale! $29.99. Only $20 more for sil. Only $40 more for evening designs."<<endl;
Dress dressA, dressB("wool"), dressC("silk",14,"evening"),
dressD("denim",4,"casual"),dressE("silk",8,"business");
dressA.displayDress();
dressB.displayDress();
dressC.displayDress();
dressD.displayDress();
dressE.displayDress();
system("pause");
}
I don't see how one can help without doing the homework for you... xD
Keep trying :)
Topic archived. No new replies allowed.