how prevalent is identity theft,how does it affect the victims presently and long term and what term and what are some of the issues in prosecuting the offenders?
In: Computer Science
Write a Java program to read in text line by line until a blank line is entered. When this occurs the program returns the total number of words and characters found as shown in the example below.
A program to count the number of words and characters in an input text block.
Enter text line by line; blank line to end.
>> This is the first line of text
>> Followed by the second line of text
>> Ending with the final line of text
>>
Your text contained 21 words and 81 characters.
Your program should be able to reproduce this example (Note that text following the >> prompt is user input to the program).
Instructions
1. Start by writing a method, countLine, to count the number of words and characters in a string. It should have the following signature:
private countObject countLine(String input) {
which returns the total number of words and characters in the input string, where countObject is a simple nested class similar to listNode with two instance variables corresponding to the number of words and characters respectively.
class countObject {
int words;
int chars;
}
Hint: you might consider adding a constructor to initialize this object and getter methods to retrieve each component.
2. Write a main class which implements the user dialog shown in the example. It calls the countLine method to process each line read and adds the counts returned in countObject to the totals. Call this class wordCount.
Hints: You may use that acm.jar is available; the StringTokenizer class can greatly simplify the coding of the countLine method.
Do your coding in Eclipse. Cut and paste wordCount.java into the space provided on the exam.
In: Computer Science
In C, build a connect 4 game with no graphical use interface. Build only the text interface. Use a 2D array as the Data structure. The skeleton of the game is provided for you, Build the game based on the guidelines below. The game does NOT need a mode where you play against the computer. It is simply a game of Connect 4 between player 1 and player 2.
SKELETON:
#include
// Initializing constants
#define NAME_LENGTH 30
#define BOARD_WIDTH 6
#define BOARD_HEIGHT 6
#define GAME 0
#define P_ONE 1
#define P_TWO 2
#define NO 0
#define YES 1
// Declaring variables
char p1[NAME_LENGTH];
char p2[NAME_LENGTH];
int bWidth = BOARD_WIDTH;
int bHeight = BOARD_HEIGHT;
int playCurrent = P_ONE; // Player 1 starts by default
int gameOver = GAME; // GAME = game is running, P_ONE = player one
has won and so on
int p1Quit = NO;
int p2Quit = NO;
//print “Setting up the game”. Ask each player their name.
void Initialization() {
printf("Setting up the
game\n");
printf("Enter your
names\n");
printf("Player
1:\n");
scanf("%s", p1);
printf("Player
2:\n");
scanf("%s", p2);
}
void Teardown() {
printf("Destroying the
game\n");
}
/*accept a letter for which column of the game we are going to drop a disc into. Valid letters are A-G (7 columns). You should designate a letter for “Quit the game”. Input must be returned from this function*/
char AcceptInput() {
char c;
int valid = 0;
do {
printf("Player %d:\n", playCurrent);
printf("Print a character to pick your column (A - G) or Q to
quit\n");
scanf(" %c", &c);
if (c < 'A' || (c > 'G' && c != 'Q')) printf("Invalid
character. Try again\n");
else break;
} while (1);
return c;
}
/*pass the input data to this function. Since we do not have a “world” right now, choosing “A” is the “winning move”, all other letters make the game continue.*/
void UpdateWorld(char c) {
if (c == 'Q') {
if (playCurrent == P_ONE) {
p1Quit = YES;
gameOver = P_TWO;
} else {
p2Quit = YES;
gameOver = P_ONE;
}
}
if (c == 'A') {
gameOver = playCurrent;
}
playCurrent =
playCurrent == P_ONE ? P_TWO : P_ONE;
}
//Print the result calculated in the state of the world
void DisplayWorld() {
if (p1Quit == YES)
printf("Player 1 quit\n");
if (p2Quit == YES)
printf("Player 2 quit\n");
if (gameOver == GAME)
{
printf("Game is currently in process\n");
} else {
printf("Player %d won\n", gameOver);
}
}
/*call initialization, then loop until a flag is set (game over or a player quit), calling accept input, update and display. Outside of the loop, call teardown.*/
int main() {
Initialization();
while (gameOver == GAME
&& p1Quit == NO && p2Quit == NO) {
char c;
c = AcceptInput();
UpdateWorld(c);
DisplayWorld();
}
Teardown();
return 0;
}
Connect Four is a game that alternates player 1 and player 2. You should keep track of whose turn it is next. Here are the guidelines for building the game.
In: Computer Science
The main purpose of this lab is to reinforce the lectures on code style and documentation.
Make as many improvements to the code style as you can including white space, variable names, etc. (NOTE: do this manually – no automated formatting tools allowed). Comment the file completely.
#include <iostream>
#include <cmath>using namespace std;
const int A_CONSTANT = 3;
void functionA(int a[], int aNumber);
void functionB(int a[], int anotherNumber);
void functionC(const int anArray[], int aNumber);
void functionD(int& sum);
int functionE(double number); void functionF(int n);
int main( ){
int production[A_CONSTANT];
cout << "This program displays a graph showing\n" << "production for each factory in the company.\n";
functionA(production, A_CONSTANT);
functionB(production, A_CONSTANT);
functionC(production, A_CONSTANT);
return 0;}
void functionA(int a[], int aNumber){
for (int someNumber = 1;someNumber <= aNumber; someNumber++)
{ cout << endl << "Enter production data for plant number " << someNumber << endl; functionD(a[someNumber - 1]);}}
void functionD(int& sum){
cout << "Enter number of units produced by each department.\n" << "Append a negative number to the end of the list.\n";
sum = 0; int next;
cin >> next;
while (next >= 0) {
sum = sum + next;
cin >> next; }
cout << "Total = " << sum << endl;
}
void functionB(int a[], int anotherNumber){
for (int index = 0; index < anotherNumber; index++)
a[index] = functionE(a[index]/1000.0);
}
int functionE(double number) {
return static_cast<int>(floor(number + 0.5));
}
void functionC(const int anArray[], int aNumber){
cout << "\nUnits produced in thousands of units:\n";
for (int someNumber = 1; someNumber <= aNumber; someNumber++) {
cout << "Factory #" << someNumber << " ";
functionF(anArray[someNumber - 1]);
cout << endl;
}
}
void functionF(int n) {
for (int count = 1; count <= n; count++) cout << "*";
}
In: Computer Science
Implement a superclass Person. Make two classes, Student and Instructor, that inherit from Person. A person has a name and a year of birth. A student has a major, and an instructor has a salary. Write the class declarations, the constructors, and the methods toString for all classes. Supply a test program that tests these classes and methods.
In: Computer Science
Visual Basic Question :
Sum = 1 + 1/2 + 1/3 + 1/4 + .......
A project which allows the user to enter a number in the Textbox1 and which indicates the number of terms on the Label
e.g. I enter 10 (sum) in the Textbox1 and Label1 indicates 12367 (terms)
I have tried a few days but it does not work... thanks for your help!
dim i, t as integer
for i = 1 to t-1
textbox1 = textbox1 + 1/i
next
Label1 = t
In: Computer Science
Write a programme to read and print your phone number,
your initials and your average.
note:c++
In: Computer Science
Question 1
i) A binary system uses 8-bits to represent an analog value ranging from 120 ounces to 700 ounces, determine the resolution of the system and interprete your result.
ii) Determine the number of bits that would be needed for the above resolution to improve to better than 0.01 ounces per increment. Interpret your results.
iii) Use the binary coded decimal (BCD) representation of integers to represent each of the following integers.
2194
4576
7865
3947
3782
In: Computer Science
Question 12: Please provide tilde (~) for the following expressions:
A) 300N + (3N^5) + (4N^5)*logN
B) (N)^(1/2) + 6 ( NlogN / logN^2 )
C) N^100/ 2^N
D) 1 + 1/N
In: Computer Science
How to compile this code on Visual Studio?
Because it keeps getting me an error when i compile it.
#include<iostream.h>
#include<cio.h>
class Array
{
public:
Array(int=0)//initalise the array with 0 value
Array(const Array &);
~Array();
private:
int size;
int *arr;
bool setvalue(int index,int value);
bool getvalue(int index,int &value);
Array & increment();
int getsize();
void print();
Array &Add(const Array arr);
bool Equal(const Array *arr)const;
Array &removeAt(int index);
Array &insertAt(int index,int value);
}; //End of Array class
void Array::setvalue(int index,int value) //set value for
array
{
i=index;
x=value;
}
void Array::getvalue(int index,int value) //get array element
{
i=index;
x=&value;
}
void Array::getsize() //return the size of the array
{
cout<<arr.size();
}
void Array::print() //display array element
{
cout << x<endl;
}
void Array::Add(int arr[])
{
int i;
for (i = 0; i < 5; i++)
arr[i]++; // this alters values in array in main()
}
void main()
{
Array A;
int arr[5];
cout << "Please Enter " << A.getSize() << " elements for A1 :";
int x;
for (int i = 0; i < A.getSize(); i++)
{
cin >> x;
A.setValue(i, x);
}
Array B(5);
cout << "Please Enter " << B.getSize() << " elements for B : ";
for (int i = 0; i < B.getSize(); i++)
{
cin >> x;
B.setValue(i, x);
}
cout << "Testing copy constrcutor : Array X(A); D = ";
Array X(A);
X.print();
cout << endl;
cout << "I am printing A using getValue assuming that I don't know the size,\nA = ";
int i = 0;
while (A.getValue(i, x))
{
cout << x << " ";
i++;
}
cout << "\nArray C = A.increment(), printing (using A.print()) A and C after the function call\nA = ";
Array C = A.increment();
A.print();
cout << "\nC = ";
C.print();
cout << "\nA.Equal(C) = " << A.Equal(&C) << endl;
cout << "A.Equal(B) = " << A.Equal(&B) << endl;
cout << "Array D = A.Add(B) = ";
Array D = A.Add(B);
D.print();
cout << "\nA is ";
A.print();
cout << "\nB is ";
B.print();
cout << endl;
cout << "Inserting 99 at index 99999 in A, the result is :\n";
A.insertAt(99999, 99);
A.print();
cout << endl;
cout << "Inserting -99 at index -99999 in A, the result is :\n";
A.insertAt(-99999, -99);
A.print();
cout << endl;
cout << "Inserting 7 at index 3 in A, the result is :\n";
A.insertAt(3, 7);
A.print();
cout << endl;
cout << "Deleting the element at index 2 from A, the result is :\n";
A.removeAt(2);
A.print();
cout << endl;
getch();
}
In: Computer Science
Create a program that reports whether each word in a set of words appears in a paragraph. Here are the requirements: a. Ask the user to enter a set of words, one at a time. Use an appropriate prompt to keep asking for words until a blank line is entered. The set of words should be in a dictionary, where the word is the key, and “yes” or “no” is the value. The value represents whether the word appears in the paragraph. As the words are entered, the value should initially be “no”. b. Ask the user to enter a paragraph. Use an appropriate prompt to keep asking for lines/sentences of the paragraph. The lines/sentences should be in a list (of strings). When the user enters a blank line, the paragraph is complete. c. Once the paragraph is entered, check to see if each word in the dictionary is in the paragraph. If it is, then set the value of that key (word) to “yes”. It is sufficient to determine if the word is in the paragraph. You do not need to find all instances, nor count the number of instances. d. Present the results by writing the results of the dictionary using a loop. (Do not simply print the dictionary as a whole.) This should appear as two columns of data, with the key in the first column, and the corresponding value of “yes” or “no” in the second column.
In: Computer Science
In two paragraph, explain the hierarchical structure of a system that you have worked on and how emergence affects the levels in the systems hierarchy. Provide details and apply what you learned here to discuss what (if any) changes you would have done, if you have to do it all over again.
In: Computer Science
Describe how DDoS attacks may be mounted against TCP and UDP services. In what way will being connection oriented be different for TCP and UDP?
In: Computer Science
Using the below given ASCII table (lowercase letters) convert the sentence “welcome to cci college” into binary values.
|
a - 97 |
b - 98 |
c - 99 |
d - 100 |
e - 101 |
f - 102 |
g - 103 |
h - 104 |
i - 105 |
|
j - 106 |
k - 107 |
l - 108 |
m - 109 |
n - 110 |
o - 111 |
p - 112 |
q - 113 |
r -114 |
|
s -115 |
t - 116 |
u - 117 |
v - 118 |
w - 119 |
x - 120 |
y - 121 |
z - 122 |
Space - 32 |
In: Computer Science
Write LMC assembly code that prints the minimum of two numbers.
HINT: use and extend the table below for your solution.
|
Mailbox |
Mnemonic |
Code |
Instruction description |
In: Computer Science