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
gogolik [260]
3 years ago
8

What is the value of the totalsString variable after the following code is executed? var totals = [141.95, 212.95, 411, 10.95];

totals[2] = 312.95; var totalsString = ""; for (var i = 0; i < totals.length; i++) { totalsString += totals[i] + "|"; }
Computers and Technology
1 answer:
Alex Ar [27]3 years ago
7 0
<h2>Answer:</h2>

141.95|212.95|312.95|10.95|

<h2>Explanation:</h2>

<em>Reformatting the code snippet and giving it line numbers;</em>

1.       var totals = [141.95, 212.95, 411, 10.95];

2.      totals[2] = 312.95;

3.      var totalsString = "";

4.      for (var i = 0; i < totals.length; i++) {

5.          totalsString += totals[i] + "|";

6.      }

Line 1 creates an array called totals with four elements.

     First element = totals[0] =141.95

     Second element = totals[1] = 212.95

     Third element = totals[2] = 411

     Fourth element = totals[3] = 10.95

Line 2 replaces the value of the third element <em>totals[2]</em> = 411 with 312.95.

     Therefore the array <em>totals = </em>[141.95, 212.95, 312.95, 10.95]

Line 3 creates an empty string called totalsString

Lines 4 - 6 create a for loop that cycles from i=0 to i<totals.length

       totals.length = 4 (which is the number of items in the array totals)

       This means that the loop cycles from i=0 to i<4

       During cycle 1 when i = 0, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[0] + "|"   //substitute the values

            totalsString = "" + 141.95 + "|"

            totalsString = 141.95|

       During cycle 2 when i = 1, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[1] + "|"   //substitute the values

            totalsString = "141.95|" + 212.95 + "|"

            totalsString = 141.95|212.95|

       During cycle 3 when i = 2, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[2] + "|"   //substitute the values

            totalsString = "141.95|212.95|" + 312.95 + "|"

            totalsString = 141.95|212.95|312.95|

       During cycle 4 when i = 3, the expression inside the for loop executes as follows;

            totalsString = totalsString + totals[3] + "|"   //substitute the values

            totalsString = "141.95|212.95|312.95|" + 10.95 + "|"

            totalsString = 141.95|212.95|312.95|10.95|

At the end of the execution, totalsString = 141.95|212.95|312.95|10.95|

You might be interested in
Assslainsdffddsvvdesdssbhasasco5m
alexandr402 [8]
Hahahahaha I wanna was the day I wanna was the last time I got to
8 0
3 years ago
Read 2 more answers
Write the printItem() method for the base class. Sample output for below program:
Anna [14]

Answer:

The printItem() method code is filled in the explanation, highlighted with bold font.

Explanation:

// ===== Code from file BaseItem.java =====

public class BaseItem {

  protected String lastName;

  public void setLastName(String providedName) {

      lastName = providedName;

      return;

  }

// FIXME: Define printItem() method

/* Your solution goes here */

  public void printItem() {

      // TODO Auto-generated method stub

      System.out.println("Last name: "+lastName);

  }

}

// ===== end =====

4 0
3 years ago
Create a goal seek analysis to determine what the price should be to generate demand of 2,625,000 tablets given that the supplie
Svetach [21]

Answer:

Explanation:

The following image shows the required entries that are to be filled in the excel sheet:

Goal Seek Parameters and Results

Set Cell                                        C14

To Value By Changing Cell        2625000

By Changing Cell                         C3

Resulting Price?                           $290

Explanation:

The goal seek tool in excel is used to change a value in the calculation to get the desired results.

In the given question, it is required to get the demand of tablets to reach the value of 2,625,000 by changing the price.

The value that is to be inserted in the “Set cell” field is the cell number which shall contain the desired result. This cell must have a formula having the cell which is inserted in the “by changing cell” field.

In the given question, the value of demand is desired.

The cell value which stores the calculated demand is C14 is and hence it is inserted in the field “Set cell”

The “to value” field of the goal seek tool is used to set the desired result.

Here, 2,625,000 is the value that is desired and hence it filled in the “To value” field.

The “By changing cell” field of the goal seek tool, represents the cell whose value is to be changed for getting the desired results.

Here, the value of price is required to be changed to get the required demand, thus the value that should be inserted in the “By changing cell” of the goal seek tool is C3, which represents the price.

The required demand is achieved by changing the price to $290.

8 0
3 years ago
What are the external parts of a computer system and which are output devices and which are input devices
cestrela7 [59]
I'd question the wording, However:

Monitor, Output device.
Keyboard, Input device.
Mouse, Input device.
Speakers Output Device.
Microphone, Input device.
Printer, Output device.
Scanner, input device.

Devices do not have to explicitly be one or the other e.g. a printer with a scanner, or headphones with a microphone.  
4 0
4 years ago
Write a class named Add that has the following data members, constructor, and methods:
taurus [48]

Answer:

A class is like a blueprint of object.

Explanation:

A class defines the kinds of data and the functionality their objects will have.

A class enables you to create your own custom types by grouping together variables of other types, methods and events.

In C#, we can create a class  using the class keyword.

Here's a sample program:

using System;

namespace ConsoleApplication

{

   public class Test

   {

       public static void Main()

       {

           Add a1 = new Add(70, 50);

           a1.AddNumbers();                    

           Console.ReadLine();

       }      

   }

     class Add

   {

       private int row;

       private int column;

       public Add(int r, int c)

       {

           row = r;

           column = c;

       }

       public void AddNumbers()

       {

           Console.WriteLine(row+column);

       }

   }

}

output: 120

Explanation of the program:

I have created a class named Add. Within a class, row and column are two fields and AddNumbers() is a method. We also have constructor to initialize row and column.

In main method, If I need to invoke members of the class, I must create  an instance of the class. We can create any number of instances using the single class.IN our program, a1 is the reference variable using which we can invoke members of the class. I invoked function in the class and passed arguments to the constructor while creating an instance.

Those values are assigned to method variables and it operated the addition. Thus the output is 120.

7 0
3 years ago
Other questions:
  • What is the legal right granted to all authors and artists that gives them sole ownership and use of their words, software, pict
    9·2 answers
  • Help me Please?!! I will put you as brainliest.<br>I hope I spelled that right.
    5·2 answers
  • Write a Python function merge_dict that takes two dictionaries(d1, d2) as parameters, and returns a modified dictionary(d1) cons
    5·1 answer
  • Grbn kmjnhbgvfcdxswikmjnthbrvgt
    5·2 answers
  • Consider the following code segment.
    15·1 answer
  • Which of the following BEST describes an extranet?
    13·1 answer
  • In an income statement subtracting the cost of goods sold from the net sales provides the?
    11·1 answer
  • Describe how both IPv4 and IPv6 access and utilize TCP as an upper-layer transfer protocol.
    6·1 answer
  • Who created fortnite
    15·2 answers
  • Why must you be careful when handling a hard drive?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!