Monday, July 16, 2018

Pre release material computer science 2018 –test 2 2210/22 solutions

Pre release material computer science 2018 –test 2

2210/22 solutions 

#include

#include

using namespace std;

int main()

{

int serial=100,digit,digit2,digit3,notfound,checkdigit,uid[20],tage,age[20],noofrun[20],participant,recuid[20],starthour,startmin,startsec,finishhour,finishmin,finishsec,durationinsec,fast1,fast2,fast3,startinsec,finishinsec;

float pbtime[20],durationinmin[20];

std::string  name[20],recname1,recname2,recname3,recordfound,tname;

for (int registe=1;registe<=2;registe++)

{ digit=serial/100;

digit2=(serial/10)-(digit*10);

digit3=(serial%10);

checkdigit=10-((digit*4)+(digit2*3)+(digit3*2))%10;

uid[registe]=(serial*10)+checkdigit;

cout<<"Your register ID is "<

cout<<"\nEnter your age: ";

cin>>age[registe];

while(age[registe]<4 age="" registe="">14)

{

             cout<<"\n Eligible age between 4 to 14, enter again: ";

            cin>>age[registe];

        }

cout<<"\nEnter your name: ";

cin>>name[registe];

pbtime[registe]=100.00;

noofrun[registe]=0; recuid[registe]=0;

serial=serial+1;

}

 string alreadyparticipated="no";

int notregistered;

do{           cout<<"enter participant uid";

                cin>>participant;

                notregistered=0;

                notfound=0;

for (int idcheck=0;idcheck<20 font="" idcheck="">

   if (participant==uid[idcheck]){

    cout<<"\nYou already registered";   

    tname=name[idcheck];    

    tage=age[idcheck];

    alreadyparticipated="check"; } else{notregistered=notregistered+1;      } }

if (alreadyparticipated=="check")    {

                for (int idcheck1=0;idcheck1

                                    if (recuid[idcheck1]==participant)  {

                                    cout<<"\nYou already participate, next ";

                                    alreadyparticipated="yes"; }

                                    else{notfound=notfound+1;} } }

                    if (notfound==record)

                    { cout<<"\nYou are allowed to participate";

alreadyparticipated="no"; }

                    if (notregistered==20)

                    { cout<<"\nYou are not registered";

                                    alreadyparticipated="yes"; }

}while(alreadyparticipated=="yes"  );

recuid[record]=participant;

cout<<"Enter starttime and finishtime in HH MM SS ";

cin>>starthour>>startmin>>startsec;

                        while (starthour<0 starthour="">23 || startmin<0 startmin="">59 || startsec<0 startsec="">59)

                        {   cout<<"\n You have entered incorrect time, Enter again: ";

                            cin>>starthour>>startmin>>startsec;                        }

     cin>>finishhour>>finishmin>>finishsec;

while (finishhour<0 finishhour="">23 || finishmin<0 finishmin="">59 || finishsec<0 finishsec="">59)

                        {   cout<<"\n You have entered incorrect finish time, Enter again: ";

                            cin>>finishhour>>finishmin>>finishsec;             }

recordfound="yes";

idcheck=20;}

else{cout<<"You have already participated";}

}else { recordfound="no";}     }

}while (recordfound=="no");

cout<<"Enter starttime and finishtime in HH MM SS ";

cin>>starthour>>startmin>>startsec;

cin>>finishhour>>finishmin>>finishsec;

startinsec=(starthour*3600)+(startmin*60)+startsec;

finishinsec=(finishhour*3600)+(finishmin*60)+finishsec;

durationinsec=finishinsec-startinsec;

durationinmin[record]=int (durationinsec/60)+(float)(durationinsec%60)/100;

noofrun[record]=noofrun[record]+1;

if (durationinmin[record]

pbtime[record]=durationinmin[record];

if(noofrun[record]==11){ cout<<"You are awarded half wristband"<

if (noofrun[record]==22){ cout<<"You Have been awarded full wristband"<

if (tage >=4 && tage<=6){

if (durationinmin[record]

{fast1=durationinmin[record]; recname1=tname;}}

if (tage >=7 && tage<=10){

if (durationinmin[record]

fast2=durationinmin[record];

recname2=tname;}}

if (tage >=11 && tage<=14){

if (durationinmin[record]

fast3=durationinmin[record];

recname3=tname;}}}

     cout<<"\nThe fastest of 4 to 6 is "<

            cout<<"\nThe fastest of 7 to 10 is "<

            cout<<"\nThe fastest of 11 to 14 is "<

}