Having trouble with this assignment not sure how to fix all 4 things. having difficulties with all of them. Please help.
number 1
//DEBUG1-1
#include<iostream>
void main()
double myMoney, yourMoney;
myMoney = 286.72;
yourMoney = 124.67;
cout<<"I have "<<"myMoney"<<" and you have "<<yourMoney<<endl;
system(:pause:);
number 2
#include<iostream>
#include<string.h>
class RepairJob
{
void friend displayRepairJob(RepairJob rj, Technician tech);
private:
int jobNum;
int mo;
int day;
int yr;
double amount;
int techNum;
public:
RepairJob(int job, int m, int d, int y, double amt, int tech);
};
RepairJob::RepairJob(int job, int m, int y, double amt, int tech)
{
jobNum = job;
mo = m;
day = d;
yr = y;
amount = amt;
jobNum = tech;
}
class Technician
{
friend void displayRepairJob(RepairJob rj, Technician tech);
private:
int techId;
char name[20];
public:
Technician(int id, char nm[]);
};
Technician::Technician(int id, char nm[])
{
techId = id;
name = nm;
}
void displayRepairJob(RepairJob rj, Technician tech)
{
cout<<"RepairJob "<<rj.jobNum<<" on "<<rj.mo<<"/"<<rj.day<<"/"<<rj.yr<<
" for $"<<rj.amount<<" repaired by #"<<tech.techId<<" "<<tech.name<<endl;
}
void main()
{
RepairJob job(1386,9,2,2003,228.95,345);
Technician tech(345,"Dunne");
displayRepairJob();
system(:pause:);
}
number 3
#include<iostream>
#include<string.h>
class Player;
class League
{
friend int canPlayerJoin(Player aPlayer, League aLeague);
private:
char leagueName[35];
int minimumAge;
int maximumAge;
public:
void setValues(char leagueName[], int min, int max);
void displayValues();
};
void League::setValues(char leagueName[], int min, int max)
{
int temp;
strcpy(leagueName, leagueName);
if(min > max)
{
temp = min;
min = max;
max = temp;
}
minimumAge = min;
maximumAge = max;
}
void League::displayValues()
{
cout<<leagueName<<" Minimum age: "<<minimumAge<<" Maximum age: "<<maximumAge<<endl;
}
class Player
{
friend int canPlayerJoin(Player aPlayer, League aLeague);
private:
char name[20];
int age;
public:
void setValues(char playerName[], int playerAge);
};
void PLayer::setValues(char playerName[], int playerAge)
{
strcpy(name,playerName);
age = playerAge;
}
int League::canPlayerJoin(Player aPlayer, League aLeague)
{
int leagueFlag = 0;
if(aPlayer.age>= aLeague.minimumAge && aPlayer.age <= aLeague.maximumAge)
leagueFlag = 1;
return(leagueFlag);
}
void main()
{
int x;
League aLeague[8];
Player aPlayer;
aLeague[0].setValues("PeeWee Softball",4,6);
aLeague[1].setValues("PeeWee Soccer",4,7);
aLeague[2].setValues("Shooting Stars Soccer",7,10);
aLeague[3].setValues("White Lightning Basketball",6,9);
aLeague[4].setValues("Track Trekkers",9,11);
aLeague[5].setValues("Junior Shots",11,14);
aLeague[6].setValues("Senior Shots",12,16);
aLeague[7].setValues("Travelling Homers",13,17);
aLeague[8].setValues("Key Trotters",14,18);
aPlayer.setValues("Katie",7);
cout<<"Acceptable Leagues this player can join: "<<endl;
for(x = 0; x< 8; ++x)
if(canPlayerJoin(aPlayer,aLeague[x]))
aLeague[x].displayValues();
system(:pause:);
}
number 4
#include<iostream>
#include<string.h>
class Order
{
Order yearEndTotal(Order summary, Order oneOrder);
private:
char customerName[20];
int orderQuantity;
public:
Order();
setValues();
displayValues();
};
Order::Order()
{
strcpy(customerName,"Total");
orderQuantity=0;
};
void setValues()
{
cout<<"Enter customer name ";
cin>>customerName;
cout<<"Enter quantity ordered: ";
cin>>orderQuantity;
}
void Order::displayValues()
{
cout<<customerName" ordered "orderQuantity" items."endl;
}
Order yearEndTotal(Order summary, Order oneOrder)
{
summary.orderQuantity = oneOrder.orderQuantity;
return(summary);
}
void main()
{
const int ORDERS = 10;
Order anOrder[ORDERS];
Order summary;
int x;
for(x=0; x<ORDERS; ++x);
anOrder[x].setValues();
for(x = 0; x< ORDERS; ++x)
{
summary = yearEndTotal(summary,anOrder[x]);
}
summary.displayValues();
system(:pause:);
}
Is the real nature of these homework that you have been given erroneous code and your task is to figure out what is not correct and propose changes?
Your compiler is your friend. If you try to compile a code that has syntactic errors, then the compiler will tell what it does not like. (Some compilers are more to the point than others, but all do say something.)
Lets take an example:
1 2 3 4 5 6 7 8
//DEBUG1-1
#include<iostream>
void main()
double myMoney, yourMoney;
myMoney = 286.72;
yourMoney = 124.67;
cout<<"I have "<<"myMoney"<<" and you have "<<yourMoney<<endl;
system(:pause:);
reports:
4:1: error: expected initializer before 'double'
5:1: error: 'myMoney' does not name a type
6:1: error: 'yourMoney' does not name a type
7:1: error: 'cout' does not name a type
8:7: error: expected constructor, destructor, or type conversion before '(' token
Start from first error, for the other errors might be only side-effects of the first:
Since this is an assignment you should start by compiling each example and see what errors you get. Then when compiled run the program to see what output you get.
Just looking at the first example I see three possible errors/problems. One may not be an problem for you depending on how old your compiler is.
The use of "system" anything is not a good idea as it could leave your program open to attack. I look at this a forth problem.
I looks like the point is to find the mistakes. If I tell you all the answers you will miss the opportunity to learn how to debug a program, yours or someone else's.
Instead of asking for all the answers compile and then run the program(s) and figure out what is wrong.