Write the constructor for the Theater class. The constructor takes three int parameters, representing the number of seats per row, the number of tier 1 rows, and the number of tier 2 rows, respectively. The constructor initializes the theaterSeats instance variable so that it has the given number of seats per row and the given number of tier 1 and tier 2 rows and all seats are available and have the appropriate tier designation. Row 0 of the theaterSeats array represents the row closest to the stage. All tier 1 seats are closer to the stage than tier 2 seats. Complete the Theater constructor. /** Constructs a Theater object, as described in part (a). * Precondition: seatsPerRow > 0; tier1Rows > 0; tier 2 Rows >= 0 */ public Theater(int seatsPerRow, int tier1Rows, int tier 2 Rows)

Answers

Answer 1

Answer:

See explaination

Explanation:

class Seat {

private boolean available;

private int tier;

public Seat(boolean isAvail, int tierNum)

{ available = isAvail;

tier = tierNum; }

public boolean isAvailable() { return available; }

public int getTier() { return tier; }

public void setAvailability(boolean isAvail) { available = isAvail; } }

//The Theater class represents a theater of seats. The number of seats per row and the number of tier 1 and tier 2 rows are

//determined by the parameters of the Theater constructor.

//Row 0 of the theaterSeats array represents the row closest to the stage.

public class Theater {

private Seat[][] theaterSeats; /** Constructs a Theater object, as described in part (a). * Precondition: seatsPerRow > 0; tier1Rows > 0; tier2Rows >= 0 */

public Theater(int seatsPerRow, int tier1Rows, int tier2Rows) {

theaterSeats= new Seat[tier1Rows+tier2Rows][seatsPerRow];

}

public boolean reassignSeat(int fromRow, int fromCol, int toRow, int toCol) {

if(theaterSeats[toRow][toCol].isAvailable()) {

int tierDestination =theaterSeats[toRow][toCol].getTier();

int tierSource =theaterSeats[fromRow][fromCol].getTier();

if(tierDestination<=tierSource) {

if(tierDestination==tierSource) {

if(fromRow<toRow) {

return false;

}else {

theaterSeats[toRow][toCol].setAvailability(false);

theaterSeats[fromRow][fromCol].setAvailability(true);

return true;

}

}

theaterSeats[toRow][toCol].setAvailability(false);

theaterSeats[fromRow][fromCol].setAvailability(true);

return true;

}else {

return false;

}

}else {

return false;

}

}

public static void main(String[] args) {

//Lets understand it with simple example

Theater t1 = new Theater(3,1,2);

//Our threater has 3 seat in each row and we have one tier 1 row and 1 tier 2 row

//total no of seat will be 9.

//Lets create our seat

t1.theaterSeats[0][0] = new Seat(true,1);

t1.theaterSeats[0][1] = new Seat(false,1);

t1.theaterSeats[0][2] = new Seat(true,1);

t1.theaterSeats[1][0] = new Seat(true,2);

t1.theaterSeats[1][1] = new Seat(true,2);

t1.theaterSeats[1][2] = new Seat(true,2);

t1.theaterSeats[2][0] = new Seat(false,2);

t1.theaterSeats[2][1] = new Seat(false,2);

t1.theaterSeats[2][2] = new Seat(true,2);

//Lets print out theater and see which seat is available or which is not

System.out.println("Theater===>");

for(int i=0;i<3;i++) {

for(int j=0;j<3;j++) {

System.out.print("["+i+"]"+"["+j+"] : "+t1.theaterSeats[i][j].isAvailable()+" ");

}

System.out.println();

}

System.out.println("(2,1) want to change seat to (0,0)");

System.out.println("["+2+"]"+"["+1+"]"+"===>"+"["+0+"]"+"["+0+"]");

t1.reassignSeat(2, 1, 0, 0);

for(int i=0;i<3;i++) {

for(int j=0;j<3;j++) {

System.out.print("["+i+"]"+"["+j+"] : "+t1.theaterSeats[i][j].isAvailable()+" ");

}

System.out.println();

}

}

}


Related Questions

Lab Assignment 7A For the lab this week, you will sort an array - using any of the sort methods discussed in Chapter 23 or the Selection sort. It's your choice. Use the following criteria for your assignment: Write a program that uses a two-dimensional array to store daily minutes walked and carb intake for a week. Prompt the user for 7 days of minutes walked and carb intake; store in the array. Write a sort ( your choice which sort ) to report out the sorted minute values -lowest to highest. Write another to report out the sorted carb intake - highest to lowest. These methods MUST be your original code. Your program should output all the values in the array and then output the 2 sorted outputs. You must use an array to receive credit for this assignment

Answers

Answer:

See explaination

Explanation:

import java.util.Scanner;

public class sort {

static void lowestToHighest(float arr[][])

{

float temp;

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

for(int j=0;j<12-i-1;j++) //Using bubble sort to sort

{

if(arr[j][0]>arr[j+1][0])

{

temp = arr[j][0];

arr[j][0] = arr[j+1][0];

arr[j+1][0] = temp;

}

}

for(int i=0;i<11;i++) //Using bubble sort to sort

{

for(int j=0;j<12-i-1;j++)

if(arr[j][1]>arr[j+1][1])

{

temp = arr[j][1];

arr[j][1] = arr[j+1][1];

arr[j+1][1] = temp;

}

}

System.out.println("Data in the array after sorting lowest to highest: ");

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

System.out.printf(arr[i][0]+" "+arr[i][1]+"\n");

}

static void highestToLowest(float arr[][])

{

float temp;

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

for(int j=0;j<12-i-1;j++) //Using bubble sort to sort

{

if(arr[j][0]<arr[j+1][0])

{

temp = arr[j][0];

arr[j][0] = arr[j+1][0];

arr[j+1][0] = temp;

}

}

for(int i=0;i<11;i++) //Using bubble sort to sort

{

for(int j=0;j<12-i-1;j++)

if(arr[j][1]<arr[j+1][1])

{

temp = arr[j][1];

arr[j][1] = arr[j+1][1];

arr[j+1][1] = temp;

}

}

System.out.println("Data in the array after sorting highest to lowest: ");

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

System.out.printf(arr[i][0]+" "+arr[i][1]+"\n");

}

public static void main(String[] args){

float temperature[][]=new float[12][2];

Scanner input = new Scanner(System.in);

System.out.println("Enter 12 months of highest and lowest temperatures for each month of the year: ");

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

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

temperature[i][j]=input.nextFloat();

System.out.println("Data in the array: ");

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

System.out.printf(temperature[i][0]+" "+temperature[i][1]+"\n");

lowestToHighest(temperature);

highestToLowest(temperature);

}

}

A disadvantage of a bus network is that _____. a. failure in one workstation necessarily affects other workstations on the network b. data flows in only one direction from one computer to the next c. devices cannot be attached or detached without disturbing the rest of the network d. performance can decline as more users and devices are added

Answers

A disadvantage of a bus network is that performance can decline as more users and devices are added

Explanation:

A bus network is an arrangement in a local area network (LAN) in which each node is connected to a main cable or link called the bus.The advantages of a bus network are: it is easy to install. it is cheap to install, as it doesn't require much cable.

