Questions
Ruby programming Create a Ruby program which reads numbers, deposits them into an array and then...

Ruby programming

Create a Ruby program which reads numbers, deposits them into an array and then calculates the arithmetic mean (otherwise known as the average), the median (that is, the number that splits the set of value in half with half being above and half being below the number), and the standard deviation (that is, the average of distance each number is from the mean then squared). Further information about these calculations can be found here:

average: http://en.wikipedia.org/wiki/Average
(add up all the numbers in the set and divide that total by the quantity of values in the set)

median: http://en.wikipedia.org/wiki/Median
(for a set that holds an odd number of values, sort the numbers in the set and then take the value in the middle of the set. for a set that holds an even number of values, sort the numbers in the set and find the average of the two values in the middle of the set).

standard deviation: http://en.wikipedia.org/wiki/Standard_deviation
(find the average of the set. for each value in the set, calculate the difference between each value and the average. square each of these difference. find the average of these squared differences. take the square root of this average).

IN ORDER TO RECEIVE FULL CREDIT, YOUR CODE SHOULD PROPERLY READ VALUES, STORE THEM IN AN ARRAY AND MANIPULATE THE ARRAY TO ARRIVE AT THE DESIRED CALCULATIONS.

Hint : In order to have Ruby calculate the square root of a numeric value named i, please say squareRootOfI = Math::sqrt( i )

A number of different program dialogues describe the program I am looking for.

