In the computer game Civilization, a character representing a world leader who advocates non-violence is uncharacteristically aggressive. In the first version of the game, this was an unintentional effect caused by a bug.
In the game, world leader characters are assigned an ‘aggression’ score and this is increased or decreased according to changes in circumstance. For example, if a leader adopts democracy, their aggression score is decreased by 2.
This particular world leader was given the lowest possible aggression of 1 by the game makers, to reflect that they thought the leader was unlikely to declare war on another character.
Given that the aggression score is stored as an 8-bit unsigned integer representation, do the following:
In: Computer Science
Textbook: Starting out with Python (3rd or 4the Edition)
Question: Programming Exercise # 9 - Trivia Question
In this programming exercise, you will create a simple trivia
game for two players. The program
will work like this:
Starting with player 1, each player gets a turn at answering 5
trivia questions. (There
should be a total of 10 questions.) When a question is displayed, 4
possible answers are
also displayed. Only one of the answers is correct, and if the
player selects the correct
answer, he or she earns a point.
After answers have been selected for all the questions, the program
displays the number of
points earned by each player and declares the player with the
highest number of points the
winner.
To create this program, write a Question class to hold the data
for a trivia question. The
Question class should have attributes for the following data:
A trivia question
Possible answer 1
Possible answer 2
Possible answer 3
Possible answer 4
The number of the correct answer (1, 2, 3, or 4)
The Question class also should have an appropriate _ _init_ _
method, accessors, and mutators.
The program should have a list or a dictionary containing 10
Question objects, one for each
trivia question. Make up your own trivia questions on the subject
or subjects of your choice for
the objects.
In: Computer Science
Why must you keep the back-up copy of your keyring files in a safe place?
In: Computer Science
Given the following attributes in a project management:
Discuss in detail each of them and on how would you use them as the IT manager for the company. Provide a details information support your discussion.
In: Computer Science
Use MIPS write an assembly program which asks the user to enter
3 number. The program
then sorts these numbers, the prints them from largest to
smallest.
In: Computer Science
The answer should be in JAVA.
You will design and implement two classes to support a client
program, RockPaperScissorsGame.java, to simulate
Rock-Paper-Scissors game.
Read and understand the client program to find out the requirements
for the HandShape and Player classes.
The rules of the Rock-Paper-Scissors game are:
Scissors✌️ beats Paper✋ that beats Rock✊ that
beats Scissors✌️
Additionally, to simplify the game logic (and complexify a little
bit the HandSahpe class) , two players cannot show the same hand
shape.
The followings are some sample runs:
$java RockPaperScissorsGame
Alice shows Paper
Bob shows Scissors
Bob wins!
$java RockPaperScissorsGame
Alice shows Paper
Bob shows Rock
Alice wins!
$java RockPaperScissorsGame
Alice shows Scissors
Bob shows Rock
Bob wins!
RockPaperScissorsGame.java
public class RockPaperScissorsGame {
public static void main(String[] args) {
String[] handShapeName = {"Rock", "Paper", "Scissors"};
HandShape handShape = new HandShape();
Player player1 = new Player("Alice");
Player player2 = new Player("Bob");
System.out.println(player1.getName() + " shows " + handShapeName[player1.showHand(handShape)]);
System.out.println(player2.getName() + " shows " + handShapeName[player2.showHand(handShape)]);
System.out.println(player1.findWinner(player2) + " wins!");
}
}In: Computer Science
Suppose that we throw balls into m bins until some bin contains
two balls. Each throw
is independent, and each ball is equally likely to end up in any
bin. What is the expected number of
ball throwed?
In: Computer Science
c++
How do I get numbers and words before I press the enter?
For example, if i type cat 12 Rabbit 27 and then click enter, i want to stop receiving input.
In: Computer Science
Based on the below information, describe everything that can be determined about this packet (give the actual data value for each field). Convert each field to its normally displayed value (i.e. Hexadecimal/Decimal/Binary). Example: Version is 4 which is IPv4 IP Datagram Header:
45 00 00 44 5b d2 00 00 80 11 ef 4d 8 3 b7 75 39 83 b7 72 e1
In: Computer Science
I am currently working on an HOME AUTOMATION PROJECT(((that
which controls home appliances via web/Google
Assistant/application..
My question is HOW CAN SUCH PROJECT BE IMPROVED..
And also HOW CAN IT BE MADE DIFFERENT from series of such projects
on the web..
I need 4-5 ideas on HOW TO DISTINGUISH MY
OWN from others..
TECHNICALITY OF THE HIGHEST ORDER IS DEMANDED IN THE ANSWERS
In: Computer Science
Instructions (No array) (c++) (visual studio)
1. Create a project called Project3B
2. Create 3 String variables called name1, name2, name3
3. Create 9 double variables called test1_1, test1_2, test1_3,
test2_1, test2_2, test2_3, test3_1, test3_2, test3_3
4. Create 3 double variables called average1, average2,
average3
To calculate the average score = (test1 + test2 + test3) /
3.0
5. Run the program with the following data using cin
name1 = “Tom”, name2 = “Mary”, name3 = “Ali”
test1_1 = 81.4, test1_2 = 92.1, test1_3 = 75.5
test2_1 = 98.7, test2_2 = 93.5, test2_3 = 90.1
test3_1 = 64.2, test3_2 = 75.8, test3_3 = 78.4
6. Display the output using cout and setw()
In: Computer Science
Define spatial and temporal locality. Consider the following code:
for (i=0; i < 50; i++)
for (j =0; j < 30; j++)
a[i] = a[i] * j;
b. Give an example of temporal locality in the above code.
In: Computer Science
In: Computer Science
Consider a simple system with 8-bit block size. Assume the encryption (and decryption) to be a simple XOR of the key with the input. In other words, to encrypt x with k we simply perform x⊕k giving y. Similarly, to decrypt y, we perform y⊕k giving x.
You are given the following 16-bit input 1A2Bin hexadecimal. You are provided IV as 9D in hexadecimal. The key to be used (where appropriate) is 7C in hexadecimal. Compute the encrypted output with the following methods. Express your final answer, for each of them, as 4 hexadecimal characters so it is easy to read.
A. ECB
B. CBC
C. OFB
D. CFB
In: Computer Science
Assignment
Examine the Main and Address classes. You are going to add two classes derived from Address: BusinessAddress and PersonAddress.
Create BusinessAddress class
The printLabel method should print (using System.out.println())
First line – the businessName field
Second line – the address2 field if it is not null or empty
Third line – the StreetAddress field if it is not null or empty
Fourth line – city field followed by a comma and space, the state field followed by two spaces, and the zip field
Create PersonAddress class
The printLabel method should print (using System.out.println())
First line – the personName field
Second line – the StreetAddress field
Third line – city field followed by a comma and space, the state field followed by two spaces, and the zip field
Modify Main class
Add the following three BusinessAddress objects to the list.
|
BusinessName |
Address2 |
StreetAddress |
City |
State |
Zip |
|
Columbus State |
Eibling 302B |
550 East Spring St. |
Columbus |
OH |
43215 |
|
AEP |
P.O. Box 2075 |
null |
Columbus |
OH |
43201 |
|
Bill’s Coffee |
null |
2079 N. Main St. |
Columbus |
OH |
43227 |
Add the following three PersonAddress objects to the list.
|
PersonName |
StreetAddress |
City |
State |
Zip |
|
Saul Goodman |
1200 N. Fourth St. |
Worthington |
OH |
43217 |
|
Mike Ehrmentraut |
207 Main St. |
Reynoldsburg |
OH |
43211 |
|
Gustavo Fring |
2091 Elm St. |
Pickerington |
OH |
43191 |
Example Output
Columbus State
Eibling 302B
550 East Spring St.
Columbus, OH 43215
====================
AEP
P.O. Box 2075
Columbus, OH 43201
====================
Bill's Coffee
2079 N. Main St.
Columbus, OH 43227
====================
Saul Goodman
1200 N. Fourth St.
Worthington, OH 43217
====================
Mike Ehrmentraut
207 Main St.
Reynoldsburg, OH 43211
====================
Gustavo Fring
2091 Elm St.
Pickerington, OH 43191
====================
My code
package home;
public class Main {
public static void main(String[] args) {
Address[] addressList = new Address[6];
// TODO Add 3 person addresses to list
addressList[3] = new PersonAddress("1200 N. Fourth St.","Worthington","OH","43217","Saul Goodman");
addressList[4] = new PersonAddress("207 Main St.","Reynoldsburg","OH","43217","Mike Ehrmentraut");
addressList[5] = new PersonAddress("2091 Elm St.","Pickerington","OH","43191","Gustavo Fring");
// TODO Add 3 business address to list
addressList[0] = new BusinessAddress("550 East Spring St.","Columbus","OH","43215","Columbus State","Eibling 302B");
addressList[1] = new BusinessAddress(null,"Columbus","OH","43201","AEP","P.O. Box 2075");
addressList[2] = new BusinessAddress("2079 N. Main St.","Columbus","OH","43227","Bill’s Coffee",null);
for (Address address : addressList) {
address.printLabel();
System.out.println("====================");
}
}
}
package home;
public class BusinessAddress extends Address {
// two private String fields businessName and address2
private String businessName;
private String address2;
//Constructor
public BusinessAddress(String streetAddress, String city, String state, String zip, String businessName, String address2) {
super(streetAddress, city, state, zip);
this.businessName = businessName;
this.address2 = address2;
}
//getters and setters
public String getBusinessName() {
return businessName;
}
public void setBusinessName(String businessName) {
this.businessName = businessName;
}
public String getAddress2() {
return address2;
}
public void setAddress2(String address2) {
this.address2 = address2;
}
@Override
public void printLabel() {
String result ="";
if(address2==null)
result = businessName+"\n"+super.toString();
else
result = businessName+"\n"+address2+"\n"+super.toString();
System.out.println(result);
}
}
}
package home;
public class PersonAddress extends Address {
private String personName;
//Constructor
public PersonAddress(String streetAddress, String city, String state, String zip, String personName) {
super(streetAddress, city, state, zip);
this.personName = personName;
}
//getter and setter
public String getPersonName() {
return personName;
}
public void setPersonName(String personName) {
this.personName = personName;
}
@Override
public void printLabel() {
System.out.println(personName+"\n"+super.toString());
}
}
package home;
public abstract class Address {
private String streetAddress;
private String city;
private String state;
private String zip;
public Address(String streetAddress, String city, String state, String zip) {
this.streetAddress = streetAddress;
this.city = city;
this.state = state;
this.zip = zip;
}
public String getStreetAddress() {
return streetAddress;
}
public void setStreetAddress(String streetAddress) {
this.streetAddress = streetAddress;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getZip() {
return zip;
}
public void setZip(String zip) {
this.zip = zip;
}
public String toString() {
return streetAddress + "\n" +
city + ", " + state + " " + zip + "\n";
}
public abstract void printLabel();
}In: Computer Science