The disadvantages of a bus network are:

If the main cable fails or gets damaged the whole network will fail. As more workstations are connected the performance of the network will become slower because of data collisions. Every workstation on the network "sees" all of the data on the network – this is a security risk.Bus topology is used for small workgroup local area networks whose computers are connected using a thinnet cable. Trunk cables connecting hubs or switches of departmental LANs to form a larger LAN. Bus topology uses one main cable to which all nodes are directly connected. The main cable acts as a backbone for the network. One of the computers in the network typically acts as the computer server. The first advantage of bus topology is that it is easy to connect a computer or peripheral device.

What changes do you need to a algorithm to compare 100 numberst

Answers

Answer:

It really depends - in general every data structure has its use.

Explanation:

Furthermore, traversing the list will be inefficient because the data items are not contiguous in memory, forcing the CPU to jump all over the RAM memory causing further slowdown.

1 Write a java program which calculates the area of either a Triangle or a Rectangle. Use Scanner to take an input field to tell you if the area to be calculated is for a Triangle or is for a Rectangle. Depending on that input - the program must call either the Triangle method or the Rectangle method. Each of those methods must receive 2 input fields from the user - one for base and one for height in order to calculate the area and then to print that area and the height and base from inside the method.

Answers

A Java program which calculates the area of either a Triangle or a Rectangle. Use Scanner to take an input field to tell you if the area to be calculated is for a Triangle or is for a Rectangle.

Explanation:

Use Scanner to take an input field to tell you if the area to be calculated is for a Triangle or is for a Rectangle.

Depending on that input - the program must call either the Triangle method or the Rectangle method.

import java.util.Scanner;

class AreaOfRectangle {

  public static void main (String[] args)

  {

   Scanner scanner = new Scanner(System.in);

   System.out.println("Enter the length of Rectangle:");

   double length = scanner.nextDouble();

   System.out.println("Enter the width of Rectangle:");

   double width = scanner.nextDouble();

   //Area = length*width;

   double area = length*width;

   System.out.println("Area of Rectangle is:"+area);

  }

}

class AreaOfTriangle  

{

  public static void main(String args[])  

   {    

       

     Scanner s= new Scanner(System.in);

       

        System.out.println("Enter the width of the Triangle:");

        double b= s.nextDouble();

 

        System.out.println("Enter the height of the Triangle:");

         double h= s.nextDouble();

 

                 //Area = (width*height)/2

     double area=(b*h)/2;

     System.out.println("Area of Triangle is: " + area);      

  }

}

Consider the following class descriptions and code. Account is an abstract class with one abstract method named getInterestRate. BasicCheckingAccount is a concrete class that extends Account. EnhancedCheckingAccount extends BasicCheckingAccount and overrides getInterestRate.

Account acct;
double rate1, rate2;
acct = new BasicCheckingAccount(< parameters not shown >);
rate1 = acct.getInterestRate(); // assignment 1
acct = new EnhancedCheckingAccount(< parameters not shown >);
rate2 = acct.getInterestRate(); // assignment 2

The reference to getInterestRate in assignment 2 is to the class

a. Account

b. EnhancedCheckingAccount

c. SavingsAccount

d. The code cannot run, because the variable acct cannot be assigned to an EnhancedCheckingAccount object in the line before assignment 2.

Answers

Answer:

Option B - Enhanced Checking Account

Explanation:

Enhanced Checking Account as this class overrides the get interest Rate

5.6 Look carefully at how messages and mailboxes are represented in the email system that you use. Model the object classes that might be used in the system implementation to represent a mailbox and an email message

Answers

Answer:

See explaination for the details of the answer.

Explanation:

A class is a structured diagram that describes the structure of the system.

It consists of class name, attributes, methods and responsibilities.

A mailbox and an email message has some certain attributes such as, compose, reply, draft, inbox, etc.

See attachment for the Model object classes that might be used in the system implementation to represent a mailbox and an email message.

Both the

B

cancel button and the enter button appear on the formula bar when you begin typing in a cell.

Answers

Answer:

The answer is "True"

Explanation:

In the given question some information is missing, that is an option "true or false", which can be described as follows:

It displays the format string properties, which helps them build and update equations. In the second here are examples of what Linux Excel's equation bars, in this two-button, are used, which can be described as follows:

The cancel button is used to cancel or delete any formula. The enter button is used to insert any formula in the bar.

(Solved—15 Lines) In many jurisdictions a small deposit is added to drink containers to encourage people to recycle them. In one particular jurisdiction, drink containers holding one liter or less have a $0.10 deposit, and drink containers holding more than one liter have a $0.25 deposit. Write a program that reads the number of containers of each size from the user. Your program should continue by computing and displaying the refund that will be received for returning those containers. Format the output so that it includes a dollar sign and always displays exactly two decimal places.

Answers

Answer:

JAVA program is given below.

import java.util.Scanner;

public class Main

{

   //static variables declared and initialized as required

   static float deposit1 = 0.10f;

   static float deposit2 = 0.25f;

   static float refund1;

   static float refund2;

   static int num_one_lit;

   static int num_more;

public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

 System.out.print("Enter the number of containers of 1 liter or less: ");

 num_one_lit = sc.nextInt();

 System.out.print("Enter the number of containers of more than 1 liter: ");

 num_more = sc.nextInt();

 //refund computed based on user input

 refund1 = num_one_lit*deposit1;

 refund2 = num_more*deposit2;

 //displaying refund

 System.out.printf("Total refund amount for containers of 1 liter or less is $%.2f %n", refund1);

 System.out.printf("Total refund amount for containers of more than 1 liter is $%.2f %n", refund2);

}

}

OUTPUT

Enter the number of containers of 1 liter or less: 5

Enter the number of containers of more than 1 liter: 2

Total refund amount for containers of 1 liter or less is $0.50  

Total refund amount for containers of more than 1 liter is $0.50

Explanation:

1. Variables are declared at class level hence declared as static.

2. Variables holding deposit also initialized with the given values.

3. User input is taken for the number of containers in both categories.

4. The total value of refund is computed using the given values and user entered values.

5. The total refund is displayed to the user for both categories.

6. To display two decimal places always, variables to hold deposit and refund are declared as float.

7. The keywords used for decimals are %.2f %n. The %.2f keyword indicates two decimal places to be displayed in float variable, %n indicates a numeric value is to be displayed.

8. The printf() method is used to display the formatted output for refund amount.

9. The keywords used to display the formatted output is derived from C language.

10. All the code is written inside class and execution begins from the main() method.

[Submit on zyLabs] Please write a function with one input, a matrix, and one output, a matrix of the same size. The output matrix should be the input matrix mirrored on the vertical axis. For instance, theinput:[123456789]Would become: [321654987]And the input:[112221112212]Would become:[221112221121]Note that this functions slightly differently for inputs with odd and even numbers of columns. For an odd number of columns, your centermost column stays the same. For an even number of columns, all columns are moved in the resulting output. You can use the function[yDim, xDim]

Answers

Answer:

See explaination for the details.

Explanation:

% Matlab file calculateMirrorMatrix.m

