1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alina1380 [7]
2 years ago
12

Rainfall_mi is a string that contains the average number of inches of rainfall in Michigan for every month (in inches) with ever

y month separated by a comma. Write code to compute the number of months that have more than 3 inches of rainfall. Store the result in the variable num_rainy_months. In other words, count the number of items with values > 3.0.
Computers and Technology
1 answer:
const2013 [10]2 years ago
5 0

Answer:

Hi!

The answer in Javascript is:

function monthsWithMoreOfThree() {

  var Rainfall_mi = '3,4,1,5,2,6,7,9'; <em>//Defined and declared</em>

  var num_rainy_months = 0;

  var values = Rainfall_mi.split(","); <em>//use split method for Strings. Array is returned</em>

   for (var i = 0; i < values.length; i++) { <em>//for each value, compares with 3</em>

     if(values[i] > 3) { <em>//In Javascript, you can compare an String value with an int. Can use parseInt(aString) to explicit parse but is not necessary</em>

       num_rainy_months++; <em>//If value is greater than 3, adds 1 to num_rainy_months</em>

     }

   }

}

You might be interested in
A ____ is a program that lets computer users create and access a collection of organized data.
ruslelena [56]
Database management system
5 0
3 years ago
Build three classes that conform to the following interfaces. Use arrays in creating your classes (e.g., do not use the built-in
daser333 [38]

Explanation:

public class ArrayList {

private Object[] array = new Object[1];

/**

 * Places new element at location

 * @param c, element to be inserted

 * @param i, location it is to be placed

 */

public void insert(char c, int i) {

 if(i>this.size()){

  System.out.println("Index "+i +" outside of list size; max: " +this.size());

  System.exit(0);

 }

 int count = 0;

 try {

  Object[] other = new Object[this.array.length+1];

  switch(i){

     case 0:{

      other[0] = c;

      for(int j=1;j<this.array.length;j++)

       other[j] = this.array[j-1];

       

      this.array = other;

      break;

     }

     default: {

      for(int j=0;j<i;j++)

       other[j] = this.array[j];

      other[i] = c;

      for(int k=i+1;k<this.array.length;k++)

       other[k] = this.array[k-1];

      this.array = other;

      break;

     }

     }

 }

 catch(ArrayIndexOutOfBoundsException exception) {

     largerArray();

     if(++count == 2){

      System.out.println("Something went wrong.");

      System.exit(0);

     }  

 }

}

 

/**

 * Places new element at location

 * @param object, element to be inserted

 * @param index, location it is to be placed

 */

void insert(Object object, int index){

 if(index>this.size()){

  System.out.println("Index "+index +" outside of list size; max: " +this.size());

  System.exit(0);

 }

 int count = 0;

 try {

  Object[] other = new Object[this.array.length+1];

  switch(index){

     case 0:{

      other[0] = object;

      for(int j=1;j<this.array.length;j++)

       other[j] = this.array[j-1];

       

      this.array = other;

      break;

     }

     default: {

      for(int j=0;j<index;j++)

       other[j] = this.array[j];

      other[index] = object;

      for(int k=index+1;k<this.array.length;k++)

       other[k] = this.array[k];

      this.array = other;

      break;

     }

     }

 }

 catch(ArrayIndexOutOfBoundsException exception) {

     largerArray();

     if(++count == 2){

      System.out.println("Something went wrong.");

      System.exit(0);

     }  

 }

}

 

/**

 * Removes element at index

 * @param index, location to remove

 * @return temp, object removed

 */

Object remove(int index){

 if(index>this.size()){

  System.out.println("Index "+index +" outside of list size; max: " +this.size());

  System.exit(0);

 }

 Object temp = this.array[index];

 int count = 0;

 try {

  Object[] other = new Object[this.array.length-1];

  switch(index){

     case 0:{

      other[0] = this.array[1];

      for(int j=1;j<this.size();j++)

       other[j] = this.array[j+1];

       

      this.array = other;

      break;

     }

     default: {

      for(int j=0;j<index;j++)

       other[j] = this.array[j];

      for(int k=index;k<this.size();k++)

       other[k] = this.array[k+1];

      this.array = other;

      break;

     }

     }

 }

 catch(ArrayIndexOutOfBoundsException exception) {

     largerArray();

     if(++count == 2){

      System.out.println("Something went wrong.");

      System.exit(0);

     }  

 }

 return temp;

}

 

/**

 * Copies the array to a new array twice the size.

 */

public void largerArray(){

 Object[] other = new Object[this.array.length*2];

 System.arraycopy(this.array, 0, other, 0, this.array.length);

 this.array = other;

}

 

/**

 * @return true if there are null elements

 */

public boolean isEmpty() {

 boolean bool = true;

 for (Object element : this.array) {

  if(element!=null){

   bool = false;

   break;

  }

  else{

   bool = true;

   break;

 }

 }

 return bool;

}

 

/**

 * Determines the real length of the array

 * @return length of non-null elements

 */

public int size(){

 int count = 0;

 for(int i=0;i<this.array.length;i++){

  if(this.array[i]==null)

   continue;

  else

   count++;

 }

 return count;

}

 

/**

 * Converts array to string.

 * @return the Array as a string

 */

public String toString(){

 String string = "";

 for(int i=0;i<this.size();i++){

  if(i<this.size()-1)

   string += this.array[i]+", ";

  else

   string += this.array[i];

 }

 return string;

}

 

/**

 * Similar to get, imput the character, retrieve index.

 * @param object, what we're looking for

 * @return index

 */

int indexOf(Object object){

 int index = -1;

 for(int i=0;i<this.array.length;i++){

  if(this.array[i]==(object))

   index = i;

  else continue;

 }

 return index;

}

 

/**

 * @param object, Arraylist tyoe

 * @return true, if the elements of the arrays are equivalent.

 */

public boolean equals(ArrayList object){

 boolean bool = false;

 int thisLength = this.array.length;

 int objectLength = object.array.length;

 if(thisLength > objectLength){

  for(int i=0;i<this.array.length;i++)

   if(this.array[i] == object.array[i])

    bool = true;

   else{

    bool = false;

    break;

   }

 }

 else{

  for(int i=0;i<object.array.length;i++)

   if(this.array[i] == object.array[i])

    bool = true;

   else{

    bool = false;

    break;

   }

 }

 return bool;

}

 

/**

 * Getter to check what is at an index

 * @param index, location

 * @return the character at this position

 */

Object get(int index){

 return this.array[index];

}

}

6 0
2 years ago
Put these events in the order in which they occurred,
lakkis [162]

Answer:

  1. Local fisherman recover the body of Major Martin off the coast  of Spain .
  2. Spanish officials pass off the information in the briefcase to  German agents.
  3. Major Martin's name appears on a casualty list in a British  newspaper.
  4. Germany prepares for an imminent attack on the island of  Sardinia.

Explanation:

This above is the order in which Operation Mincemeat was executed in WW2 to deceive the Germans into believing that the Allies were going to invade the Balkans directly instead of Sicily which was their actual target.

The plan involved a fictitious Major Martin who had secret documents about the Allied invasion of the Balkans. After the body was released from a British submarine, it washed up in Spain where it was found by local fishermen.

Spanish officials then passed the information in the briefcase Major Martin had to German intelligence. To further reinforce the ruse, the British published Major Martin's name in a casualty list.

The Germans were thoroughly convinced and switched forces from Sicily for the defence of the Balkans and the island of Sicily.

5 0
3 years ago
Operating systems are designed to work with specific hardware. Which operating system works with Apple computers?
Ghella [55]
2. Mac and to be more precisely, OS X
5 0
3 years ago
Read 2 more answers
Do you play Rocket League
lakkis [162]
Yessirrr like 3 times a week
6 0
2 years ago
Read 2 more answers
Other questions:
  • Barr the Bear has started a business to sell fish to Poe and his fellow penguins. The penguin customers submit many fish orders,
    12·1 answer
  • A software license gives the owner the to use software.
    12·2 answers
  • An undesirable jagged appearance is referred to as
    7·2 answers
  • Only Lysita knows the password for the question......
    10·1 answer
  • An attacker compromises the Washington Post's web server and proceeds to modify the homepage slightly by inserting a 1x1 pixel i
    12·1 answer
  • This method of advertising is expensive but can be the most effective method.
    15·1 answer
  • The need to strike a<br>- among work, life, family, and other responsibilities is<br>universal.​
    15·1 answer
  • which statement is true? O A Future games will be more context oriented. OB. Future games will be more product driven. Future ga
    13·2 answers
  • The Table Design and Layout tabs are available under the
    13·2 answers
  • Damion recently did an update to his computer and added a new video card. After the update, Damion decided that he would like to
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!