Questions
Trace this code: 1) #include<iostream> using namespace std;    class Test {     int value; public:     Test(int...

Trace this code:

1)

#include<iostream>

using namespace std;

  

class Test {

    int value;

public:

    Test(int v);

};

  

Test::Test(int v) {

    value = v;

}

  

int main() {

    Test t[100];

    return 0;

}

===================================================================

2)

#include <iostream>

using namespace std;

int main()

{

                int i, j;

                for (i = 1; i <= 3; i++)

                {

                                //print * equal to row number

                                for (j = 1; j <= i; j++)

                                {

                                                cout << "* ";

                                }

                                cout << "\n";

                }

                system("pause");

                return 0;

In: Computer Science

A real estate expert wanted to find the relationship between the sale price of houses and...

A real estate expert wanted to find the relationship between the sale price of houses and various characteristics of the houses. He collected data on five variables, recorded in the table, for 12 houses that were sold recently. The five variables arePrice: Sale price of a house in thousands of dollars. Lot Size: Size of the lot in acres. Living Area: Living area in square feet. Age: Age of a house in years. Type of house: town house (T) or Villa (V) Price Lot Size Living Area Age Type of house

Price 255 178 263 127 305 164 245 146 287 189 211 123

Lot Size1.4 0.9 1.8 0.7 2.6 1.2 2.1 1.1 2.8 1.6 1.7 0.5

Living area 2500 2250 2900 1800 3200 2400 2700 2050 2850 2600 2300 1700

Age 8 12 5 24 10 18 9 28 13 9 8 11

Type of the house T T T T T T T V V V V V

Find the regression equation for the town house e) Find the regression equation for the Villa f) What is the price of a town house with a lot size of 1.3, living area of 1800, and is 7 years old?

In: Statistics and Probability

Java Language Add a method (deleteGreater ()) to the LinkedList class to delete the node with...

Java Language

Add a method (deleteGreater ()) to the LinkedList class to delete the node with the higher value data.

Code:

class Node {

int value;

Node nextNode;

Node(int v, Node n)

{

value = v;

nextNode = n;

}

Node (int v)

{

this(v,null);

}

}

class LinkedList

{

Node head; //head = null;

LinkedList()

{

}

int length()

{

Node tempPtr;

int result = 0;

tempPtr = head;

while (tempPtr != null)

{

tempPtr = tempPtr.nextNode;

result = result + 1;

}

return(result);

}

void insertAt(int v, int position)

{

Node newNode = new Node(v,null);

Node tempPtr;

int tempPosition = 0;

if((head == null) || (position ==0))

{

newNode.nextNode = head;

head = newNode;

}

else {

tempPtr = head;

while((tempPtr.nextNode != null)&&(tempPosition < position -1))

{

tempPtr = tempPtr.nextNode;

tempPosition = tempPosition + 1;

}

if (tempPosition == (position - 1))

{

newNode.nextNode = tempPtr.nextNode;

tempPtr.nextNode = newNode;

}

}

}

public String toString()

{

Node tempPtr;

tempPtr = head;

String result = "";

while(tempPtr != null)

{

result = result + "[" + tempPtr.value + "| ]-->";

tempPtr = tempPtr.nextNode;

}

result = result + "null";

return result;

}

}

public class LinkedListDemoInsDel

{

public static void main(String[] args)

{

LinkedList aLinkedList = new LinkedList();

aLinkedList.insertAt(1,0);

aLinkedList.insertAt(9,1);

aLinkedList.insertAt(13,2);

aLinkedList.insertAt(8,1);

aLinkedList.insertAt(3,2);

System.out.println(aLinkedList);

System.out.println("Largo de lista: " + aLinkedList.length());

}

}

In: Computer Science

Complete the program used on the instructions given in the comments: C++ lang #include <string> #include...

Complete the program used on the instructions given in the comments:

C++ lang

#include <string>

#include <vector>

#include <iostream>

#include <fstream>

using namespace std;

vector<float>GetTheVector();

void main()

{

vector<int> V;

V = GetTheVector(); //reads some lost numbers from the file “data.txt" and places it in //the Vector V

Vector<int>W = getAverageOfEveryTwo(V);

int printTheNumberOfValues(W) //This should print the number of divisible values by 7 //but not divisible by 3.

PrintIntoFile(W); //This prints the values of vector W into an output file “output.txt”

}

As you see in the main program, there are four functions. The first function is called “GetVector()” that reads a set of integer, place them into the vector V, and returns the vector to the main program.

The second function is called “GetAverageOfEveryTwoNumber() that takes a vector “V” and finds the average of every two consecutive numbers, place the values into another vector called “W” and returns it to the main program. For example if the Vector is:

10 20 30 40 50 60 70 80 90 100

Then vector “W” should be:

15 25 35 45 55 65 75 85 95

Because (10+20) divided by 2 is 15, and so on.

The next function takes the vector “W” and count how many of the values are divisible by “7” but not divisible by “3”