% Matlab function to return a matrix which should be input matrix mirrored

% on the vertical axis

% input is a matrix

% output is a matrix of same size as input matrix

function [mirrorMatrix] = calculateMirrorMatrix(inputMatrix)

mirrorMatrix = zeros(size(inputMatrix)); % create output matrix mirrorMatrix of same size as inputMatrix

fprintf('\n Input Matrix :\n');

disp(inputMatrix); % display the input matrix

[row,col] = size(inputMatrix); % row, col contains number of rows and columns of the inputMatrix

% loop to find the matrix which should be input matrix mirrored

for i = 1:row

mirrorIndex =1;

for j = col:-1:1

mirrorMatrix(i,mirrorIndex)=inputMatrix(i,j);

mirrorIndex=mirrorIndex + 1;

end

end

end

% end of matlab function

Please kindly check attachment for its output.

The function 'mirror_matrix' takes a matrix and returns a new matrix where the columns are reversed. It handles matrices with both odd and even numbers of columns. This solution ensures accurate vertical mirroring of the input matrix.

Mirroring a Matrix on the Vertical Axis

To solve the problem of mirroring a matrix on the vertical axis, we need to create a function that takes an input matrix and outputs a matrix of the same size where the columns are reversed.

Here's a step-by-step explanation:

Matrix Dimensions: Determine the dimensions of the matrix with variables yDim (number of rows) and xDim (number of columns).Initialize Output Matrix: Create an empty matrix of the same size as the input matrix.Reverse Columns: Iterate through each row of the matrix and assign the elements to the new positions in the output matrix such that the columns are reversed.

Here's a sample Python function to achieve this:

def mirror_matrix(matrix):
   yDim = len(matrix)
   xDim = len(matrix[0])
   output_matrix = [ ]
   for row in matrix:
       new_row = row[::-1]
       output_matrix.append(new_row)
   return output_matrix

For example, an input matrix:

[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]

would result in:

[[3, 2, 1],
[6, 5, 4],
[9, 8, 7]]

This solution ensures that the output matrix is mirrored correctly on the vertical axis.

java


This lab is intended to give you practice creating a class with
a constructor method, accessor methods, mutator methods, equals
method , toString method and a equals method.

In this lab you need to create two separate classes, one Student class and other Lab10 class.
You need to define your instance variables, accessor methods, mutator methods, constructor,
toString method and equals method in Student class.

You need to create objects in Lab10 class which will have your main method and need to add various
functionalities so that you can get the output as shown in sample output.

// Name:
// Section:

// Lab 10
// CS1113
// Fall 2016
// Class Lab10


public class Lab10
{
//Constants
private final static String NAME = "YOUR NAME"; // replace YOUR NAME with your name
private final static int STUID = 123456789;
private final static double GPA1 = 4.00;
private final static double GPA2 = 2.34;

//main method
public static void main (String[] args)
{
Student stu1;

stu1 = new Student(NAME, STUID, GPA1);

System.out.println("\nName: " + stu1.getName());
System.out.println("Id Number: " + stu1.getIdNum());
System.out.println("GPA : " + stu1.getGPA());
stu1.setGPA(GPA2);
System.out.println(stu1 + "\n");

// Create a second student object
// With a name of Trine Thunder, a
// gpa of 4.00, and a student Id of
// 000000001
// You do not need to declare these at final constants,
// but you can if you want to.

// [Add code here]

// Print out this student similar to above.
// You do not need to reset the gpa of this student.

// [Add code here]

// Check if both objects are same using == and .equals() methods.
// Print the message in both cases, whether same or not as shown in sample output.

// [Add code here]

} // end of main
} // end of class Lab10


// Name:
// Section:

// Lab 10
// CS1113
// Fall 2016
// Class : Student.java

public class Student
{
//class variables
private String name;
private int idNum;
private double gpa;

// Constructor
public Student(String namePar, int idNumPar, double gpaPar)
{
// Save namePar to class variable name

// [Add code here]

// Save idNumPar to class variable idNum

// [Add code here]

// Save gpaPar to class variable gpa

// [Add code here]

}

// Accessor: returns name of student
public String getName()
{
// Return the name of the student

// [Add code here]
}

// Accessor: returns GPA of student
public double getGPA()
{
// Return the gpa of the student

// [Add code here]
}

// Accessor: returns idNum of student
public int getIdNum()
{
// Return the idnum of the Student

// [Add code here]
}


// Mutator: Changes the GPA of the student
public void setGPA(double g)
{
// Set the class variable gpa equal to g

// [Add code here]
}

// toString method: Returns a formatted string
// of student information.
// As shown in sample output.
public String toString()
{
// declare a String variable to store the string value
// then return the formatted String.

// [Add code here]
}

// implement .equals() method which returns a boolean value
// of student information. When you call this method,
// it should print message as shown in sample output.
public boolean equals(Student s)
{
//[Add code here]
}
} // end of class Student


1) Fill in the needed code in the file (class)
Student.java (Student) and Lab10.java.
The program will not compile until you do so.
You will have 2 files, one named Lab10.java
and one named Student.java.

Compile the subsidiary class, Student.java,
first, using

javac Student.java

Once you have eliminated any and all syntax errors
in the student class. Then compile

javac Lab10.java

and eliminate any syntax errors from that class.
Then you can run the program using

java Lab10

2) Run the program and redirect the output to Lab10_out.txt

A Sample output is below:

Name: John Terry
Id Number: 123456789
GPA : 4.0
Student Name: John Terry
Student Id num:123456789
Student GPA: 2.34


Name: Trine Thunder
Id Number: 1
GPA : 4.0
Student Name: Trine Thunder
Student Id num:1
Student GPA: 4.0

Using == .....
Both are different.

Using .equals() method.....
Both are different.

3) Now change your code so that you pass same values for both stu1 and stu2.
Compile and run your program.
Your output should look like:

Name: John Terry
Id Number: 123456789
GPA : 4.0
Student Name: John Terry
Student Id num:123456789
Student GPA: 2.34


Name: Trine Thunder
Id Number: 1
GPA : 4.0
Student Name: Trine Thunder
Student Id num:1
Student GPA: 4.0

Using == .....
Both are different.

Using .equals() method.....
Both are different.

Explain why the result is not as expected?

Revert back to your previous version of your java code.

4) Turn in a printed copy of both Student.java and Lab10.java. Also
turn in a printed copy of your output file created in step 2.

Answers

Answer:

public class Lab10

