Questions
PYTHON PROGRAM Buzz Lightyear is teaching his friends about money. At the moment, they are using...

PYTHON PROGRAM

Buzz Lightyear is teaching his friends about money. At the moment, they are using fictional $ 5, 10, and 20 Monopoly game bills. Buzz hands out the bills to his friends so that they each have the same amount of money. Then he moves the bills from one friend's pile and puts it on another's pile. Next, the toys have to figure out which one has more money and which one has less.
Sometimes Buzz doesn't move a bill so everyone has exactly the same amount of money; toys should know when this happens.

Input Format:
The first line of each scenario consists of a positive integer, N, which represents the number of toys (2 <N <= 100). Each of the next N lines contains the data for a toy. The lines contain four items, the name of the toy (a single series of 2-10 letters, lowercase except the first) followed by the number of $ 5, 10, and 20 bills (in that order) assigned to that toy. The elements are separated by single spaces. The input ends in a scenario where N equals -1. This scenario should not be processed.

Constraints:
toys (2 <N <= 100)

Output Format:
The output consists of one line for each scenario. It will be in one of the following two formats:

X has more money, Z has less money.
They all have the same amount.
X and Z are names of toys.

In: Computer Science

Do the following lab by while or Do-while loop. question: Write a c++ program that asks...

Do the following lab by while or Do-while loop.

question: Write a c++ program that asks students to enter 3 valid grades and then calculate the average and print it. if the user enters the invalid grade you should print the error message and get the new grade.

Hint1: each time your program ask the following question: "Do you want to calculate another average?" and if the answer to this question is "Y" or "y" then you should continue.

Hint2: this class at least has one student.

In: Computer Science

With being given two n-bit binary strings, verify if the strings are identical or not. Design...

With being given two n-bit binary strings, verify if the strings are identical or not. Design a procedure showing all steps and write a pseudo-code. What is the complexity of the procedure? If it can tolerate some error, is there a better than linear time solution? If so, write the pseudo-code.

In: Computer Science

Write in java The submission utility will test your code against a different input than the...

Write in java

The submission utility will test your code against a different input than the sample given.

When you're finished, upload all of your .java files to Blackboard.

Grading:

Each problem will be graded as follows:

0 pts: no submission

1 pts: submitted, but didn't compile

2 pts: compiled, but didn't produce the right output

5 pts: compiled and produced the right output

Problem 1: "Letter index"

Write a program that inputs a word and an unknown number of indices and prints the letters of the word corresponding to those indices. If the index is greater than the length of the word, you should break from your loop

Sample input:

apple 0 3 20

                  

Sample output:

a

l

Problem 2: "Matching letters"

Write a program that compares two words to see if any of their letters appear at the same index. Assume the words are of equal length and both in lower case. For example, in the sample below, a and e appear in both words at the same index.

Sample input:

apple andre

Sample output

a

e

Problem 3: "Word count"

You are given a series of lowercase words separated by spaces and ending with a . , all one on line. You are also given, on the first line, a word to look up. You should print out how many times that word occured in the first line.

Sample input:

is

computer science is no more about computers than astronomy is about telescopes .

Sample output:

2

Problem 4: "Treasure Chest"

The input to your program is a drawing of a bucket of jewels. Diamonds are represented as @, gold coins as $, rubies as *.   Your program should output the total value in the bucket, assuming diamonds go for $1000, gold coins for $500, and rubies for $300. Note that the bucket may be wider or higher than the bucket in the example below.

Sample input:

|@* @ |

| *@@*|

|* $* |

|$$$* |

| *$@*|

-------

Sample output:

$9900

Problem 5: “Speed Camera”

Speed cameras are devices that monitor traffic and automatically issue tickets to cars going above the speed limit.   They work by comparing two pictures of a car at a known time interval. If the car has traveled more than a set distance in that time, the car is given a citation.

