Make a Modulefora **Mark** toencapsulateamarkbetween **0** and **100** . |Mark|Grade|Scale4mark| |-------------------|-------|--------------| |0 |50 |60 |70 |80 Theclassnamemustbe **Mark** . >...


Make a Modulefora**Mark**toencapsulateamarkbetween**0**and**100**.






|Mark|Grade|Scale4mark|


|-------------------|-------|--------------|


|0


|50


|60


|70


|80










Theclassnamemustbe**Mark**.






>**:warning:Important:**Novaluesareallowedtobekeptinmarkoutoftherangeof0to100.Inanycircumstanceandduringanyfunctionifthevaluegoesbelow0orabove100,themarkissettoaninvalidemptystate.Thisconditionwillnotberepeatedinduringtheworkshopandappliestoallthefunctionsandoperatorsofclass**Mark**







##Construction


Markcanbecreatedusinganintegervalue(oneargumentconstructor)thatsetsthevalueofthemark.Ifthisvalueisnotprovided(no-argumentconstructor),thevalueofthemarkwillbezero.


```C++


Markm,n(25),k(200),p(-10);


//valueofmis0


//valueofnis25


//kisinvalid


//pisinvalid


```



##Operatorandconversionoverloads


-Markcanbecastedtoaninteger(inttype).Theresultwouldbethevalueofthemarkorzeroifthemarkisinaninvalidstate.


```C++


Markm,n(25),k(200),p(-10);


cout


cout


cout


cout


```



**Ouptut:**


```Text


0


25


0


0


```


-Anintegercanbeaddedtothevalueofthemarkusing+=operator;ifthemarkisinvalid,theactionisomitted.Referenceofthemarkisreturnedaftertheoperation.


```C++


Markm,n(25),k(200);


cout


cout


cout


cout


```



**Output:**


```Text


20


45


0


0


```


-Markcanbesettoanintegerusingtheassignmentoperator.Ifthemarkisinaninvalidstate,theinvalidvaluecanbecorrectedbytheassignment.Referenceofthemarkisreturnedaftertheoperation.


```C++


Markm,n(25),k(200);


cout


cout


cout


```



**Output:**


```Text


80


0


70


```


-Markcanbecastedtoadouble,theresultwouldbetheGPAequivalentoftheintegervalue.Seethetableofmarkvaluesabove.Castinganinvalidmarkwillresultinazerovalue.


```C++


Markm(50),n(80),k(120);


cout


cout


cout


```



**Output:**


```Text


1


4


0


```


-Markcanbecastedtoacharacter(chartype),theresultwouldbethegradelettervalueofthemark.Seethetableofmarkvaluesabove.Castinganinvalidmarkwillresultinan'X'value.


```C++


Markm(50),n(80),k(120);


cout


cout


cout


```



**Output:**


```Text


D


A


X


```


-Markcanbeaddedtoaninteger,returningtheintegeraftertheoperation.Invalidmarkswillnotaddanyvaluetotheinteger.


```C++


Markn(80),k(120);


cout


cout


```



**Output:**


```Text


140


140


```







##Testerprogram:


```C++


//Workshop5:


//Version:1.0


//Date:10/18/2020


//Author:FardadSoleimanloo


//Description:


//ThisfileteststheDIYsectionofyourworkshop


/////////////////////////////////////////////






#include


#include"Mark.h"


usingnamespacestd;


usingnamespacesdds;


intmain(){


Markm,n(25),k(200),p(-10);


cout


cout


cout


cout


cout


cout


cout


cout


cout


cout


cout


cout


cout


cout


cout


m=50;n=80;k=120;


cout


cout


cout


cout


cout


cout


cout


cout


intval=60;


cout


cout


return0;


}


```


Hereistheexecutionsampleforthetesterprogram


```Text


int............


0


25


0


0


+=.............


20


45


0


0


=..............


80


0


70


double.........


1


4


0


char...........


D


A


X


int+=Mark...


140


140


```

















































Feb 21, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here