{

//Constants

private final static String NAME = "John Terry"; // replace YOUR NAME with your name

private final static int STUID = 123456789;

private final static double GPA1 = 4.00;

private final static double GPA2 = 2.34;

//main method

public static void main (String[] args)

{

Student stu1;

stu1 = new Student(NAME, STUID, GPA1);

System.out.println("\nName: " + stu1.getName());

System.out.println("Id Number: " + stu1.getIdNum());

System.out.println("GPA : " + stu1.getGPA());

stu1.setGPA(GPA2);

System.out.println(stu1 + "\n");

// Create a second student object

// With a name of Trine Thunder, a

// gpa of 4.00, and a student Id of

// 000000001

// You do not need to declare these at final constants,

// but you can if you want to.

System.out.println("\nName: Trine Thunder" );

System.out.println("Id Number: 000000001");

System.out.println("GPA : 4.00");

Student stu2 = new Student("Trine Thunder",000000001, 4.00 );

// [Add code here]

// Print out this student similar to above.

// You do not need to reset the gpa of this student.

System.out.println(stu2 + "\n");

// [Add code here]

// Check if both objects are same using == and .equals() methods.

// Print the message in both cases, whether same or not as shown in sample output.

System.out.println("Using ==");

if(stu1 == stu2){

System.out.println("Both are same");

}

else{

System.out.println("Both are different");

}

stu1.equals(stu2);

// [Add code here]

} // end of main

} // end of class Lab10

// Name:

// Section:

// Lab 10

// CS1113

// Fall 2016

// Class : Student.java

public class Student

{

//class variables

private String name;

private int idNum;

private double gpa;

// Constructor

public Student(String namePar, int idNumPar, double gpaPar)

{

// Save namePar to class variable name

name = namePar;

// [Add code here]

idNum = idNumPar;

// Save idNumPar to class variable idNum

gpa = gpaPar ;

// [Add code here]

// Save gpaPar to class variable gpa

// [Add code here]

}

// Accessor: returns name of student

public String getName()

{

// Return the name of the student

return name;

// [Add code here]

}

// Accessor: returns GPA of student

public double getGPA()

{

// Return the gpa of the student

return gpa;

// [Add code here]

}

// Accessor: returns idNum of student

public int getIdNum()

{

// Return the idnum of the Student

return idNum;

// [Add code here]

}

// Mutator: Changes the GPA of the student

public void setGPA(double g)

{

// Set the class variable gpa equal to g

gpa = g;

// [Add code here]

}

// toString method: Returns a formatted string

// of student information.

// As shown in sample output.

public String toString()

{

// declare a String variable to store the string value

// then return the formatted String.

String s ="";

s = s + "Student Name: "+name+"\n";

s =s + "Student Id num: "+idNum+"\n";

s =s + "Student GPA: "+gpa+"\n";

return s;

// [Add code here]

}

// implement .equals() method which returns a boolean value

// of student information. When you call this method,

// it should print message as shown in sample output.

public boolean equals(Student s)

{

//[Add code here]

System.out.println("Using .equals() method");

if(this.equals(s.idNum == this.idNum)){

System.out.println("Both are same");

return true;

}

else{

System.out.println("Both are different");

return false;

}

}

} // end of class Student

Explanation:

Output:

Name: John Terry

Id Number: 123456789

GPA : 4.0

Student Name: John Terry

Student Id num: 123456789

Student GPA: 2.34

Name: Trine Thunder

Id Number: 000000001

GPA : 4.00

Student Name: Trine Thunder

Student Id num: 1

Student GPA: 4.0

Using ==

Both are different

Using .equals() method

Both are different

WILL GIVE BRAINLIEST !True or False: Loops are important because fewer steps are needed, so the algorithm becomes shorter and easier to read.



True


False

Answers

True.

When we write long codes, we’re likely to do a lot of copying and pasting, and it’s easy to make a mistake. If we ever want to change something, we’ll need to change each line. How can we improve on this? We can separate the parts of these lines that differ from the parts that don’t, and use a loop to iterate over them. Instead of storing the user input in separate variables, we are going to use a dictionary – we can easily use the property names as keys, and it’s a sensible way to group these values.

A binary search algorithm is written (as in the modules, for example) which searches a pre-sorted array for some user-defined value, clientData. If clientData is stored in the array, it returns its array position, and if not found, it returns -1 (again, just like in the modules). Assume the array to be searched has 100 data elements in it. (Check all that apply):[NOTE: due to common off-by-one interpretations when counting such things, if your predicted answer is within one (+1 or -1) of a posted option below, you can assume your prediction and the choice you are looking at are equivalent and check that option.]A. It might return to the client with an answer after only one comparison of data.B. It may require as many as 99 comparisons of data before it returns.C. It will always return with an answer in 7 or fewer comparisons of data.D. It will always return with an answer in 3 or fewer comparisons of data.

Answers

Answer:

c) it will always return with an answer of 7 or fewer comparisons of data.

Explanation:

As maximum number of comparison in worst case for sorted binary search is log₂n, here n = 100, so maximum search is at least 6.6 which is approximately 7.

Write a recursive function named sumSquares that returns the sum of the squares of the numbers from 1 to num, in which num is a nonnegative int variable. Do not use global variables; use the appropriate parameters. Also write a program to test your function.

Answers

Answer:

def sumSquares(num):

   if (num == 0):

       return 0

   else:

       return num*num + sumSquares(num-1)

   

print(sumSquares(7))

Explanation:

* The code is in Python

The function takes one parameter num. If the num is equal to 0, that means function checked all the numbers up until num, and stops.

If the num is not equal to 0, the function will calculate the square of the number. It multiplies the num with num, adds this multiplication to result of the   same function with a parameter that is decreased by 1.

For example, if num is equal to 3 initially, following will happen:

first iteration: sumSquares(3) =  3x3 + sumSquares(2)  

second iteration: sumSquares(2) =  2x2 + sumSquares(1)

third iteration: sumSquares(1) =  1x1   + sumSquares(0)

forth iteration : sumSquares(0) = 0

If you go from bottom to top,

We know that sumSquares(0) is equal to 0, that means the result of the third iteration is 1, 1 + 0

We know that sumSquares(1) is equal to 1, that means the result of the third iteration is 5, 4 + 1

We know that sumSquares(2) is equal to 5, that means the result of the third iteration is 14, 9 + 5

Coach Kyle has some top athletes who have the potential to qualify for Olympics. They have been training very had for the 5000 and 10000 meters running competition. The coach has been recording their timings for each 1000 meters. In the practice sessions, each athlete runs a distance in multiples of 1000 meters and the coach records their time for every 1000 meters. Put the following in a text file called timings.txt. This is not a Python program. Just open up a text editor and copy the following to a file. Alice,3:15,2:45,3:30,2:27,3:42 Bob, 2:25,3:15,3:20,2:57,2:42,3:27 Charlie, 2:45,3:25,3:50,2:27,2:52,3:12 David,2:15,3:35,3:10,2:47 Write a main function that calls read_data, determines the min and max, calls get_average, and prints as below. a) Function read_data will read the file and returns a dictionary with the athlete information. b) Function get_average will accept a list of times and return the average time in the format min:sec. c) Use the split function to split the timings into individual elements of a list. d) Be sure to handle exceptions for files and incorrect data. Athlete Min Alice 2:27 Bob 2:25 Charlie 2:27 David 2:15 Max 3:42 3:27 3:50 3:35 Average 3:07 3:01 3:05 2:56

Answers

Answer:

Check the explanation

Explanation:

Coach Kyle is havaing the following data.

Alice 3:15, 2:45, 3:30, 2:27, 3:42

Bob 2:25, 3:15, 3:20, 2:57, 2:42, 3:27

Charlie 2:45, 3:25, 3:50, 2:27, 2:52, 3:12

