CS201 ASSIGNMENT NO3 # SOLUTION

18:26 0 Comments

// sharaz ghouri developer
#include <iostream>
#include <stdlib.h>
#include <time.h>
#include <string.h>
using namespace std;

class Player {
    private:
        char name[20];
        int score;

    public:
        Player(){
            strcpy(name, "\0");
            score = 0;
            cout<<"Constructor Called";
        }
        ~Player(){
            cout<<"Destructor Called"<<endl;
        }
        void setName(){          
            cin>>this->name;
        }
        char* getName(){
            return this->name;
        }
        void setScore(int score){
            this->score = score;
        }                  
        int getScore(){
            return this->score;
        }    
};  

void displayInformation () {
cout<<"This is a mini Game, allowing three players to contest.";
cout<<"Each Player will have to open three boxes from given one hundred boxes in 3 turns.";
cout<<"There is a secret number in each box. In each turn number, the secret number inside the selected box will add-up to the total score of player.  At the end, it will display the summary of score of each player.\n\n";
}

void fillBoard(int array[10][10]){
    srand(time(0));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            array[i][j] = rand()%100+1;
        }  
    }
}  
void displayBoard(int array[10][10]){
    int *ptr = *array;
   
    system("cls");
   
    displayInformation();
   
    for(int i = 1; i <= 100; i++){
        if(*ptr != 0){
            //cout<<i<<"("<<*ptr<<")\t";
            cout<<i<<"\t";
        }
        else {
            cout<<"X\t";
        }      
        ptr++;
           
        if(i%10 == 0)
            cout<<endl;
    }
    cout<<endl;
    ptr = NULL;
}  

int openBox(int grid[10][10]){
    int *ptr = *grid, choice = 0, secretNumber = 0;
    cout<<"Enter the number of box to open it: ";
    cin>>choice;
 
    ptr = ptr+choice-1;
    secretNumber = *ptr;
    *ptr = 0;
    return secretNumber;
}  
void mySwap(Player &a, Player &b) // defenation of swaping value
{
Player temp = a;
a = b;
b = temp;
}
// sorting fuction

void sortPlayers(Player players[], int size){

   
 
for(int i = size-1; i!=0 ; i--)
{
for(int j = 0; j < size-1; ++j)
{
if( players[j].getScore() < players[j+1].getScore())
{
mySwap( players[j], players[j+1]);
}
}
}


}

main(){
    int size = 3, board[10][10] = {0};
    Player players[size];
   
   
    displayInformation();
   
    for(int x = 0; x < size; x++) {
    fillBoard(board);
    cout<<"Enter name of player "<<x+1<<" of "<<size<<": ";
players[x].setName();    
   
    for(int i = 1; i <= 3; i++){
    displayBoard(board);
cout<<"Turn "<<i<<" of 3"<<endl;
   
    if(i < 3) {
    players[x].setScore(players[x].getScore()+openBox(board));
}
else{
char choice = '\0';
            int offer = 25+rand()%51;
            cout<<"Special offer take: "<<offer<<endl<<endl;
           
            cout<<"You can take special offer or open last box."<<endl;
            cout<<"To take special offer press y or Y and any other character to open your last box: ";
            cin>>choice;
           
            if(choice == 'y' || choice == 'Y'){
                players[x].setScore(players[x].getScore()+offer);
            }  
            else{
                players[x].setScore(players[x].getScore()+openBox(board));
            }  
            }              
            cout<<endl<<endl;        
}    
    cout<<"Your Score: "<<players[x].getScore()<<endl<<endl;
}

sortPlayers(players, size);

cout<<"----------  Result Summary --------------   "<<endl;
for(int k = 0; k < size; k++) {
cout<<players[k].getName()<<"\t Score: "<<players[k].getScore()<<endl;
}
cout<<endl;
    system("pause");  
}  

0 comments:

CS101 ASSIGNMENT NO#3 SOLUTION

17:52 0 Comments

<!-- sharaz ghouri  developer-->

<html>
<head>
<title>CS101 Assignment no3</title>
<!-- scrip formula for convert fn to c and k-->
<script>
function formula(){
var input= document.ftocandk.fvalue.value;

var celuis=(input-32)*5/9;

var kelvin=(input-32)*5/9+273.15;

if((document.ftocandk.fvalue.value.length)<1)
{
 window.alert('Please! enter any value in farenhit value');

}
else
{

document.ftocandk.cvalue.value=celuis;
document.ftocandk.kvalue.value=kelvin;
}
}
</script>

</head>
<body>