Math Calculator
[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: N
2 4 4 4 5 5 7 9
[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: A
Average = 5.0
[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: M
Median = 4.5
N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: S
Standard Deviation = 2.0
[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: C
[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: N
4 4 4 6

[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: N
6 3 1

[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: A
Average = 4.0
[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: M
Median = 4
[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: S
Standard Deviation = 1.603
[N]umbers [A]verage [M]edian [S]tandard Deviation [C]lear [Q]uit: Q

In: Computer Science

Weight Lifting Make a dictionary where the keys are the names of weight lifting exercises, and...

Weight Lifting Make a dictionary where the keys are the names of weight lifting exercises, and the values are the number of times you did that exercise.(At least 5 exercises,be creative. Nobody should have same values)

Use a for loop to print out a series of statements such as "I did 10 bench presses". Modify one of the values in your dictionary, to represent doing more of that exercise. Use a for loop to print out a series of statements such as "I did 10 bench presses". Add a new key-value pair to your dictionary. Use a for loop to print out a series of statements such as "I did 10 bench presses". Remove one of the key-value pairs from your dictionary. Use a for loop to print out a series of statements such as "I did 10 bench presses". Use a function to do all of the looping and printing in this problem.

In: Computer Science

Your code needs to do the following: Create a function called pigLatin that accepts a string...

Your code needs to do the following:

  1. Create a function called pigLatin that accepts a string of English words in the parameter sentence and returns a string of those words translated into Pig Latin. English is translated to Pig Latin by taking the first letter of every word, moving it to the end of the word and adding ‘ay’. For example the sentence “The quick brown fox” becomes “hetay uickqay rownbay oxfay”. You may assume the words in the parameter sentence are separated by a space.
  2. Print the original sentence.
  3. Print the Pig Latin sentence
  4. Use the computeScrabbleScore function, developed earlier, to produce a list of tuples of the Pig Latin words and their associated Scrabble scores.
  5. Print the list of Pig Latin tuples.

def pigLatin(sentence):
# Write your code below
return

# Use the variable below to test
sentence = 'The quick brown fox jumps over the lazy dog'
# write your code below

In: Computer Science

Given the following relations: PARTS(Pno, Pname, Qoh, Price, Olevel) CUSTOMERS(Cno, Cname, Street, Zip, Phone) EMPLOYEES(Eno, Ename,...

Given the following relations:

PARTS(Pno, Pname, Qoh, Price, Olevel)
CUSTOMERS(Cno, Cname, Street, Zip, Phone)
EMPLOYEES(Eno, Ename, Zip, Hdate)
ZIP_CODES(Zip, City, State)
ORDERS(Ono, Cno, Eno, Received, Shipped)
ODETAILS(Ono, Pno, Qty)

Where Qoh stands for quantity on hand and Olevel stands for (re)order Level. The P, C, E and O single letter prefixes for attributes refer to the parts, customers, employees and orders relations, respectively.

a. Retrieve the names of customers who have ordered parts costing less than $150.00.

b. Retrieve the names of customers and the Pname of orders with a qty greater than 10.

For the above queries, draw an initial relational algebra query tree then transform the initial query tree created into a more efficient form using heuristic rules. Show your optimization one step at a time and explain the rationale of each optimization.

In: Computer Science

This is to be done using JAVA Create a Madlib bean. The bean should have several...

This is to be done using JAVA

Create a Madlib bean. The bean should have several string properties and the text of the Madlib can be hardcoded. The bean should have a toString() method that outputs the text of the Madlib with the values of the properties inserted. For an additional challenge, make the text of the Madlib a property and pass an ArrayList of String arguments.

MadLib: My ______ (animal) lives in _______(place).

In: Computer Science

Create a Guess the Number game. Python randomly chooses a secret four-digit number (with no repeating...

Create a Guess the Number game.

  • Python randomly chooses a secret four-digit number (with no repeating digits) and asks the user to guess it.
  • The user has up to ten attempts to guess the number. After each guess, Python gives the user two clues (until the user either guesses the number correctly or runs out of attempts):
    • The number of digit(s) in the user’s guess that is (are) both correct and in the right position.
    • The number of digit(s) in the user’s guess that is (are) correct but in the wrong position.
      • For example, say the secret number is 0123.
        • If the user’s guess is 4567, the clues will be:
          • Right digit and position: 0
          • Right digit but wrong position: 0
        • If the user’s guess is 1023, the clues will be:
          • Right digit and position: 2
          • Right digit but wrong position: 2
  • If the user guesses the correct number within his/her ten attempts, the game will finish.
  • If the user fails to guess the correct number within his/her ten attempts, the number will be shown and the game will finish.
  • When the game finishes (i.e., whether the user guesses the correct number or fails to do so in ten attempts), Python asks the user whether he/she wants to continue playing.
    • If the user enters “Y” he/she will play another round. If the user enters “N” the game will end
  • PLEASE USE LOW-LEVEL PYTHON LANGUAGE SUCH AS WHILE LOOP OR IF ELSE ARGUMENTS, TRY NOT TO MAKE IT TOO ADVANCED

In: Computer Science

Python Program Write a program that will ask a user on how many input colored balls...

Python Program

Write a program that will ask a user on how many input colored balls of the following codes: R-red, B-blue, W-white, G-green and O-orange -will he or she would like to enter in the program and print the total number of Red balls were encountered. Assume an uppercase and lower case letter will be accepted.

In: Computer Science

Consider the following header file for the intArray object and the following main.cpp and answer the...

Consider the following header file for the intArray object and the following main.cpp and answer the following questions:

intArray.h

main.cpp

#include <iostream>

using namespace std;

class intArray

{

friend ostream& operator<<(ostream& outStream, intArray& rhs);

public:

    intArray();

    intArray(int _size);

    intArray(int _size, int array[]);

    intArray(const intArray&);

    ~intArray();

    void Print();

    void PrintSize();

    int Size() const;

    int operator[](int) const;

    intArray operator=(const intArray );

private:

    int size;

    int *data;

};

7 #include <iostream>
8 #include <cstdlib>
9 #include "intArray.h"
10
11 using namespace std;
12
13 /*
14 *
15 */
16 int main(int argc, char** argv) {
17
18     intArray Array1(5, 1);
19     intArray Array2(5, 2);
20     intArray Array3;
21    
22     Array3 = Array1 + Array2;
23     Array3 = Array1 + 5;
24     Array3 = 6 + Array1;

25    
26    
27     return 0;
28 }

Give the only prototype for the overloaded + operators as shown in lines 22, 23 and 24. Make sure all are cascade capable to allow the assignment to Array3.

In: Computer Science

You are a Software QA Professional and are now interviewing at Google for your next job....

You are a Software QA Professional and are now interviewing at Google for your next job. While in the interview, the QA Manager taking your interview asks you the following question: “Let’s say you log a bug that you find while executing 1 of your test cases. But the developer replies back and says that this is not a valid bug. How would you tackle this situation and what would be your next steps?” Provide a thorough and complete answer to this interview question.

In: Computer Science

NOTE: this is at 5th position..not 4th Using the Hamming code algorithm (7, 4), convert a...

NOTE: this is at 5th position..not 4th

  1. Using the Hamming code algorithm (7, 4), convert a data message (0110) using 7bit.
    1. Identify the number of parity bits needed
    2. Evaluate values of parity bits
    3. Final message bits with parity bits
    4. Inject error (o or 1) at 5th position and identify the error position.

In: Computer Science

In Java please. I put down my code and what I was able to achieve so...

In Java please. I put down my code and what I was able to achieve so far:

public class Animal {

  private String gender; //stores the gender of the animal
   private String type; //stores the type of the animal(bear of fish)
   private int strength; //stores the strength of the animal

   public Animal() {
       gender = "none";
       type = "none";
       strength = 0;
   }
  
    public Animal (String g, String t, int s) {
       g = gender;
       t = type;
       s = strength;      
   }

   public boolean setGender() {
       Random ranGen = new Random();
      
       boolean g = ranGen.nextBoolean();

  
       if (g == true)
           gender = "Male";
       else
           gender = "Female";
       return g;
   }
  
   public String getGender() {
       return gender;
   }

   public boolean setType() {
       Random ranGen = new Random();
      
       boolean t = ranGen.nextBoolean();
      
       if (t == true)
           type = "Bear";
       else
           type = "Fish";
       return t;      
   }
  

   public String getType() {
       return type;
   }


   public void setStrength(int strength) {
       this.strength = strength;
   }


   public int getStrength() {
       return strength;
   }

  
   public boolean compareGender(Animal animal) {

       if(this.getGender().equals(animal.getGender()))
       {
           return true;
       }
       else {
           return false;

       }
   }

  
   public boolean compareType(Animal animal) {
  
       if(this.getClass().equals(animal.getClass())){
           return true;   
       }
       else{
           return false;

       }

   }


   public boolean compareStrength(Animal animal) {
  
       if(this.getStrength() == (animal.getStrength())){
           return true;   
       }
       else{
           return false;

       }
   }
  
   public void increaseStrength() {
  
       this.setStrength(this.getStrength() + 4);
   }
  

   public String toString() {
       String str = new String ("The animal:  " + type + " + gender + strength);
       return str;

   }

}

public class River {
   private Animal[] river;
   private int numAnimals;
      

   public River() throws NumberFormatException{
   numAnimals = 0;
   Random randNum = new Random();
   int num = randNum.nextInt(20);
   river = new Animal[num];
   while(numAnimals < river.length/2)
   {
       int place = randNum.nextInt(river.length);
       if(river[place] == null)
       {
           river[place] = new Animal();

numAnimals++;


       }
   }
  
   }
  
   public River(Animal[] size) throws NumberFormatException{
       setRiver(size);
      
   }
  

   public void setRiver(Animal[] s) throws NumberFormatException
   {
       river= s;
           if (s.length >= 10 && s.length <= 20)
               river = s;
           else
       throw new NumberFormatException("Invalid Number: number out of range");
   }
  

   public Animal[] getRiver() {
       return river;      
   }
  
   public void play() {
       Random randNum = new Random();
       int moviment;
       for(int i=0; i<river.length; i++) {
           if(river[i] != null) {
               moviment = randNum.nextInt();
               if(moviment == 1) {
                  
               }
              
           }
       }
  

So my problem is on the play method. I need to iterate through the array.

If I find an animal I need to randomly decide if the animal id going to move back, forward or stay in place.

If the animal is moving back I need to make sure that he is not at the beginning of the array.

If the animal is moving forward I need to make sure that he is not at the last position of the array.

If the animal stays in place nothing needs to be done.

If the animal moves back/forward the index position needs to be checked if to see if its empty.

If is empty the animal can just move there. If is not the animal type needs to be checked.

If they are of the same type its gender needs to be checked. Same gender produces a baby, different gender they fight and the weaker animal dies (meaning it will be erased from the array).

If the animals are from different types one of the animals is going to be eaten.

**I really do not know how to do this method, I tried to start but I do not know how to move forward, so I would really appreciate if you put comments through the code. Also, can you please check if the parameterized constructor is right?

Thank you so much

In: Computer Science

Think of a technology that, in your opinion, clearly affects the workplace. Try to think of...

Think of a technology that, in your opinion, clearly affects the workplace. Try to think of a technology that is not so common. (You might also think about the technology you wish to look into for the research paper.)
Create a dialogue / conversation between two people of approximately 100 lines - about two pages. In it, one person must “act” as if the technology has little or no impact on the workplace. The other (you, perhaps) must convince the first of its impact. That last person needs to provide examples of the unanticipated and anticipated consequences of the technology. Provide an

In: Computer Science

Using x86 assembly language, create a flowchart and write an example of code that will sort...

Using x86 assembly language, create a flowchart and write an example of code that will sort 2 arrays of unsigned doubleword integers in ascending order and output the largest element in each array. Any sorting procedure can be used, but this procedure must be called twice for each array. The first time it is called, the first array should be sorted and the second time it is called, the second array must be sorted. As well as outputting which is largest in each array.

You can use these unsigned doubleword integers in the example.

Array 1: 00000000, 84728372, E222111F

Array 2: 81002346, 22222222, FFFFFFFF

In: Computer Science

This week we delved into the features of Access. We learned about importing and exporting data...

This week we delved into the features of Access. We learned about importing and exporting data to and from other applications.

Please write your own scenario, either from a previous experience you have had or from your own imagination, where it was necessary to import and export data from one application to another in the Microsoft Office Suite.

In: Computer Science

IN C LANGUAGE 16.16 Lab 5: merge Name this program merge.c - This program will take...

IN C LANGUAGE

16.16 Lab 5: merge

Name this program merge.c - This program will take two arguments from the command-line which will be the names of the two text files the program will read from. These text files contain a list of numbers each in ascending order. You'll open the text files and begin merging the two sets of numbers together until every unique number is printed to the screen once and in order. For example:

file1.txt file2.txt
1 2
2 4
3 6
6 7

file3.txt: 1 2 5 7 9 10 11 13 15 17 19 20 21 24 25

file4.txt: 3 4 6 8 10 11 12 14 16 18 20

Note: make sure your input text files end with an empty newline, or the last number may be skipped. Lines must end with a newline character, according to the standards we follow.

Example executions:

./a.out file1.txt file2.txt
1 2 3 4 6 7
./a.out file3.txt file4.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 24 25

Here is the solution in pseudo-code:

Read number1 from file1
Read number2 from file2
While ( not EOF for file1 AND not EOF for file2 )
    If number1 is less than number2
       Print number1 and read the next number from file1
    Else if number1 is greater than number2
       Print number2 and read the next number from file2
    Else (the numbers are the same)
       Print the number and read the next number from both files
End while
// at most one of the following two while statements will be true
While( file1 has not yet hit EOF)
   Print number1 and read the next number from file1
While( file2 has not yet hit EOF)
   Print number2 and read the next number from file2

In: Computer Science