David 2:15, 3:35, 3:10, 2:47

let us name it as Athlete. txt

now

1. Use a function to read the data from the file.

To read a file, we can use different methods.

file.read( )

If you want to return a string containing all characters in the file, you can

use file. read().

file = open('Athlete. txt', 'r')

print file. read()

Output:

Alice 3:15, 2:45, 3:30, 2:27, 3:42

Bob 2:25, 3:15, 3:20, 2:57, 2:42, 3:27

Charlie 2:45, 3:25, 3:50, 2:27, 2:52, 3:12

David 2:15, 3:35, 3:10, 2:47  

We can also specify how many characters the string should return, by using

file.read(n), where "n" determines number of characters.

This reads the first 5 characters of data and returns it as a string.

file = open('Athlete .txt', 'r')

print file.read(5)

Output:

alice  

file. readline( )  

The readline() function will read from a file line by line (rather than pulling  

the entire file in at once).  

Use readline() when you want to get the first line of the file, subsequent calls  

to readline() will return successive lines.  

Basically, it will read a single line from the file and return a string  

containing characters up to .  

file = open('athlete .txt', 'r')  

print file. readline():  

2.Implement the logic using Dictionary, List, and String:  

One way to create a dictionary is to start with the empty dictionary and add key-value pairs. The empty dictionary is denoted with a pair of curly braces, {}:  

Dictionary operations:  

The del statement removes a key-value pair from a dictionary. For example, the following dictionary contains the names of various fruits and the number of each fruit in stock:  

>>> inventory = {'apples': 430, 'bananas': 312, 'oranges': 525, 'pears': 217}  

>>> print(inventory)  

{'oranges': 525, 'apples': 430, 'pears': 217, 'bananas': 312}  

If someone buys all of the pears, we can remove the entry from the dictionary:  

>>> del inventory['pears']  

>>> print(inventory)  

{'oranges': 525, 'apples': 430, 'bananas': 312}  

Or if we’re expecting more pears soon, we might just change the value associated with pears:  

>>> inventory['pears'] = 0  

>>> print(inventory)  

{'oranges': 525, 'apples': 430, 'pears': 0, 'bananas': 312}  

The len function also works on dictionaries; it returns the number of key-value pairs:  

>>> len(inventory)  

4  

The in operator returns True if the key appears in the dictionary and False otherwise:  

>>> 'pears' in inventory  

True  

>>> 'blueberries' in inventory  

False  

This operator can be very useful, since looking up a non-existant key in a dictionary causes a runtime error:  

>>> inventory['blueberries']  

Traceback (most recent call last):  

File "", line 1, in <module>  

KeyError: 'blueberries'  

>>>  

3. Use maketrans and translate functions to replace commas with spaces  

text = text. translate(string. maketrans("",""), string. punctuation)  

4. Use split function to split the timings into individual elements of a list  

>>> Athlete. split(",")  

split reverses by splitting a string into a multi-element list. Note that the delimiter (“,”) is stripped out completely; it does not appear in any of the elements of the returned list.  

5. Perform necessary calculations to display min, max, and avg timings of each athlete  

_min = None  

_max = None  

_sum = 0  

_len = 0  

with open('Athlete .txt') as  ff:  

for line in ff:  

val = int(line. strip())  

if _min is None or val < _min:  

_min = val  

if _max is None or val > _max:  

_max = val  

_sum += val  

_len += 1  

_avg = float(_sum) / _len  

# Print output  

print("Min: %s" % _min)  

print("Max: %s" % _max)  

print("Avg: %s" % _avg)  

for index, row in enumerate(rows):  

print "In row %s, Avg = %s, Min = %s" % (index, Avg(row), min(row))  

for index, column in enumerate(columns):  

print "In column %s, Avg = %s, Min = %s" % (index, Avg(column), min(column))  

Write two Get statements to get input values into first Month and first Year. Then write three Put statements to output the month, a slash, and the year. Ex: If the input is 1 2000, the output is:

Answers

Answer:

// Scanner class is imported

import java.util.Scanner;

// InputExample class to hold the program

public class InputExample {

// main method to begin program execution

public static void main(String args[]) {

// Scanner object scnr is created

Scanner scnr = new Scanner(System.in);

// variable birthMonth is declared

int birthMonth;

// variable birthYear is declared

int birthYear;

// birthMonth is initialized to 1

birthMonth = 1;

// birthYear is initialized to 2000

birthYear = 2000;

// birthday is displayed

System.out.println("1/2000");

// prompt is displayed asking user to enter birthMonth

System.out.println("Enter birthMonth:");

// birthMonth is received using Scanner object

birthMonth = scnr.nextInt();

// prompt is displayed asking user to enter birthYear

System.out.println("Enter birthYear:");

// birthYear is received using Scanner object

birthYear = scnr.nextInt();

// the birthday format is displayed

System.out.println(birthMonth + "/" + birthYear);

}

}

Explanation:

The program is written in Java as required and it is well commented.

An image depicting the full question is attached.

Write a script that creates and calls a stored procedure named test. This procedure should use a transaction that includes the statements necessary to combine two customers. These statements should do the following: Select a row from the Customers table for the customer with a customer_id value of 6. This statement should lock the row so other transactions can’t read or modify it until the transaction commits, and it should fail immediately if the row is locked from another session. Update the Orders table so any orders for the selected customer are assigned to the customer with a customer_id value of 3. Update the Addresses table so any addresses for the selected customer are assigned to the customer with a customer_id value of 3. Delete the selected customer from the Customers table. If these statements execute successfully, commit the changes. Otherwise, rollback the changes.

Answers

Answer:

Check the explanation

Explanation:

use `my_guitar_shop`;

#delete the procedure test if it exists.

DROP PROCEDURE IF EXISTS test;

DELIMITER //

CREATE PROCEDURE test ()

BEGIN

   #declare variable sqlerr to store if there is an sql exception

  declare sqlerr tinyint default false;

   #declare variable handler to flag when duplicate value is inserted

  declare continue handler for 1062 set sqlerr = TRUE;

   #start transaction

   start transaction;

  delete from order_items where order_id in

      (select order_id from orders where customer_id=6);

  delete from orders where customer_id=6;

  delete from addresses where customer_id=6;

  delete from customers where customer_id=6;

 

   if sqlerr=FALSE then

      commit;

        select 'Transaction Committed' as msg;

  else

       rollback;

       select 'Transaction rollbacked' as msg;

   end if;

end //

delimiter ;

call test();

Rhea is creating a digital textbook she plans to use features that will help make the book more interesting for learning which of these can she do to make her digital textbook interesting

Answers

Answer:

incorporate audio-visual elements

Explanation:

By incorporating audio-visual elements features this will help them learn more better

Answer:

Rhea has many exciting features such as

She can add audio-visual effects in his digital book. She can use images and replace the text with images.She can use font styling. She can add a fancy border on each page.

However, the best and more attractive way is to add a fancy border.

Explanation:

Add a fancy border on each page is a more effective way to make digital textbook enjoyable.

A well-designed flyer should be

Eye-catching to make people interesting

Targeted to speak to the audience

Informative to what they find out.

Convincing that should attract people.

