Menu

Hi Guys Stuck Parts Wondering Someone Take Look Code Provide Sample Code Compare Thank Re Q43827596

Hi guys, I am stuck at some parts I was just wondering ifsomeone can take a look at my code and provide a sample code sothat I can compare. Thank you.

Here is the requirement:

*note:be aware of the Weighted Average Requirement in the course(students must achieve a
combined weight of at least 50% across all invigilatedcomponents).
Students missing 30% or more submissions will receive a UN
Students missing more than 30% of classes will receive a UN

-User can print print a report of the students grade at anytime.
The user have no restriction on the number of assignments they canenter.
Printing the report will show all the assessments for the course,the user will also see a FINAL REPORT of
the course achievement (See Appendix).
User can enter the commands:
a – Enter an assessment
r – Print the Report
q – Quit the program
If the student is absent for assessments that amount to more than30% of the weighted total of the
exams they receive a UN regardless of their weighted average.
If the student achieves more than 50% weighted average then theypass.
If the student achieves less than 50% weighted average then theyfail.

My code is:

<?php

//Keep the total number of points

//Keep the total score

//Keep the total number of missed points

//Keep a variable for the report output

//Go into a loop until the user exits

$check = true;

$totalScore = 0;

$output =0;

$totalPoints = 0;

while ($check == true)    

{

    //Prompt the user

    $command =””;

    //Read in the command

    echo “Please enter your command in theform of (a, r, q) “;

    $command = stream_get_line(STDIN, 1024,PHP_EOL);

    switch($command)

    {   

     //If the command is ….

     case ‘q’:

            echo”Bye”;

            $check= false;

            break;

        

         //Promptthe user for assessment details

     case’a’:      

            $output++;

            echo”nPHP Lab 1 – TAVu – 85032n”;

            //Enterthe name of the assessment

            echo”Enter the name of the assessment “;

            ${“nameOfAssessment”.$output}= stream_get_line(STDIN, 1024,PHP_EOL);       

            //Enterthe number of points for the assessment

            echo”Enter the number of points for the assessment”;

            ${“assessmentPoints”.$output}=stream_get_line(STDIN, 1024, PHP_EOL);

            //Checkif the user was absent, keep asking until the user enters a y or an.

            //Anotherwhile loop

            echo”Was the student absent? (y/n): “;

            ${“absent”.$output}=stream_get_line(STDIN, 1024, PHP_EOL);

            while($sentinel == true)

            {//Wasthe user absent?

                //Ifthe user entered a y or a n then exit

                //Ifthe student was absent

            if(${“absent”.$output} == “y”)    

            {

                //Writea message to the console

                echo”The student has been maked absent for this assignment.”;

                //addthe missed points to the total

                $totalScore= “0”;

                //SEtthe score to zero

      

            }

            else

            {   

                echo”Please enter the student’s score for the assessment: “;

                ${“assessmentScore”.$output}= stream_get_line(STDIN,1024,PHP_EOL);

            }

            }

            

            //Updatethe totals (Points and Score)

            $totalPoints+= ${“assessmentPoints”.$output};

            $totalScore+= ${“assessmentScore”.$output};

            //Startthe Report we have all the data we need

            //printseperator

            

         

        break;

        case ‘r’:

        //If print thereport.

        printf(“—————————————-“);

            $report.= sprintf(“%’-80sn”,”);

            

            for($i=1; $i <= $output ; $i++)

            {

            //Appendthe assignment name

            printf(“%10sAssignment:  %30sn”, “”, ${“nameOfAssessment”.$i});

            //Appendthe Total Points

            printf(“%10sTotal Points: %30sn”, “”, ${“assessmentPoints”.$i});

            //Appendthe Total Score

            printf(“%10sTotal Score: %30sn”, “”, ${“assessmentScore”.$i});

            //Appendthe Missed

            printf(“%10sMissed: %30sn”, “”, ${“absent”.$i});

            //Appendseperator

            printf(“—————————————-“);

            echo”n”;

            $totalPoints+= ${“assessmentPoints”.$i};

            $totalScore+= ${“assessmentScore”.$i};

            }

             //Compilethe final Report

           

             //Calculatedthe weighted average

             //Calculatethe missed percentage

             

             //Whasit a UN?

            

                //ifnot

               

                    //PASS

                 

                    //FAIL

                 

            //Printseperator

            $finalReport= sprintf(“%’-80sn”,”);

            

            $finalReport.= sprintf(“%40s”,”FINAL REPORT”).”n”;

            //Printthe weighted average

            //Printthe missed percentage

            //Printoutcome final outcome

            //Printseperator

            printf(“—————————————-“);

            $finalReport.= sprintf(“%’-80sn”,”);

            

             

             echo$report;

             echo$finalReport;

        break;

            //Hitthe default? Cant recognize the command?

        default:

             echo”Please enter a valid commandn”;

        break;

    }

}