Finally the last function prints the vector “W” into an output file called “output.txt”

In: Computer Science

Java Language: Using program created in this lesson as a starting point, create a circular list...

Java Language:

Using program created in this lesson as a starting point, create a circular list with at least four nodes. A circular list is one where the last node is made to point to the first. Show that your list has a circular structure by printing its content using an iterative structure such as a while. This should cause your program to go into an infinite loop so you should include a conditional that limits the number of nodes to be printed to a specific value, for example 20.

Code:

class Node {

int value;

Node nextNode;

Node(int v, Node n)

{

value = v;

nextNode = n;

}

Node (int v)

{

this(v,null);

}

}


class Stack {

protected Node top;

Stack()

{

top = null;

}

boolean isEmpty()

{

return( top == null);

}

void push(int v)

{

Node tempPointer;

tempPointer = new Node(v);

tempPointer.nextNode = top;

top = tempPointer;

}

int pop()

{

int tempValue;

tempValue = top.value;

top = top.nextNode;

return tempValue;

}

void printStack()

{

Node aPointer = top;

String tempString = "";

while (aPointer != null)

{

tempString = tempString + aPointer.value + "\n";

aPointer = aPointer.nextNode;



System.out.println(tempString);

}

}

public class StackWithLinkedList{

public static void main(String[] args){

int popValue;

Stack myStack = new Stack();

myStack.push(5);

myStack.push(7);

myStack.push(9);

myStack.printStack();

popValue = myStack.pop();

popValue = myStack.pop();

myStack.printStack();

}

}

In: Computer Science

If you have downloaded the source code from this book's companion web site, you will find...

If you have downloaded the source code from this book's companion web site, you will find the following files in the Chapter 07 folder: • GirlNames.txt--This file contains a list of the 200 most popular names given to girls born in the United States from the year 2000 through 2009. • BoyNames.txt--This file contains a list of the 200 most popular names given to boys born in the United States from the year 2000 through 2009. Write a program that reads the contents of the two files into two separate lists, allows a user to input either a girl's name, a boy's name, or both, then tells the user whether the name(s) was/were popular between 2000 and 2009. First, the program should prompt the user to choose a girl's name, a boy's name, or both by entering either 'girl', 'boy', or 'both.' Once they have chosen, they should be able to input a name. If the name was a popular name, like Jacob or Sophia, the program should print "Jacob was a popular boy's name between 2000 and 2009." or "Sophia was a popular girl's name between 2000 and 2009." If the name was not a popular name, like Voldemort, the program should print "Voldemort was not a popular boy's name between 2000 and 2009." If the user chooses to input both a girl and boy's name, ask for the boy's name, then the girl's name, and print two statements in the form mentioned above on two separate lines, with the statement about the boy's name coming first. For example, if the user inputs Voldemort and then Sophia, print: Voldemort was not a popular boy's name between 2000 and 2009. Sophia was a popular girl's name between 2000 and 2009.

My code is working perfectly on boy and girl but it only reads that a name was not popular for boy and girl when running both.

def searchBoyName(boysList, name): #Searching for given boy name in list if name in boysList: #If found print("\n " + str(name) + " was a popular boy's name between 2000 and 2009. \n"); else: #If not found print("\n " + str(name) + " was not a popular boy's name between 2000 and 2009. \n"); def searchGirlName(girlsList, name): #Searching for given girl name in list if name in girlsList: #If found print("\n " + str(name) + " was a popular girl's name between 2000 and 2009. \n"); else: #If not found print("\n " + str(name) + " was not a popular girl's name between 2000 and 2009. \n"); def main(): #Reading data from files boysList = open("BoyNames.txt", "r"); girlsList = open("GirlNames.txt", "r"); #Initializing lists boyNames = []; girlNames = []; #Adding boys names for name in boysList: name = name.strip(); boyNames.append(name); #Adding girls names for name in girlsList: name = name.strip(); girlNames.append(name); #Accepting input from user type = input("\n Enter 'boy', 'girl', or 'both':"); #Searching for boy name if type == "boy": # Reading boy name bname = input("\n\n Input a boy name: "); # Searching searchBoyName(boyNames, bname) #Searching for girl name elif type == "girl": #Reading girl name gname = input("\n\n Input a girl name: "); #Searching searchGirlName(girlNames, gname); #Searching for both elif type == "both": #Searching for given boy name in list bname = input("\n\n Input a boy name: "); #Reading girl name gname = input("\n\n Input a girl name: "); if bname in boysList: #If found print("\n " + str(bname) + " was a popular boy's name between 2000 and 2009. \n"); elif bname not in boysList: #If not found print("\n " + str(bname) + " was not a popular boy's name between 2000 and 2009. \n"); #Searching for given girl name in list if gname in girlsList: #If found print("\n " + str(gname) + " was a popular girl's name between 2000 and 2009. \n"); elif gname not in girlsList: #If not found print("\n " + str(gname) + " was not a popular girl's name between 2000 and 2009. \n"); else: print("\n Invalid selection.... \n"); #Calling main function main();

In: Computer Science

8. Elena just got engaged to be married. She posts a message about the engagement on...

8. Elena just got engaged to be married. She posts a message about the engagement on Facebook. Three of her friends, Alicia, Barbara, and Charlene, will click “like" on her post. Use X, Y, and Z (respectively) to denote the waiting times until Alicia, Barbara, and Charlene click “like" on this post, and assume that these three random variables are independent. Assume each of the random variables is an Exponential random variable that has an average of 2 minutes.

8a. Find P(X<1).

8b. Use your answer to 8a to find the probability that all 3 friends “like" the post within 1 minute.

8c. Use your answer to 8a to find the probability that none of the 3 friends “like" the post within 1 minute.

8d. Use your answer to 8a to find the probability that exactly 1 of the 3 friends “likes" the post within 1 minute.

8e. Use your answer to 8a to find the probability that exactly 2 of the 3 friends “like" the post within 1 minute.

8f. Let V denote the number of friends (among these 3) who “like" the post within 1 minute. Then V is a discrete random variable. What kind of random variable is V? [Hint: In 8b, we have P(V=3); in 8c, we have P(V=0); in 8d, we have P(V=1); in 8e, we have P(V=2). Your answers in 8b, 8c, 8d, 8e should sum to 1.]

a.Bernoulli random variable

b.Binomial random variable

c.Geometric random variable

d.Poisson random variable

In: Statistics and Probability

(i) Consider a CMOS inverter supplied at VDD= 5V with transistor parameters of KN=KP=50µA/V2 and VTN=-VTP=1V....

(i) Consider a CMOS inverter supplied at VDD= 5V with transistor parameters of KN=KP=50µA/V2 and VTN=-VTP=1V. Then consider another CMOS inverter supplied at VDD= 10V with the same transistor parameters. Draw the VTC of both inverters showing all regions of operation and the middle voltage VM. Verify your results using PSpice.