Rhea has to add a fancy border in her digital textbook for exciting learning.

Routing connects different network segments and decides where __________are sent to

Answers

Answer:

Packets

Explanation:

Write a Python function prime_generator that takes as argument positive integers s and e (where s

Answers

Answer:

def prime_generator(s, e):

   for number in range(s, e+1):      

       if number > 1:

          for i in range(2, number):

              if (number % i) == 0:

                  break

          else:

               print(number)

   

prime_generator(6,17)

Explanation:

I believe you want to ask the prime numbers between s and e.

- Initialize a for loop that iterates from s to e

- Check if the number is greater than 1. If it is, go inside another for loop that iterates from 2 to that number. If the module of that number to any number in range (from 2 to that number) is equal to 0, this means the number is not a prime number. If the module is not equal to zero, then it is a prime number. Print the number

2. Using the Book class developed in HW 4, write an application, BookLibrary, that creates a library (array) of up to 10 books and gives the user three options: to add a book, to delete a book from the library or to change a book’s information (i.e. number of pages and/or title) in the library. a. If the user selects the add option, issue an error message if the library is full. Otherwise, prompt the user for a book title. If the book with that title exists, issue an error message (no duplicated books titles are allowed). Otherwise, prompt the user for the number of pages and add the book. b. If the user selects the delete option, issue an error message if the library is empty. Otherwise, prompt the user for a book title. If the book with that title does not exist, issue an error message. Otherwise, "delete" (do not access the book for any future processing). c. If the user selects the change option, issue an error message if the library is empty. Otherwise, prompt the user for a book title. If the requested book title does not exist, issue an error message. Otherwise, prompt the user for a new title and/or number of pages and change the book information.

Answers

BookLibrary, that creates a library (array) of up to 10 books. If the user selects the add option, issue an error message if the library is full.If the book with that title exists, issue an error message

Explanation:

import java.util.Scanner;

import java.util.Arrays;

public class Derro_BooksLibrary {

public static void main(String[] args) {

 Derro_Books[] Library = new Derro_Books[10];

 Scanner scan = new Scanner(System.in);

 Derro_Books book1 = new Derro_Books("", 20);

 Derro_Books book2 = new Derro_Books("hi", 10);

 Library[0] = book1;

 Library[1] = book2;

 System.out.println("Enter 1 for add, 2 for delete, 3 for change, 4 to stop application: ");

 int answer = scan.nextInt();

 int counter = 0;

 int z = 0;

 while (true) {

  if (answer == 1) {

   for (Derro_Books book : Library) {

    counter = counter + 1;

   }

   if (counter == 10) {

    System.out.println("Library full");

   }

   System.out.println("Enter Title: ");

   String title = scan.nextLine();

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

    if (title == Library[i].getTitle()) {

     System.out.println("No Duplicated Books Titles Are Allowed");

     break;

    }

    else {

     z++;

    }

   }

   if (z < Library.length) {

   System.out.println("Enter number of pages: ");

   int pages = scan.nextInt();

   Library[z + 1] = new Derro_Books(title, pages);

  }

  if (answer == 2){

   if (Library.length == 0) {

    System.out.println("Library is empty");

   }

   System.out.println("Enter title of book: ");

   String title2 = scan.nextLine();

   for (int d = 0; d < Library.length; d++) {

    if (title2 == Library[d].getTitle())

     // Delete book

     System.out.println("Deleted book: " + title2);

    else

     System.out.println("Book does not exist");

   }

  }

  if (answer == 3) {

   if (Library.length == 0) {

    System.out.println("Library is empty.");

   } else {

    System.out.println("Enter book title: ");

    String title3 = scan.nextLine();

    for (int y = 0; y < Library.length; y++) {

     if (title3 != Library[y].getTitle())

      continue;

     else {

      System.out.println("Enter number of pages: ");

      int pages = scan.nextInt();

      Library[y] = new Derro_Books(title3, pages);

     }

    }

   }

  }

  String[] StringList = new String[10];

  for (int y = 0; y < Library.length; y++) {

   StringList[y] = Library[y].getTitle();

  }

  Arrays.sort(StringList);

  for (String bookt : StringList) {

   System.out.println(bookt + Library);

  }

 }

}

}

}

Explain the term duty cycle and determine the pulse duration of a periodic pulse train whose duty cycle is 15% and frequency is 13.3Mhz. Interprete your results.

Answers

Answer:

Duty cycle of a signal measures the fraction of a  time of a given transmitter is transmitting that signal. This fraction of a time determines the overall or total power transmitted or delivered by that signal.

More power is possessed by duty cycles with longer signals. This gives the signal the following characteristics such as reliability, strength and easy detection and thus require less efficient receivers.Less power is associated  with duty cycles of shorter signals. This gives the signal the following characteristics  such as less reliability, lower strength and not easily detected and thus require more efficient receivers.

Duty cycle = 15 %

frequency =  13.3Mhz = 13.3 x 10^3 hz = I/T = F

T = period = 1 / F = 1/13.3 x 10^3 hz= 7.5188 x 10 ^-5 s

Duty cycle = pulse duration/ period

15 % = PD/7.5188 x 10 ^-5 s

PD = 15/100 X 7.5188 x 10 ^-5 s = 1.12782 x 10^ -5 s

INTERPRETATION OF RESULTS

With a duty of 15 % and pulse duration of 1.12782 x 10^ -5 s, the strength is low , short signal and less reliable and needs more efficient receiver

Explanation:

Duty cycle of a signal measures the fraction of a  time of a given transmitter is transmitting that signal. This fraction of a time determines the overall or total power transmitted or delivered by that signal.

More power is possessed by duty cycles with longer signals. This gives the signal the following characteristics such as reliability, strength and easy detection and thus require less efficient receivers.Less power is associated  with duty cycles of shorter signals. This gives the signal the following characteristics  such as less reliability, lower strength and not easily detected and thus require more efficient receivers.

Duty cycle = 15 %

frequency =  13.3Mhz = 13.3 x 10^3 hz = I/T = F

T = period = 1 / F = 1/13.3 x 10^3 hz= 7.5188 x 10 ^-5 s

Duty cycle = pulse duration/ period

15 % = PD/7.5188 x 10 ^-5 s

PD = 15/100 X 7.5188 x 10 ^-5 s = 1.12782 x 10^ -5 s

INTERPRETATION OF RESULTS

With a duty of 15 % and pulse duration of 1.12782 x 10^ -5 s, the strength is low , short signal and less reliable and needs more efficient receiver

Which of the following statements correctly describe a computer program?
A. It is a robust way to find information
B. It is a set of step by step instructions called coding
C. It is a way to take apart a computer

Answers

Answer: A. It’s a robust way to find information

Explanation:

Hope this help.

Answer:

A. It is a robust way to find information

Explanation:

eh

Consider an unpipelined or single-stage processor design like the one discussed in slide 6 of lecture 17. At the start of a cycle, a new instruction enters the processor and is processed completely within a single cycle. It takes 2,000 ps to navigate all the circuits in a cycle (including latch overheads). Therefore, for this design to work, the cycle time has to be at least 2,000 pico seconds. What is the clock speed of this processor? (5 points) What is the CPI of this processor, assuming that every load/store instruction finds its instruction/data in the instruction or data cache? (5 points) What is the throughput of this processor (in billion instructions per second)? (10 points)