<h1 style="background-color:blue" align="center">Pakistan Metrological Department</h1>

<p style="background-color:deepskyblue">You are welcome to online temperature converter.
 Here is a simple Fahrenheit temprature converter. You can enter Fahrenheit values and get converted values <br>
into Celsius and Kelvin as per your requrement</p>

<form name="ftocandk" method="post" action="">
<table>
<tr>
<td>Fahrenheit :</td><td><Input type="text" name="fvalue" size="30%" >
<td>
</tr>
<tr>
<td>Celuis : </td><td><input type="text" name="cvalue" size="30%" value=0.00></td>
</tr>
<tr>
<td>Kelvin :</td><td><input type="text" name="kvalue" size="30%" value=0.00></td>
</tr>
<tr>
<td></td>
<td align="left" colspan="2" ><input type="button" name"convert" value="convert" onCLick=formula()>
<input type="reset" name="reset" value="Reset Form"></td>
</tr>
</table>
</form>

<p>To clear your form for new conversion you can press the &quotReset Form&quot button and all values will
 be erased from fields</p>
<body>
</html>

<!-- END-->
CS101 Assignment no3

Pakistan Metrological Department

You are welcome to online temperature converter. Here is a simple Fahrenheit temprature converter. You can enter Fahrenheit values and get converted values
into Celsius and Kelvin as per your requrement
Fahrenheit :
Celuis :
Kelvin :
To clear your form for new conversion you can press the &quotReset Form&quot button and all values will be erased from fields

0 comments:

VU STUDENT WATCH WORLD CUP HERE

00:07 0 Comments





VU STUDENT SPECIAL WORLD CUP STREAMING PLZ COMMENT HERE

0 comments:

ICC World Cup Warm up matches, 2015

23:53 0 Comments

ICC World Cup Warm up matches, 2015

Feb 08 2015 - Feb 13 2015, Teams: India, Australia, South Africa, Sri Lanka, New Zealand, Zimbabwe, England, West Indies, Pakistan, Bangladesh, Ireland, Scotland, Afghanistan, United Arab Emirates.
Series Home Play Fantasy Cricket
DateMatch DetailsTimeVenueD/N
GMTISTYour TimeGroundCity
Feb 08 - SunAustralia vs India, 1st Match03:309:00 AM19:30
(Feb 7)
Adelaide OvalAdelaide
Feb 09 - MonNew Zealand vs Zimbabwe, 2nd Match22:00
Feb 8
3:30 AM
(Feb 9)
14:00Bert Sutcliffe OvalLincoln
Feb 09 - MonSouth Africa vs Sri Lanka, 3rd Match22:00
Feb 8
3:30 AM
(Feb 9)
14:00Hagley OvalChristchurch
Feb 09 - MonEngland vs West Indies, 4th Match03:309:00 AM19:30
(Feb 8)
Sydney Cricket GroundSydney
Feb 09 - MonBangladesh vs Pakistan, 5th Match03:309:00 AM19:30
(Feb 8)
Blacktown Olympic Park OvalSydney
Feb 10 - TueIreland vs Scotland, 6th Match03:309:00 AM19:30
(Feb 9)
Blacktown Olympic Park OvalSydney
Feb 10 - TueIndia vs Afghanistan, 7th Match03:309:00 AM19:30
(Feb 9)
Adelaide OvalAdelaide
Feb 11 - WedNew Zealand vs South Africa, 8th Match22:00
Feb 10
3:30 AM
(Feb 11)
14:00Hagley OvalChristchurch
Feb 11 - WedSri Lanka vs Zimbabwe, 9th Match22:00
Feb 10
3:30 AM
(Feb 11)
14:00Bert Sutcliffe OvalLincoln
Feb 11 - WedAustralia vs United Arab Emirates, 10th Match03:309:00 AM19:30
(Feb 10)
Melbourne Cricket GroundMelbourne
Feb 11 - WedEngland vs Pakistan, 11th Match03:309:00 AM19:30
(Feb 10)
Sydney Cricket GroundSydney
Feb 12 - ThuScotland vs West Indies, 12th Match23:00
Feb 11
4:30 AM
(Feb 12)
15:00Sydney Cricket GroundSydney
Feb 12 - ThuBangladesh vs Ireland, 13th Match23:00
Feb 11
4:30 AM
(Feb 12)
15:00Blacktown Olympic Park OvalSydney
Feb 13 - FriAfghanistan vs United Arab Emirates, 14th Match23:00
Feb 12
4:30 AM
(Feb 13)
15:00Junction OvalMelbourne

0 comments:

Facebook