x.Hmelp on changing this code to c++ class instead of struct. The struct members
ID: 3615345 • Letter: X
Question
x.Hmelp on changing this code to c++ class instead of struct. The struct members should be class private data and obviously public are the functions. ThanksBelow is the file and the c code
135 90 4 9.0 a S 11/9 C 1 AVE 228 4.00 Society of Professional Engineers
140 36 2 12.0 p M 10/10 L B TTD 110 5.00 Association for Computing Machinery
141 45 3 2.30 p R 10/11 V 1 MOC 316 3.00 Game Developer's Club
134 18 4 1.0 p R 10/9 M W SOC 105 5.00 National Society of Black Engineers
488 20 1 12.0 p F 10/10 P M AGT 100 20.00 Student Senate
525 15 2 11.30 a T 10/11 O 3 BOD 218 5.00 Marching band
491 100 3 3.0 p N 10/9 V A SH 121 0.0 AWT Volunteers
512 15 1 9.30 a S 10/12 C L LAM 118A 15.00 Concert choir
170 91 4 10.0 a M 10/11 F R RSV 402P 6.00 Biomedical Engineering Student Society
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define MAXGROUP 10
#define MINCOUNT 6
#define MAXCOUNT 10
#define ZERO 0
struct activities
{
int groupnum;
char *groupname;
float meettime;
char mthalfday;
char meetday;
int meetweek;
int nextmonth;
int nextday;
char buildingloc[4];
char meetroom[5];
char purpose;
char memtype;
int groupsize;
float groupcost;
};
void printallinput(struct activities fungroup[MAXGROUP], int xindex);
int main(void)
{
FILE *groupfile;
struct activities group[MAXGROUP];
int iindex, jindex, kindex, count;
int intro, index, len,temp;
int choose, xindex, xcount;
char chflush,ch;
char temparr[100];
printf(" Activities which you are interested in must be between %d and %d. ",MINCOUNT,MAXGROUP);
printf("Please enter your choice:>>> ");
scanf("%d", &count);
while((count < MINCOUNT) || (count > MAXGROUP))
{
printf(" Wrong input: Please reenter the number of activities you interested in ");
printf(" Must be between %d and %d ", MINCOUNT, MAXCOUNT);
scanf("%d", &count);
}
groupfile = fopen("xfile.dat", "r");
if(groupfile == NULL)
{
printf(" Error opening File! ");
return 0;
}
iindex = 0;
while(iindex<count && fscanf(groupfile,"%d", &(group[iindex].groupnum)) != EOF)
{
fscanf(groupfile, "%d", &(group[iindex].groupsize));
fscanf(groupfile, "%d", &(group[iindex].meetweek));
fscanf(groupfile, "%f", &(group[iindex].meettime));
fgetc(groupfile);
group[iindex].mthalfday = fgetc(groupfile);
fgetc(groupfile);
group[iindex].meetday = fgetc(groupfile);
fgetc(groupfile);
temp=1;
jindex=0;
ch= fgetc(groupfile);
while(ch!='/')
{
temp=temp*jindex+(ch-48);
&n
Explanation / Answer
#include#include#include#define MAXGROUP 10#define MINCOUNT 6#define MAXCOUNT 10#define ZERO 0struct activities{int groupnum;char *groupname;float meettime;char mthalfday;char meetday;int meetweek;int nextmonth;int nextday; char buildingloc[4];char meetroom[5];char purpose;char memtype;int groupsize;float groupcost;};class act{private:FILE *groupfile;struct activities group[MAXGROUP];int iindex, jindex, kindex, count;int intro, index, len,temp;int choose, xindex, xcount;char chflush,ch;char temparr[100];public: act(){printf(" Activities which you are interested in must be between %d and %d. ",MINCOUNT,MAXGROUP);printf("Please enter your choice:>>> ");scanf("%d", &count);while((count MAXGROUP)){printf(" Wrong input: Please reenter the number of activities you interested in ");printf(" Must be between %d and %d ", MINCOUNT, MAXCOUNT);scanf("%d", &count);}groupfile = fopen("xfile.dat", "r");if(groupfile == NULL){printf(" Error opening File! ");//return 0;}iindex = 0;while(iindexRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.