Answers

Answer:

a. Clock Speed of Processor = 0.5 GHz

b. Cycles per Instruction (CPI) = 1 Clock per Instruction

c. Throughput = 1 billion Instruction per Second

Explanation

Given Data

Time Take to complete the single Cycle = 2000ps = 2000 x 10⁻¹²

To Find

a. Clock Speed of Processor = ?

b. Cycles per Instruction (CPI) = ?

c. Throughput = ?

Solution:

a. Clock Speed of Processor = ?

Clock Speed = 1/Time to complete the cycle

                      = 1/2000 x 10⁻¹²  Hz

                      =  0.0005 x 10¹²  Hz

                      =  0.5 x 10⁹  Hz                             as   10⁹ = 1 Giga   so,

                      = 0.5 GHz

b. Cycles per Instruction (CPI) = ?

It is mentioned that, each instruction should start at the start of the new cycle and completely processed at the end of that cycle so, we can say that Cycles per Instruction (CPI) = 1

for above mentioned processor.

c. Throughput = ?

Throughput = CPI x Clock Speed

where

CPI = 1 cycle per instruction

Clock Speed = 1 billion Instructions per Second

as

Clock Speed = 1 billion Cycles per Second

Throughput = 1 cycle per instruction x 1 billion Cycles per Second

Throughput = 1 billion Instruction per Second

                         

Lab Assignment 3 Phase 1 Create a class named Car, which is supposed to represent cars within a Java program. The following are the attributes of a typical car: - year which indicates the year in which the car was made. - price indicating the price of the car The year attribute is an integer, whereas the price is a double value. The year can only lie between 1970 and 2011. The price can be any value between 0 and 100000. The class Car should be constructed in such a way that any attempt to place an invalid value in the year and/or price, will result in the attribute being set to its lowest possible value. Create the class, which contains the necessary attributes and setter/getter methods: setYear( ), getYear( ), setPrice( ) and getPrice( ). Test all of its public members, which in this case only represents the setter/getter methods. The instructor will provide his/her own testing code to verify that the class is functioning properly

Answers

Answer:

Check the explanation

Explanation:

Car.java

//class Car

public class Car {

  //private variable declarations

  private int year;

  private double price;

  //getYear method

  public int getYear() {

      return year;

  }

  //setYear method

  public void setYear(int year) throws CarException {

      //check for the year is in the given range

      if(year>=1970&&year<=2011)

          this.year = year;

      //else throw an exception of type CarException

      else

          throw new CarException("Invalid Year");

  }

  //getPrice method

  public double getPrice() {

      return price;

  }

  //setPrice method

  public void setPrice(double price) throws CarException {

      //check for the price is in the given range

      if(price>=0&&price<=100000)

          this.price = price;

      //else throw an exception of type CarException

      else

          throw new CarException("Invalid Price");

  }

  //default constructor to set default values

  public Car(){

      this.year=1970;

      this.price=0;

  }

  //overloaded constructor

  public Car(int year, double price) {

      //check for the year is in the given range

      if(year>=1970&&year<=2011)

          this.year = year;

      //else initialize with default value

      else

          this.year=1970;

      //check for the price is in the given range

      if(price>=0&&price<=100000)

          this.price = price;

      //else initialize with default value

      else

          this.price=0;

     

  }

  //copy constructor

  public Car(Car c){

      this.year=c.year;

      this.price=c.price;

  }

  //toString method in the given format

  public String toString() {

      return "[Year:" + year + ",Price:" + (int)price + "]";

  }

  //finalize method

  public void finalize(){

      System.out.println("The finalize method called.");

  }

  public static void main(String args[]) throws CarException{

      Car a=new Car();

      System.out.println(a.toString());

      Car b=new Car(1986,25000.98);

      System.out.println(b.toString());

      Car c=new Car();

      c.setYear(1900);

      c.setPrice(23000);

      System.out.println(c.toString());

      Car d=new Car();

      d.setYear(2000);

      d.setPrice(320000);

      System.out.println(d.toString());

  }

}

CarException.java

//exception class declaration

public class CarException extends Exception{

  //private variable declaration

  private String message;

  //constructor

  public CarException(String message) {

      super();

      this.message = message;

  }

  //return error message

  public String getMessage(){

      return message;

  }

 

}

a) Before writing any code, you should go through a design process. Try to do so carefully – either follow a top-down approach, a full bottom-up approach, or some combination. But, in any case, you should come up with a list of functions you plan to implement, each with its own clear purpose. a. Create a document that outlines all the functions you will create, including a purpose for each, stating what the function does, and any parameters it has. The purpose for each function can become its docstring b) After you have written a description of your program, including the planned functions, go ahead and write code for each function. Be sure to create a docstring for each function. Turn in your program and the design document you created beforehand. Challenge: See if you can create a program so that the lines are drawn

Answers

Answer:

See Explaination

Explanation:

import turtle

def drawLine(x,y,height):

'''

method to draw a vertical line from x,y with given height

'''

turtle.up()

turtle.goto(x,y)

turtle.down()

turtle.goto(x,y-height)

def drawSet(x,y,height):

'''

method to draw a full set of tally marks

'''

temp = x

#drawing 5 vertical lines

for j in range(4):

drawLine(temp,y,height)

temp+=20

#drawing a line crossing all previous lines

turtle.up()

turtle.goto(x-5,y-height/2)

turtle.down()

turtle.goto(temp-15,y-height/4)

def drawPartialSet(x,y,height,count):

'''

method to draw an incomplete set (less than 5 tally marks)

'''

temp = x

for j in range(count):

drawLine(temp,y,height)

temp+=20

#getting number

num=int(input('Enter the number: '))

#finding number of complete sets

sets=num//5

#finding number of incomplete sets

extra=num%5

#setting up turtle

turtle.setup(width=500,height=500)

turtle.pensize(5)

turtle.speed(0) #max speed

#starting x, y coordinates

x=-240

y=250

line_height=80 #height of one tally line

#drawing all complete sets

for i in range(1,sets+1):

drawSet(x,y,line_height)

x+=line_height

if i%5==0:

#moving to next line after every 5 sets

x=-240

y-=line_height+50

#drawing extra sets if exist

if extra>0:

drawPartialSet(x,y,line_height,extra)

turtle.ht() #hide turtle

turtle.done() #finish drawing

For each of the four CPU scheduling algorithm: First Come First Serve, Shortest Job First, Shortest Remaining Time First, and Round Robin, you will compare and contrast these algorithms. For each scheduling algorithm using the following CPU scheduling example: 1. Generate the Gantt Chart. 2. For each process, compute its: a. Turnaround time. b. Waiting time. c. Response time. 3. Compute, to 2 decimal places: a. The average turnaround time. b. The average waiting time. c. The average response time. The Exam 2 Answer Document contains a table for each scheduling algorithm for you to fill out.

Answers

Answer:

See explaination

Explanation:

Turnaround Time (TAT):

