Answer:
var playerTurn;
var NUM_COLS;
var NUM_ROWS;
var SYMBOLS;
var tiles = [];
var checkWin = function()
{ };
var Tile = function(x, y)
{
this.x = x;
this.y = y;
this.size = width/NUM_COLS;
this.label = "";
};
Tile.prototype.draw = function()
{
fill(214, 247, 202);
strokeWeight(2);
rect(this.x, this.y, this.size, this.size, 10);
textSize(100);
textAlign(CENTER, CENTER);
fill(0, 0, 0);
text(this.label, this.x+this.size/2, this.y+this.size/2);
};
Tile.prototype.empty = function()
{
return this.label === "";
};
Tile.prototype.onClick = function()
{
// If the tile is not empty, exit the function
// Put the player's symbol on the tile
// Change the turn
};
Tile.prototype.handleMouseClick = function(x, y)
{
// Check for mouse clicks inside the tile
};
for (var i = 0; i < NUM_COLS; i++)
{
for (var j = 0; j < NUM_ROWS; j++)
{
tiles.push(new Tile(i * (width/NUM_COLS-1), j * (height/NUM_ROWS-1)));
}
}
var drawTiles = function()
{
for (var i in tiles)
{
tiles[i].draw();
}
};
mouseReleased = function()
{
for (var i in tiles)
{
tiles[i].handleMouseClick(mouseX, mouseY);
}
};
draw = function()
{
background(143, 143, 143);
drawTiles();
};
Explanation:
Answer:
Following are the program in the C++ Programming Language.
//header file
#include<iostream>
//header file
#include <bits/stdc++.h>
//namespace
using namespace std;
//set main function
int main()
{
//set float type variables
float a,s,m,d,c,b,g;
//print message and get variable from the user
cout<<" Enter The First Number : ";
cin>>c;
//print message and get variable from the user
cout<<" Enter The Second Number: ";
cin>>b;
again:
//get variable from the user for Operation
cout<<" Enter the Operation which you want : ";
char choice;
cin>>choice;
//Addition
a=c+b;
//Subtraction
s=c-b;
//Multiplication
m=c*b;
//Division
d=c/b;
//Modulus
g=fmod(c, b);
//set switch statement
//here is the solution
switch(choice)
{
case '+':
cout<<"Addition: "<<a<<endl;
goto again;
break;
case '-':
cout<<"Subtraction: "<<s<<endl;
goto again;
break;
case '*':
cout<<"Multiplication: "<<m<<endl;
goto again;
break;
case '/':
cout<<"Division: "<<d<<endl;
goto again;
break;
case '%':
cout<<"Modulus: "<<g<<endl;
goto again;
break;
default:
cout<<"Exit";
break;
}
return 0;
}Explanation:
Here, we define the required header files then, we set main function.
Answer:
Given Data:
Clock rate of P1 = 4 GHz
Clock rate of P2 = 3 GHz
Average CPI of P1 = 0.9
Number of Instructions = 5.0E9 = 5 × 10^9
Clock rate of P2 = 3 GHz
Average CPI of P2 = 0.75
Number of Instructions = 1.0E9 = 10^9
To find: If the computer with largest clock rate has the largest performance?
Explanation:
Solution:
As given in the question, clock rate of P1 = 4 GHz which is greater than clock rate of P2 = 3 GHz
According to the performance equation:
CPU Time = instruction count * average cycles per instruction/ clock rate
CPU Time = I * CPI / clock rate
Where instruction count refers to the number of instructions.
Performance of P1:
CPU Time (P1) = 5 * 10^9 * 0.9 / (4 * 10^9)
= 5000000000 * 0.9 / 4000000000
= 4500000000 / 4000000000
= 1.125s
Performance of P2:
CPU Time (P2) = 10^9 * 0.75/ (3 * 10^9)
= 750000000 / 3000000000
= 0.25s
So the Performance of P2 is larger than that of P1,
performance (P2) > performance (P1)
0.25 is better than 1.125
But clock rate of P1 was larger than P2
clock rate of P1 > clock rate of P2
4 GHz > 3 GHz
So this is a misconception about P1 and P2.
It is not true that computer with the largest clock rate as having the largest performance.
Answer:
The solution code is written in Python.
Explanation:
Firstly, use input() function to prompt user for a file name. (Line 1)
Next, we use input() function again to prompt user input a target character (Line 2)
Create a reader object and user read() method to copy entire texts from to the variable content (Line 4 - 5).
At last we can get the number of times the specified character appears in the file using the Python string built-in method count() (Line 6)
Answer:
Its A Dynamic Web Page
Explanation:
i = []
for i in range(len([s1])):
if s1.count(s1[i]) > 1:
has_dups = True
elif s1.count(s1[i]) = 1:
has_dups = False
Here is the message I got from the system:
Solutions with your approach don't usually use: elif
Please Help me to correct it.
B) Nouns and verbs in the problem description
C) Polymorphism
D) UML notation
Answer:
A) Javadoc comments
Explanation:
It is used for documenting the java source code in HTML and java code documentation. The difference between multi-line comment and javadoc is that ,javadoc uses extra asterisk, For example-
/**
* This is a Javadoc
*/
It is used to record the behavior of classes.There are various tags used in this like @author,{@code},@exception and many more.