?>

This is the output sample:

Appendix Enter Assessments: hp Lab@1_SWA_56789.php oder SE Please enter your command in the form of (a, r, q)a Please enter t

Appendix Enter Assessments: hp Lab@1_SWA_56789.php oder SE Please enter your command in the form of (a, r, q)a Please enter the name of the assessment: Quizi Please enter the number of points for the assessment: 10 Was the student absent? (y/n)n. Please enter the student’s score for the assessment: 6 Please enter your command in the form of (a, r, qa Please enter the name of the assessment: Quiz2 Please enter the number of points for the assessment: 10 Was the student absent? (ynnn Please enter the student’s score for the assessment: 4 Print Report: 10 ease er Total Score: Please enter your command in the form of (a, r or – nd in the form ora —- lease en cen tinand in the form ota , P Qua .. ease Total Points: of the assessment: Quizi ber of points for the assessment: 18 S the studer Missed: 9 Lease enter the lents…score for the assessment.——- ease enter your command-in-theforn_on_a_–02—- lease en Assiroment of the assessment: Quiz2 Wer of points for the assessment: 10 CIN ease Total Points: s the Total Score: lease enter Missed: dient’s score for the assessment: a 156A p orted to save as displaying dialog – – — — — — — – — — — FINAL REPORT Weighted Average: 0.50% Missed PercentagesthersNOT FOR REDISTRUBUTTON 0.00% ENTS FOUND REDES Otcom QURSE MATERIAL WILL BE INVIOLATION OF ACADEMIC IN Doce POLICIES AND WTED FACT New Outcome: PLINARY ACTION BY DMINISTRATION. – – — —- — –= = === === == == — – — — — — — — – Please enter your command in the form of (a, r, og Show transcribed image text Appendix Enter Assessments: hp Lab@1_SWA_56789.php oder SE Please enter your command in the form of (a, r, q)a Please enter the name of the assessment: Quizi Please enter the number of points for the assessment: 10 Was the student absent? (y/n)n. Please enter the student’s score for the assessment: 6 Please enter your command in the form of (a, r, qa Please enter the name of the assessment: Quiz2 Please enter the number of points for the assessment: 10 Was the student absent? (ynnn Please enter the student’s score for the assessment: 4 Print Report: 10 ease er Total Score: Please enter your command in the form of (a, r or – nd in the form ora —- lease en cen tinand in the form ota , P Qua .. ease Total Points: of the assessment: Quizi ber of points for the assessment: 18 S the studer Missed: 9 Lease enter the lents…score for the assessment.——- ease enter your command-in-theforn_on_a_–02—- lease en Assiroment of the assessment: Quiz2 Wer of points for the assessment: 10 CIN ease Total Points: s the Total Score: lease enter Missed: dient’s score for the assessment: a 156A p orted to save as displaying dialog – – — — — — — – — — — FINAL REPORT Weighted Average: 0.50% Missed PercentagesthersNOT FOR REDISTRUBUTTON 0.00% ENTS FOUND REDES Otcom QURSE MATERIAL WILL BE INVIOLATION OF ACADEMIC IN Doce POLICIES AND WTED FACT New Outcome: PLINARY ACTION BY DMINISTRATION. – – — —- — –= = === === == == — – — — — — — — – Please enter your command in the form of (a, r, og

Expert Answer


Answer to Hi guys, I am stuck at some parts I was just wondering if someone can take a look at my code and provide a sample code s…

OR