It is the time interval from the time of submission of a process to the time of the completion of the process.

Difference b/w Completion Time and Arrival Time is called Turnaround Time.

Completion Time (CT): This is the time when the process completes it’s execution.

Arrival Time (AT): This is the time when the process has arrived in the ready state.

TAT = CT - AT

Waiting Time (WT):

The time spent by a process waiting in the ready queue for getting the CPU.

The time difference b/w Turnaround Time and Burst Time is called Waiting Time.

Burst Time (BT): This is the time required by the process for it’s execution.

WT = TAT - BT

Now with Waiting Time and Burst Time we can also calculate Turn Around Time via:

TAT = BT + WT

Response Time(RT)-

Response time is the time spent between the ready state and getting the CPU for the first time.

Please kindly check attachment for the step by step solution of the given problem.

Expressions Write a console program that prompts the user for 3 double precision floating point values input1, input2, input3. Have the program compute and display the following values. the sum of input1, input2, input3 the average of input1, input2, input3 the log2 of input1 To access the built-in function log2 -- log2(X) computes the base 2 logarithm of X, you need to include the header at the top of your code.

Answers

Answer:

See Explaination

Explanation:

#include <iostream>

#include <cmath>

using namespace std;

int main()

{

float input1, input2, input3;

float sum=0.0, avg, l;

cout<<"enter the value for input1: ";

cin>>input1;

cout<<"enter the value for input2: ";

cin>>input2;

cout<<"enter the value for input3: ";

cin>>input3;

sum=input1+input2+input3;

cout<<"sum of three numbers: "<<sum<<endl;

avg=sum/3;

cout<<"average of three numbers: "<<avg<<endl;

l=log2(input1);

cout<<"log2 value of input1 number: "<<l;

return 0;

}

output:

enter the value for input1: 4

enter the value for input2: 5

enter the value for input3: 6

sum of three numbers: 15

average of three numbers: 5

log2 value of input1 number: 2

Write a function merge that merges two lists into one, alternating elements from each list until the end of one of the lists has been reached, then appending the remaining elements of the other list.

Answers

Explanation:

The program that merges two lists or two arrays is written below;

Code :

void main void

{

char [] arr1= {'1','2','3'};

char [] arr2= {'a','b','c','d','e'};

int l1= arr1.length;

int l2=arr2.length;

int l3=l1+l2;

char [] arr3=new char[l1+l2];

int i=0;

int j=0;

int k=0;

int m=0;

int r=0;

if(l1<l2)

   r=l1;

else

   r=l2;

while(m<r)

{

   arr3[k++]=arr1[i++];

   arr3[k++]=arr2[j++];

   m++;

}

while(k<l3)

{

   if(l1<l2)

       arr3[k++]=arr2[j++];

   else

       arr3[k++]=arr1[i++];

}

for(int n=0;n<l3;n++)

{

   System.out.print(arr3[n]+" ");

}

}

In class Assignment Setup of Production FacilityJobs Description Duration/ Weeks Predecessors1 Design production tooling 4 - 2 Prepare manufacturing drawings 6 - 3 Prepare production facility 10 - 4 Procure tooling 12 1 5 Procure production parts 10 2 6 Kit parts 2 3,4,5 7 Install tools 4 3,4 8 Testing 2 6,7 1. Draw the network diagram2. What is the critical path

Answers

Answer:

See explaination

Explanation:

Critical path method (CPM) is a step-by-step process by which critical and non-critical tasks are defined so that time-frame problems and process bottlenecks are prevented.

please see attachment for the step by step solution of the given problem.

A certain application runs in 30 minutes on a single processor PXY system. A close analysis reveals that 6 minutes of execution is due to inherently sequential code, while the code for the remaining 24 minutes is fully parallelizable. We consider upgrading our system to a multi-core PXY system so as to make the running time at most 10 minutes. What is the minimum number of cores that we should use

Answers

Answer:

minimum number of cores required = 6

Explanation:

Time take by parallelizable code = 24 mins

Reduced time of parallelizable code = 4 mins

Speed gained = 24/4 = 6 times

Therefore minimum number of cores required = 6

Other Questions
Skimping on calories in an effort to lose weight doesn't affect your body or send the wrong message to yourmetabolism.True or False The ________ manages all systems throughout the organization and the day-to-day operations of the entire IS organization. Question 1 options: 1) applications development manager 2) CIO 3) information center manager 4) IS Director Nitrifiers are bacteria a. capable of living in symbiosis in the roots of some plants. b. capable of oxidizing NH3 using NO. c. that convert N2 to NH3. d. that generate nitrites or nitrates. e. capable of using NH3 as an electron donor. If project A generates $10 million of free cash flow over its five year useful life and project B generates $8 million of free cash flow over its useful life, then Project A will have a shorter payback period than Project B, assuming both projects require the same initial investment. A sphere has been placed inside an cylinder with the same dimensions;both have a radius of 6cm,and a height of 12cm How many cubic centimeters of space does the sphere fill not fill up. A.432pi cm B.72 pi cm C.288 pi cm D.144 pi cm James has $1500 to open a checking account. He can maintain a monthly balance of at least $1000. He plans to use the ATM four times per month at his local branch. He does not overdraft his account and plans to use direct deposit. He also plans to pay his bills online and he averages 8 bills per month.A. Account BB. Account A Explain why a food web is a more realistic model ofenergy flow than a food chain.Answer: Food chain only shows one path by which energy can move through an ecosystem, because most organisms eat a variety of things, they are part of many food chains. A food web shows multiple pathways of energy, it shows interconnected food chains in a ecosystem.Hope this helps When disinfecting a whirlpool foot spa after use by a client, you must circulate the disinfectant for ______________ or the length of time indicated on the product label. 3 x + 9 = box If the equation has no solution, which expression can be written in the box on the other side of the equation? Clucking blucksClucking blucksClucking blucksClucking blucksClucking blucksClucking blucksClucking blucks Unlike the military, most U.S. Government agencies and nongovernmental organizations are _____ to create separate staffs at the strategic, operational, and tactical levels, with the result that Joint Task Force personnel interface with individuals who are coordinating their organization's activities at more than one level. Describe the president's main role and how he or she carries it out. What are starches and sugars in the cell known as? Will mark brainliest, please help! Why were women able to vote in western states like Wyoming before the restof the country?A. Women went to school longer in the West than in the East.B. Life in the West was not tied to traditional rules of society.C. They were influenced by Native American culture.D. Religion was stronger in the West. 172.7=3.14d Solve for d The Spanish Armada:_________. a. attempted to invade England. b. was a treasure fleet attacked by the English. c. was destroyed by a storm before it left Spain. d. caused Spain to give up New World colonization as a result of its defeat. e. broke English naval power for a century. The sum of two numbers increased by 5 The normal curve with a mean of 0 and standard deviation of 1 is called ________________ who runs the fastest ? (ONLY ANSWER IF YOU KNOW IT BECAUSE CORRECT ONE GETS BRAINLIEST)stephanie runs 14 feet per secondbrooke runs 589 feet in 44 seconds will runs 1 mile in 454 secondsrob runs 548 feet in 1 minute