The input are two text representations of a traffic picture with a car labeled as letters “c” (the car is moving upwards. These two pictures are shot exactly 1 second apart. Each row is 1/50 of a mile. The car is fined $10 for each mile per hour over 30 mph, rounded down to the nearest mph. Print the fine amount.

Sample input:

|.|

|.|

|.|

|.|

|c|

---

|.|

|c|

|.|

|.|

|.|

Sample output:

$1860

Problem 6. Distance from the science building

According to Google Maps, the DMF science building is at GPS coordinate 41.985 latitude, -70.966 longitude. Write a program that will read somebody’s GPS coordinate and tell whether that coordinate is within one-and-a-half miles of the science building or not.

Sample input:

-70.994

41.982

Sample output:

yes

At our position, 1 1/2 miles is about .030 degrees longitude, but about .022 degrees latitude. That means that you should calculate it as an ellipse, with the east and west going from -70.936 to -70.996, and the north and south going from 41.963 to 42.007.

Hint: Use the built in Ellipse2D.Double class. Construct a Ellipse2D.Double object using the coordinates given, and then use its "contains" method.

Problem 7: "Palindrome Numbers"

A palindrome is a word that reads the same forwards and backwards, such as, for example, "racecar", "dad", and "I". A palindrome number is the same idea, but applied to digits of a number. For example 1, 121, 95159 would be considered palindrome numbers.

The input to your program are two integers start and end. The output: all of the palindrome numbers between start and end (inclusive), each on a new line.

Sample input:

8 37

Sample output:

8

9

11

22

33

Hints:

1. Start by writing and testing a function that takes a number and returns true/false if the number is a palindrome. Then call that function in a for loop.

2. To see if a number is a palindrome, try turning it into a string. Then use charAt to compare the first and last digits, and so on.

In: Computer Science

Discuss a few technological innovations of recent years that increased the comfort of human lives creating...

Discuss a few technological innovations of recent years that increased the comfort of human lives creating successful business ventures (hint: transportation/accommodation/taxi /telecommunication products/food delivery services).

In: Computer Science

(C++)Put a new integer 1 at the second position of the vector. vec will now look...

(C++)Put a new integer 1 at the second position of the vector. vec will now look like this.

  9 1 0 6 9 10 12 15 20 25 30 80

Your code: ___________________

int bmwOne(vector<int> & myVec)

{ int value = myVec.at(0);
for (auto & x: myVec) {

if (x < value) {

value = x; }

}

return value;

}

Explain the code of bmwOne. What is it doing?

If the function is called from the code below, what will be the output? Write down the full output of this code.

int main(int argc, const char * argv[]) {

vector<int> myVec = {25,15, 20, 11, 3, 10, 6};

cout << "output is: " << mysteryOne(myVec);

return 0;

}

In: Computer Science

The argument in the following scenario was invalid. Discuss the logical fallacies that apply to the...

The argument in the following scenario was invalid. Discuss the logical fallacies that apply to the reasoning and why they matter in light of the scenario

You are engaged in an intense discussion with your friend, Bill, who works in the IT department at your university. Bill complains that many students are using P2P (peer-to-peer) file-sharing applications on the university’s network to download excessive amounts of unauthorized copyrighted material. He also claims that the most effective solution to this problem would be to disable student access to all (existing) P2P sites and to prevent students at your institution from setting up their own P2P sites for any reason whatsoever (even to include noncopyrighted material). You convey to Bill your belief that this measure is too drastic. However, Bill argues that the only way to eliminate unauthorized file sharing among students at your institution is to disable access to all P2P software on the university’s network.

In: Computer Science

What is the “logical malleability” of software as both a product and a service? Explain at...

What is the “logical malleability” of software as both a product and a service? Explain at least four “conceptual muddles” this state of affairs creates for upholding ethical frameworks. Include three specific cases and examples from the book or recent current events

In: Computer Science

Java programming language Array - Single identifier which can store multiple values Example initialized with values:...

Java programming language

Array - Single identifier which can store multiple values

Example initialized with values: int[] mySimpleArray = {4, 17, 99};

Example with fixed length but no values: int[] myFixedArray = new int[11];

The brackets identify the index. Each value has its own index number.
NOTE: First element is the zeroth element: mySimpleArray[0] is 4, [1] is 17

Make a new Netbeans project called ArraysAndLoops

Create the simple array with 4, 17, 99.

Use System.out.println with the variable with index literals to print out each value.

MORE LOOPS - Computing factorials

Show how factorial algorithm works, use FOR loop for factorials 0 to 10

Use i as index to store each factorial in an array

Use method Array.toString(myFactorials) to print out array at each step to check

          NOTE: requires import java.util.*

WRITING A FILE - requires import java.io.*

Step 1: Make an object for file output

Step 2: Use object, method println(...)

In-Class Active: Print the factorials array to a .txt file

          PrintWriter objectName = new PrintWriter(file path.filename);

Apply that structure to the array already made; use objectName factorialsTest

          Make a header statement for the first line of the file:

                   factorialsTest.println("Factorials 0 to 10");

Make the next line the array with all its values:

          factorialsTest.println(Arrays.toString(myFactorials));

These println method put the Strings in a buffer. Write to actual file by closing object.

          factorialsTest.close();

If time, print out all the array values using a FOR loop, System.out

In: Computer Science

Python pls 1. The function only allow having one return statement. Any other statements are not...

Python pls

1. The function only allow having one return statement. Any other statements are not allowed. You only have to have exactly one return statement.

For example

the answer should be

def hello(thatman):

return thatman * thatman

1. Create a function search_wholo function. This function returns a list of 2 tuples, which people and their excitement skills, and sorted by decreasing excitement level(highest excitement skill first). If two people have the same excitement level, they should appear alphabetically. The list includes people who have the same hobby as an argument, and greater than or equal to the excitement level(which argument also).

For example

database = {'Dio': {'Lottery': 2, 'Chess': 4, 'Game': 3},'Baily': {'Game': 2, 'Tube': 1, 'Chess': 3}, 'Chico': {'Punch': 2, 'Chess': 5}, 'Aaron': {'Chess': 4, 'Tube': 2, 'Baseball': 1}}

def search_wholo(database, hobby:str, num: int):

# ONLY ONE STATEMENT ALLOWED (RETURN STATEMENT)

search_wholo(database, 'Chess',4) -> [('Chico', 5),('Aaron', 4), ('Dio',4)]

search_wholo(database, 'Game',0) -> [('Dio', 3), ('Baily', 2)]

search_wholo(database, 'Tube',3) -> [] #because all people's excitement skill for tube is lower than 3

search_wholo(database, 'Gardening',3) -> [] #because there is no "gardening" hobby in the dictionary

In: Computer Science

2-D bit parity is generated by placing the data bits in a matrix form as shown...

2-D bit parity is generated by placing the data bits in a matrix form as shown below. Then, a parity bit is computed for every row and every column: These parity bits are shown in grey. Assume that even parity is used (as shown below). Assume throughout that the receiver is guaranteed that no more than 2 errors are possible.

1 0 1 0 1 1

1 1 1 1 0 0

0 1 1 1 0 1

0 0 1 0 1 0

(a) Show that any 2-bit errors in data can be detected.

(b) What type of bit errors can go undetected? Explain with an example. (Hint: Think beyond 2 bit errors)

(c) What happens when a parity bit is erroneous? Flip the parity bit corresponding to the third row and explain what will happen.

In: Computer Science

Create method addUserInput Write a method called addUserInput(). The method should ask the user to input...

Create method addUserInput

Write a method called addUserInput().

The method should ask the user to input two integers (one by one), add the two integers, and return the sum.

By using java.util.Scanner to get user input;

The method may not compile due to Scanner Class which need to add a "throws" statement onto the end of the method header because some lines may throw exceptions

Refer to the Java API documentation on Scanner to figure out which specific Exception should be thrown from your method - do not add “throws Exception”.

I only want the addUserInput() method to write out in code with a specific Exception it needs in the method. In Java, it would be appreciated thanks.

In: Computer Science

Name at least five benefits and five pitfalls associated with RFID technologies in the context of...

Name at least five benefits and five pitfalls associated with RFID technologies in the context of privacy debates. Be sure to explain and specify examples.

In: Computer Science

Using Maven and Web Programming Basics 1. Build a program using maven 75 pts A. Create...

Using Maven and Web Programming Basics

1. Build a program using maven 75 pts

A. Create file structure

Create a file structure for your program like the following:

web_app
→ src
→ main
→ java
→ resources
→ webapp
→ target

make sure you have in src/main/ the directories java, resources, and webapp.

In most Java IDEs (Eclipse, IntelliJ, etc.) you can make a maven project, which will have this structure by default (without the webapp directory), you can use that IDE tools then add the webapp directory.

B. Make pom.xml

Apache maven is a build automation tool that can compile and build your program as well as download any .jar dependencies you need. I’ll provide you with a pom.xml file with the parameters set to download the .jar files you need to make a web server in java. Put this file at the top level of your program file structure (same level as the the src and target directories). To verify you examined the file, change the value in the <name> tag from YOUR_WEB_APP to the name of your program. You can see all the jar files that are needed in <dependencies> and where the program is named in

<build>
<plugin>

<programs>

<program>

the file that sets up the tomcat program is in webDriver.Main (which I will describe later) and the program name is web (if you are doing the extra credit don’t change this)

C. Add tomcat driver

For this program we’ll be using the Apache Tomcat web framework (another popular one for java is Glassfish). In IDE you can use the Web Application projects to form your web program, but for this class I want you to build the web app driver so you can more easily publish your software and so you can see what is need to make a java web server.

To start make a package in src/main/java called webDriver (same as the name above), then add the provided Main.java file into that package (web_app/src/main/java/webDriver). If you see errors in your IDE your package names do not match (package webDriver) or you set up the pom.xml file incorrectly. Otherwise it should not have any errors. This class when run talks to the operating system to make your computer into a web server.

D. Create web.xml file

To help out your web server with some piping of traffic you need to setup a web.xml file. In your src/main/webapp directory create a folder called WEB-INF. In there put the provided web.xml file. This file helps direct traffic for the server, but it’s really simple for this homework, but we’ll build on it, in later assignments. To verify you have looked at the file, change the <display-name> value in the file, to your program name. The <welcome-file-list> gives the search order for the server’s default landing page.

E. Generate index.html

Finally you should have a working server to check if it works put an index.html page in src/main/webapp. I provided one, but you can put your own one in there.

To test if everything work, you’ll need to build the maven package. For windows users, open powershell or cmd, osX users open console, and terminal for Linux users, navigate to your project and type
mvn package

you should get a bunch of messages where the last five lines are similar to:

[INFO] ------------------------------------------------------------------------

[INFO] BUILD SUCCESS

[INFO] ------------------------------------------------------------------------

[INFO] Total time: 1.862 s

[INFO] Finished at: 2020-01-12T13:01:55-07:00

[INFO] ------------------------------------------------------------------------

In: Computer Science

Assignment #3 – Geometry Calculator Assignment Objectives Task #1 void Methods 1. Name the program file...

Assignment #3 – Geometry Calculator Assignment Objectives

Task #1 void Methods 1. Name the program file Geometry.java. This program will compile, but, when you run it, it doesn’t appear to do anything except wait. That is because it is waiting for user input, but the user doesn’t have the menu to choose from yet. We will need to create it.

2. Below the main method, but in the Geometry class,create a static method called printMenu that has no parameter list and does not return a value. It will simply print out instructions for the user with a menu of options for the user to choose from. The menu should appear to the user as: This is a geometry calculator Choose what you would like to calculate

1. Find the area of a circle

2. Find the area of a rectangle

3. Find the area of a triangle

4. Find the circumference of a circle

5. Find the perimeter of a rectangle

6. Find the perimeter of a triangle Enter the number of your choice:

3. Add a line in the main method that calls the printMenu method as indicated by the comments.

4. Compile, debug, and run. You should be able to choose any option, but you will always get 0 for the answer. We will fix this in the next task any times as needed without rewriting the code each time.

Task #2 Value-Returning Methods

1. Write a static method called circleArea that takes in the radius of the circle and returns the area using the formula A = π r power 2.

2. Write a static method called rectangleArea that takes in the length and width of the rectangle and returns the area using the formula A = lw.

3. Write a static method called triangleArea that takes in the base and height of the triangle and returns the area using the formula A = ½bh.

4. Write a static method called circleCircumference that takes in the radius of the circle and returns the circumference using the formula C = 2πr.

5. Write a static method called rectanglePerimeter that takes in the length and the width of the rectangle and returns the perimeter of the rectangle using the formula P = 2l +2w.

6. Write a static method called trianglePerimeter that takes in the lengths of the three sides of the triangle and returns the perimeter of the triangle which is calculated by adding up the three sides.

Task #3 Calling Methods

1. Add lines in the main method in the GeometryDemo class which will call these methods.

2. Write some sample data and hand calculated results for you to test all 6 menu items.

3. Compile, debug, and run. Test out the program using your sample data.

In: Computer Science