            (ii) Draw the square root of the CMOS inverter current versus the input voltage for the two CMOS inverters in given in part (i) biased at either VDD=5 V or VDD=10 V. Determine the peak current of the CMOS inverter at VDD=5 V & VDD=10 V. Verify your results using PSpice.

(iii) Consider NMOS inverter supplied at VDD= 5V with transistor parameters of KDriver=10 KLoad=100µA/V2 and VT =0.7V. Calculate the power dissipated for the following input conditions: Vin= 0.25 V and Vin=4.3 V.

(iv) If two NOR gates based on the CMOS inverter given in part (i) which supplied at VDD= 5V are connected to realize an SR Flip Flop. Sketch the NOR gate and sketch the complete circuit of the SR Flip Flop indicating the S and R inputs a well as the Q output. What are the logic”0” and logic “1” levels of this Flip Flop?

(v) If two NOR gates based on the NMOS inverter given in part (iii) are connected to realize an SR Flip Flop. Sketch the NOR gate and sketch the complete circuit of the SR Flip Flop indicating the S and R inputs a well as the Q output. What are the logic”0” and logic “1” levels of this Flip Flop?

In: Electrical Engineering

Sulfur Determination in Coal Samples experiment i)The coal sample being used in this experiment is assumed...

Sulfur Determination in Coal Samples experiment

i)The coal sample being used in this experiment is assumed to have 3% sulfur in its composition. What percent of sulfate (SO42-) is present in the coal samples?

ii) Knowing the percent of assumed sulfate from above in your coal samples, what would be the concentration of sulfate (in ppm) if the sample was placed in 250 mL of water?

iii) The UV-Vis spectrophotometer and the Ion Chromatograph (IC) have both been introduced in earlier experiments in this course. Based on your prior knowledge of these instruments, which do you think will give a more accurate reading of sulfate levels in your coal samples? Why?

In: Chemistry

Consider the isatin yield experiment below. Set up the 2^4 experiment in this problem in two...

Consider the isatin yield experiment below. Set up the 2^4 experiment in this problem in two blocks with ABCD confounded. Analyze the data from this design. Is the block effect large?. Show the steps to perform this in Minitab.

factor low high
A:acid strength (%) 87 93
B:Reaction time (min) 15 30
C:Amount of acid (ml) 35 45
D:reaction temperature (c) 60 70
A B C D yield

-1

-1 -1 -1 6.08
1 -1 -1 -1 6.04
-1 1 -1 -1 6.53
1 1 -1 -1 6.43
-1 -1 1 -1 6.31
1 -1 1 -1 6.09
-1 1 1 -1 6.12
1 1 1 -1 6.36
-1 -1 -1 1 6.79
1 -1 -1 1 6.68
-1 1 -1 1 6.73
1 1 -1 1 6.08
-1 -1 1 1 6.77
1 -1 1 1 6.38
-1 1 1 1 6.49
1 1 1 1 6.23

In: Statistics and Probability