What does the following code do?

package shop.ui;
import javax.swing.JOptionPane;
//import java.io.IOException;

final class PopupUI implements UI {
PopupUI() {}
public void displayMessage(String message) {
JOptionPane.showMessageDialog(null,message);
}
public void displayError(String message) {
JOptionPane.showMessageDialog(null,message,"Error",JOptionPane.ERROR_MESSAGE);
}
public void processMenu(UIMenu menu) {
StringBuffer b = new StringBuffer();
b.append(menu.getHeading());
b.append("\n");
b.append("Enter choice by number:");
b.append("\n");
for (int i = 1; i < menu.size(); i++) {
b.append(" " + i + ". " + menu.getPrompt(i));
b.append("\n");
}
String response = JOptionPane.showInputDialog(b.toString());
int selection;
try {
selection = Integer.parseInt(response, 10);
if ((selection < 0) || (selection >= menu.size()))
selection = 0;
} catch (NumberFormatException e) {
selection = 0;
}
menu.runAction(selection);
}
public String[] processForm(UIForm form) {
// TODO
String[]formArray = new String[form.size()];
for(int i=0;i {
String message = JOptionPane.showInputDialog(form.getPrompt(i));
formArray[i] = message;
}
return formArray;
}
}

Answers

Answer 1

Answer: what is this?

Explanation:


Related Questions

What do we call data that's broken down into bits and sent through a network?

Answers

Answer:

Bits

Explanation:

2. (8 points) When creating the Academic Database, there were several instances of data
validation. Data types were assigned to each field in the table to stop undesirable values from
being placed into certain fields. A presence check was used on fields that were listed as NOT
NULL, requiring some data to be input. Uniqueness validation was automatically assigned for
fields that were primary keys. Describe at least one field in the Academic Database a table
where range validation could have been used and describe at least one field in the Academic
Database where choice validation could have been used. Your answer should be addressed in
100 to 150 words.​

Answers

Answer:

See explaination

Explanation:

An Academic Database deals with the information pertaining to the records of students of an institute. The various fields which can be associated with a student are Name, Unique Identification Number, Marks in various subjects, Grades, Courses Taken and so on. Most of the fields mentioned above have some or other form of validation that is required for the DB to be consistent and follow the basic properties of a database.

One field where range validation can be used is MARKS. In the marks field, the range of marks will be say 0 to 100 and anything below 0 or above 100 must be reported to the database administrator. Another field where we can apply a range validation is AGE in which the range of age allowed could greater than say 10, if it is a college and maximum age could be say 60. Thus, the range check on the AGE field is 10 to 60.

One field where choice validation can be used is GENDER. In the gender field, there could be multiple choices like Male, Female and Others. Thus, out of the available choices we have to select only the available choice and only one choice must be selected where we can apply choice validation. Another field is COURSE, where we can have a list of courses a student can opt for and out of the available courses can select one.

Thus, there are multiple fields where we can apply various types of validation and it is important to explore the area for which the DB has been created understanding all the scenarios and attributes of the problems that are associated with that area.

(TCO 4) Give the contents of Register A after the execution of the following instructions:

Data_1 EQU $12
Data_2 EQU %01010101
LDAA #Data_1
ADDA #Data_2

A) $12
B) $67
C) $55
D) $57

Answers

It’s b.$67 I hope it helps I am not that good at technology I am good at other thing

4. Write an interface ObjectWithTwoParameters which has a method specification: double area (double d1, double d2) which returns the area of a particular object. Write three classes RectangleClass, TriangleClass, and CylinderClass which implement the interface you created. Also, write a demo class which creates objects of RectangleClass, TriangleClass, and CylinderClass and call the corresponding methods

Answers

Answer:

The java program for the given scenario is as follows.

import java.util.*;

//interface with method area

interface ObjectWithTwoParameters

{

double area (double d1, double d2);

}

class RectangleClass implements ObjectWithTwoParameters

{

//overriding area()

public double area (double d1, double d2)

{

return d1*d2;

}

}

class TriangleClass implements ObjectWithTwoParameters

{

//overriding area()

public double area (double d1, double d2)

{

return (d1*d2)/2;

}  

}

class CylinderClass implements ObjectWithTwoParameters

{

public double area (double d1, double d2)

{

return ( 2*3.14*d1*d1 + d2*(2*3.14*d1) );

}

}

public class Test

{

public static void main(String[] args)

{

//area displayed for all three shapes

ObjectWithTwoParameters r = new RectangleClass();

double arear = r.area(2, 3);

System.out.println("Area of rectangle: "+arear);

ObjectWithTwoParameters t = new TriangleClass();

double areat = t.area(4,5);

System.out.println("Area of triangle: "+areat);

ObjectWithTwoParameters c = new CylinderClass();

double areac = c.area(6,7);

System.out.println("Area of cylinder: "+areac);

}

}

OUTPUT

Area of rectangle: 6.0

Area of triangle: 10.0

Area of cylinder: 489.84

Explanation:

1. The program fulfils all the mentioned requirements.

2. The program contains one interface, ObjectWithTwoParameters, three classes which implement that interface, RectangleClass, TriangleClass and CylinderClass, and one demo class, Test, containing the main method.

3. The method in the interface has no access specifier.

4. The overridden methods in the three classes have public access specifier.

5. No additional variables have been declared.

6. The test class having the main() method is declared public.

7. The area of the rectangle, triangle and the cylinder have been computed as per the respective formulae.

8. The interface is similar to a class which can have only declarations of both, variables and methods. No method can be defined inside an interface.

9. The other classes use the methods of the interface by implementing the interface using the keyword, implements.

10. The object is created using the name of the interface as shown.

ObjectWithTwoParameters r = new RectangleClass();

D-H public key exchange Please calculate the key for both Alice and Bob.
Alice Public area Bob
Alice and Bob publicly agree to make
N = 50, P = 41
Alice chooses her Bob
picks his
Private # A = 19 private #
B= ?
------------------------------------------------------------------------------------------------------------------------------------------
I am on Alice site, I choose my private # A = 19.
You are on Bob site, you pick up the private B, B and N should have no common factor, except 1.
(Suggest to choose B as a prime #) Please calculate all the steps, and find the key made by Alice and Bob.
The ppt file of D-H cryptography is uploaded. You can follow the steps listed in the ppt file.
Show all steps.

Answers

Answer:

See explaination

Explanation:

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

What should the timing of transition slides be per minute?
Maintain the flow of the presentation to
slides per minute

Answers

Answer:

15 seconds

Explanation:

A presentation slide is supposed to be on for 15 seconds and stop to ask if anyone has any questions, if you are explaining something or reading alond with the slide it could be as long as you want it to be.

Answer:

4 slides per minute

Explanation:

How is a struck-by rolling object defined?

Answers

Sorry I don’t know I just needed points to ask my question

Answer:

Struck by rolling object is commonly defined as Struck-By Rolling Object Hazard because it was caused by rolling objects or any objects that moves in circular motion that could cause an injury or accident.

Explanation:


The equation of certain traveling waves is y(x.t) = 0.0450 sin(25.12x - 37.68t-0.523) where x and y are in
meters, and t in seconds. Determine the following:
(a) Amplitude. (b) wave number (C) wavelength. (d) angular frequency. (e) frequency: (1) phase angle, (g) the
wave propagation speed, (b) the expression for the medium's particles velocity as the waves pass by them, and (i)
the velocity of a particle that is at x=3.50m from the origin at t=21.os​

Answers

Answer:

A. 0.0450

B. 4

C. 0.25

D. 37.68

E. 6Hz

F. -0.523

G. 1.5m/s

H. vy = ∂y/∂t = 0.045(-37.68) cos (25.12x - 37.68t - 0.523)

I. -1.67m/s.

Explanation:

Given the equation:

y(x,t) = 0.0450 sin(25.12x - 37.68t-0.523)

Standard wave equation:

y(x, t)=Asin(kx−ωt+ϕ)

a.) Amplitude = 0.0450

b.) Wave number = 1/ λ

λ=2π/k

From the equation k = 25.12

Wavelength(λ ) = 2π/25.12 = 0.25

Wave number (1/0.25) = 4

c.) Wavelength(λ ) = 2π/25.12 = 0.25

d.) Angular frequency(ω)

ωt = 37.68t

ω = 37.68

E.) Frequency (f)

ω = 2πf

f = ω/2π

f = 37.68/6.28

f = 6Hz

f.) Phase angle(ϕ) = -0.523

g.) Wave propagation speed :

ω/k=37.68/25.12=1.5m/s

h.) vy = ∂y/∂t = 0.045(-37.68) cos (25.12x - 37.68t - 0.523)

(i) vy(3.5m, 21s) = 0.045(-37.68) cos (25.12*3.5-37.68*21-0.523) = -1.67m/s.

Write the definition of a function words_typed, that receives two parameters. The first is a person's typing speed in words per minute (an integer greater than or equal to zero). The second is a time interval in seconds (an integer greater than zero). The function returns the number of words (an integer) that a person with that typing speed would type in that time interval.

Answers

Answer:

   //Method definition of words_typed

   //The return type is int

   //Takes two int parameters: typingSpeed and timeInterval

   public static int words_typed(int typingSpeed, int timeInterval) {

       //Get the number of words typed by  

       //finding the product of the typing speed and the time interval

       //and then dividing the result by 60 (since the typing speed is in "words

       // per minute"  and the time interval is in "seconds")

       int numberOfWords = typingSpeed * timeInterval / 60;

       

       //return the number of words

       return numberOfWords;

       

   }        //end of method declaration

Explanation:

The code above has been written in Java and it contains comments explaining each of the lines of the code. Please go through the comments.

Answer:

I am writing the program in Python.

def words_typed(typing_speed,time_interval):

   typing_speed>=0

   time_interval>0

   no_of_words=int(typing_speed*(time_interval/60))

   return no_of_words

   

output=words_typed(20,30)

print(output)

Explanation:

I will explain the code line by line.

First the statement def words_typed(typing_speed,time_interval) is the definition of a function named words_typed which has two parameters typing_speed and time_interval.

typing_speed variable of integer type in words per minute.

time_interval variable of int type in seconds

The statements typing_speed>=0 and time_interval>0 means that value of typing_speed is greater than or equal to zero and value of time_interval is greater than zero as specified in the question.

The function words_typed is used to return the number of words that a  person with typing speed would type in that time interval. In order to compute the words_typed, the following formula is used:

   no_of_words=int(typing_speed*(time_interval/60))

The value of typing_speed is multiplied by value of time_interval in order to computer number of words and the result of the multiplication is stored in no_of_words. Here the time_interval is divided by 60 because the value of time_interval is in seconds while the value of typing_speed is in minutes. So to convert seconds into minutes the value of time_interval is divided by 60 because 1 minute = 60 seconds.

return no_of_words statement returns the number of words.

output=words_typed(20,30) statement calls the words_typed function and passed two values i.e 20 for typing_speed and 30 for time_interval.

print(output) statement displays the number of words a person with typing speed would type in that time interval, on the output screen.

Describe the Software Development Life Cycle. Describe for each phase of the SDLC how it can be used to create software for an Employee Payroll System that allows employees to log the number of hours completed in a work period and then generate their pay. Use Microsoft Word to complete this part of the assessment. Save your file as LASTNAME FIRSTNAME M08FINAL1 were LASTNAME is your lastname and FIRSTNAME is your first name. Upload your answer to this question; do not submit this assessment until you have completed all questions. This question is worth 25 points.

Answers

Answer:

Check the explanation

Explanation:

SDLC

SDLC stands for Software Development Life Cycle

It provides steps for developing a software product

It also checks for the quality and correctness of a software

The main aim of SDLC is to develop a software, which meets a customer requirements

SDLC involves various phases to develop a high-quality product for its end user

Phases of SDLC

           There are seven phases in a software development life cycle as follows,

Requirement Analysis   Feasibility Study   Design    Coding    Testing Deployment      Maintenance

kindly check the attached image below

Requirement analysis

This is the first stage in a SDLC.

In this phase, a detailed and precise requirements are collected from various teams by senior team members

It gives a clear idea of the entire project scope, opportunities and upcoming issues in a project

This phase also involves, planning assurance requirements and analyze risk involved in the project

Here, the timeline to finish the project is finalized

Feasibility Study

In this stage, the SRS document, that is “Software Requirement Specification” document is defined, which includes everything to be designed and developed during the life cycle of a project

Design

In this phase as the name indicates, software and system design documents are prepared, based on the requirement specification document

This enable us to define the whole system architecture

Two types of design documents are prepared in this phase as follows,

High-Level Design

Low-Level Design

Coding

In this phase, the coding of project is done in a selected programming language

Tasks are divided into many units and given to various developers

It is the longest phase in the SDLC

Testing

In this stage, the developed coding is tested by the testing team

The testing team, checks the coding in the user point of view

Installation/Deployment

In this stage, a product is released by the company to the client

Maintenance

Once the product is delivered to the client, the maintenance phase work will start by fixing errors, modifying and enhancing the product.

Employee Payroll System

Requirement analysis

Gather information from various team for requirement

Analyze the number of employees to handle the project

Timeline to finish the project, eg.1 month

Feasibility Study

The system requirements such as how many systems are required

Decide which software to be installed to handle the project.

For example, if we are going to develop the software using C language, then software for that has to be installed

The SRS document has to be prepared

Design

In this the HLD and LLD is prepared, the overall software architecture is prepared

The modules involved in coding are decided

Here the modules can be employee, payroll manager, Employee Log time, account details

The input and output are designed, such as employee name is the input and output is the salary for him, based on working hours

Coding

Here the coding is divided into various sections and given to 2 or more employees

One may code employee detail, one will code working hours of employees and one may code the banking details of employee

Testing

The coding is tested for syntax, declaration, data types and various kinds of error

The testing team will test the coding with various possible values

They may even check with wrong values and analyze the output for that

Installation

Now the software is installed in the client system and the client is calculating the payroll for an employee based on working hours in a month

Maintenance

If any error occurs, the team will clear the issue.

When a new employee joins, then the employee data will added to the database and the database is updated

Also if the client asks for any new features, it will done in this phase.

Write a class called DisArray with methods to convert a 1-dimensional array to a 2-dimensional array. The methods' name should be convert2D. You should create methods to convert int[] and String[], that can be tested against the following class. Your convert2D methods should choose the closest possible square-ish size for the 2D array. For example, if your input array is [10], its 2D conversion should be [3][4] or [4][3] -- you decide if you want to favor rows over columns. Your method should place the elements of the one-dimensional array into the two-dimensional array in row-major order, and fill the remaining elements with 0 (for integer arrays) or null (for String arrays). The process of filling unused elements with 0 or null is called padding. If the input array's length is a perfect square, e.g., [16], then your output should a square array, i.e., [4][4]. For any other size, your objective is to minimize the number of padded elements. For example, if your input is [10] you should opt for a [3][4] array instead of a [4][4]. The former will have only 2 padded elements; the latter 6.

Answers

Answer:

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

//Class header definition

public class DisArray {

   //First method with int array as parameter

   public static void convert2D(int[] oneD) {

       //1. First calculate the number of columns

       //a. get the length of the one dimensional array

       int arraylength = oneD.length;

       //b. find the square root of the length and typecast it into a float

       float squareroot = (float) Math.sqrt(arraylength);

       //c. round off the result and save in a variable called row

       int row = Math.round(squareroot);

       //2. Secondly, calculate the number of columns

       //a. if the square of the number of rows is greater than or equal to the

       //length of  the one dimensional array,

       //then to minimize padding, the number of

       //columns  is the same as the number of rows.

       //b. otherwise, the number of columns in one more than the

       // number of rows

       int col = ((row * row) >= arraylength) ? row : row + 1;

       //3. Create a 2D int array with the number of rows and cols

       int [ ][ ] twoD = new int [row][col];

       //4. Place the elements in the one dimensional array into

       //the two dimensional array.

       //a. First create a variable counter to control the cycle through the one

       // dimensional array.

       int counter = 0;

       //b. Create two for loops to loop through the rows and columns of the

       // two  dimensional array.

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

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

               //if counter is less then the length of the one dimensional array,

               //then  copy the element at that position into the two dimensional

               //array.  And also increment counter by one.

               if (counter < oneD.length) {

                   twoD[i][j] = oneD[counter];

                   counter++;

              }

              //Otherwise, just pad the array with zeros

               else {

                   twoD[i][j] = 0;

               }

           }

       }

       //You might want to create another pair of loop to print the elements

       //in the  populated two dimensional array as follows

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

           for (int j = 0; j < twoD[i].length; j++) {

               System.out.print(twoD[i][j] + " ");

           }

           System.out.println("");

       }

   }     //End of first method

   //Second method with String array as parameter

   public static void convert2D(String[] oneD) {

       //1. First calculate the number of columns

       //a. get the length of the one dimensional array

       int arraylength = oneD.length;

       //b. find the square root of the length and typecast it into a float

       float squareroot = (float) Math.sqrt(arraylength);

       //c. round off the result and save in a variable called row

       int row = Math.round(squareroot);

       //2. Secondly, calculate the number of columns

       //a. if the square of the number of rows is greater than or equal to the length of  

       //the one dimensional array, then to minimize padding, the number of

       //columns  is the same as the number of rows.

       //b. otherwise, the number of columns in one more than the

       //number of rows.

       int col = (row * row >= arraylength) ? row : row + 1;

       //3. Create a 2D String array with the number of rows and cols

       String[][] twoD = new String[row][col];

       //4. Place the elements in the one dimensional array into the two

       // dimensional array.

       //a. First create a variable counter to control the cycle through the one

       // dimensional array.

       int counter = 0;

       //b. Create two for loops to loop through the rows and columns of the

       //two  dimensional array.

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

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

               //if counter is less then the length of the one dimensional array,

               //then  copy the element at that position into the two dimensional

               //array.  And also increment counter by one.

               if (counter < oneD.length) {

                   twoD[i][j] = oneD[counter];

                   counter++;

               }

               //Otherwise, just pad the array with null values

               else {

                   twoD[i][j] = null;

               }

           }

       }

       //You might want to create another pair of loop to print the elements  

       //in the populated two dimensional array as follows:

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

           for (int j = 0; j < twoD[i].length; j++) {

               System.out.print(twoD[i][j] + " ");

           }

           System.out.println("");

       }

   }    // End of the second method

   //Create the main method

   public static void main(String[] args) {

       //1. Create an arbitrary one dimensional int array

       int[] x = {23, 3, 4, 3, 2, 4, 3, 3, 5, 6, 5, 3, 5, 5, 6, 3};

       //2. Create an arbitrary two dimensional String array

       String[] names = {"abc", "john", "dow", "doe", "xyz"};

       

       //Call the respective methods

       convert2D(x);

       System.out.println("");

       convert2D(names);

   }         // End of the main method

}            // End of class definition

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

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

Sample Output

23 3 4 3  

2 4 3 3  

5 6 5 3  

5 5 6 3  

abc john dow  

doe xyz null

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

Explanation:

The above code has been written in Java and it contains comments explaining each line of the code. Please go through the comments. The actual executable lines of code are written in bold-face to distinguish them from the comments.

The Taylor series expansion for ax is: Write a MATLAB program that determines ax using the Taylor series expansion. The program asks the user to type a value for x. Use a loop for adding the terms of the Taylor series. If cn is the nth term in the series, then the sum Sn of the n terms is . In each pass calculate the estimated error E given by . Stop adding terms when . The program displays the value of ax. Use the program to calculate: (a) 23.5 (b) 6.31.7 Compare the values with those obtained by using a calculator.

Answers

Answer: (a). 11.3137

(b). 22.849

Explanation:

Provided below is a step by step analysis to solving this problem

(a)

clc;close all;clear all;

a=2;x=3.5;

E=10;n=0;k=1;sn1=0;

while E >0.000001

cn=((log(a))^n)*(x^n)/factorial(n);

sn=sn1+cn;

E=abs((sn-sn1)/sn1);

sn1=sn;

n=n+1;

k=k+1;

end

fprintf('2^3.5 from tailor series=%6.4f after adding n=%d terms\n',sn,n);

2^3.5 from tailor series=11.3137 after adding n=15 terms

disp('2^3.5 using calculator =11.3137085');

Command window:

2^3.5 from tailor series=11.3137 after adding n=15 terms

2^3.5 using calculator =11.3137085

(b)

clc;close all;clear all;

a=6.3;x=1.7;

E=10;n=0;k=1;sn1=0;

while E >0.000001

cn=((log(a))^n)*(x^n)/factorial(n);

sn=sn1+cn;

E=abs((sn-sn1)/sn1);

sn1=sn;

n=n+1;

k=k+1;

end

fprintf('6.3^1.7 from tailor series=%6.4f after adding n=%d terms\n',sn,n);

disp('6.3^1.7 using calculator =22.84961748');

Command window:

6.3^1.7 from tailor series=22.8496 after adding n=16 terms

6.3^1.7 using calculator =22.84961748

cheers i hope this helped !!!

Box one:
logical
Date and time
Compatibility
Web

Box 2:
&
$
=
#

Box 3:
Not
If
Or
Sum

Answers

Box One is logical
Box Two I’m not sure, it depends on what language or program or website you’re using, however I’d assume it would be ‘=‘
Box Three is If

what should i name my slideshow if its about intellectual property, fair use, and copyright

Answers

Answer:

You should name it honest and sincere intention

Explanation:

That is a good name for what you are going to talk about in your slideshow.

Design and implement the Heap.h header using the given Heap class below:
template
class Heap
public:
Heap();
Heap(const T elements[], int arraySize); //
Remove the root from the heap and maintain the heap property
T remove() throw (runtime_error);
// Insert element into the heap and maintain the heap property
void add(const T& element);
// Get the number of element in the heap
int getSize() const;
private:
vector v;
Removing the root in a heap - after the root is removed, the tree must be rebuilt to maintain the heap property:
Move the last node to replace the root;
Let the root be the current node;
While (the current node has children and the current node is smaller than one of its children) Swap the current node with the larger of its children; The current node now is one level down;}
Adding a new node - to add a new node to the heap, first add it to the end of the heap and then rebuild the tree as follows:
Let the last node be the current node;
While (the current node is greater than its parent)
{Swap the current node with its parent; The current node now is one level up:}
To test the header file, write the heapSort function and use the following main program:
#include
#include "Heap.h"
using namespace std;
template
void heapSort(T list[], int arraySize) 1/
your code here .. p
int main()
const int SIZE = 9;
int list[] = { 1, 2, 3, 4, 9, 11, 3, 1, 2 }; heapSort(list, SIZE);
cout << "Sorted elements using heap: \n";
for (int i = 0; i < SIZE; i++) cout << list[i] << " ";
cout << endl;
system("pause");
return;
Sample output:
Sorted elements using heap:
1 1 2 3 3 4 7 9 11

Answers

Answer:

See explaination

Explanation:

/* Heap.h */

#ifndef HEAP_H

#define HEAP_H

#include<iostream>

using namespace std;

template<class T>

class Heap

{

public:

//constructor

Heap()

{

arr = nullptr;

size = maxsize = 0;

}

//parameterized constructor

Heap(const T elements[], int arraySize)

{

maxsize = arraySize;

size = 0;

arr = new T[maxsize];

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

{

add(elements[i]);

}

}

//Remove the root from the heap and maintain the heap property

T remove() //code is altered

{

T item = arr[0];

arr[0] = arr[size-1];

size--;

T x = arr[0];

int parent = 0;

while(1)

{

int child = 2*parent + 1;

if(child>=size) break;

if(child+1 < size &&arr[child+1]>arr[child])

child++;

if(x>=arr[child]) break;

arr[parent] = arr[child];

parent = child;

}

arr[parent] = x;

return item;

}

//Insert element into the heap and maintain the heap property

void add(const T&element)

{

if(size==0)

{

arr[size] = element;

size++;

return;

}

T x = element;

int child = size;

int parent = (child-1)/2;

while(child>0 && x>arr[parent])

{

arr[child] = arr[parent];

child = parent;

parent = (child-1)/2;

}

arr[child] = x;

size++;

}

//Get the number of element in the heap

int getSize() const

{

return size;

}

private:

T *arr; //code is altered

int size, maxsize;

};

#endif // HEAP_H

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/* main.cpp */

#include<iostream>

#include "Heap.h"

using namespace std;

template <typename T>

void heapSort(T list[], int arraySize)

{

Heap<T> heap(list, arraySize);

int n = heap.getSize();

for(int i=n-1; i>0; i--)

{

list[i] = heap.remove();

}

}

int main()

{

const int SIZE = 9;

int list[] = {1, 7, 3, 4, 9, 11, 3, 1, 2};

heapSort<int>(list, SIZE);

cout << "Sorted elements using heap: \n";

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

cout << list[i] << " ";

cout <<endl;

system("pause");

return 0;

}

Assume the existence of an UNSORTED ARRAY of n characters. You are to trace the CS111Sort algorithm (as described here) to reorder the elements of a given array. The CS111Sort algorithm is an algorithm that combines the SelectionSort and the InsertionSort following the steps below: 1. Implement the SelectionSort Algorithm on the entire array for as many iterations as it takes to sort the array only to the point of ordering the elements so that the last n/2 elements are sorted in increasing (ascending) order. 2. Implement the InsertionSort Algorithm to sort the first half of the resulting array elements so that these elements are sorted in decreasing (descending) order.

Answers

Answer:

class Main {

  public static void main(String[] args) {

      char arr[] = {'T','E','D','R','W','B','S','V','A'};

      int n = arr.length;

      System.out.println("Selection Sort:");

      System.out.println("Iteration\tArray\tComparisons");

      long comp1 = selectionSort(arr);

      System.out.println("Total comparisons: "+comp1);

      System.out.println("\nInsertion Sort:");

      System.out.println("Iteration\tArray\tComparisons");

      long comp2 = insertionSort(arr);

      System.out.println("Total Comparisons: "+comp2);

      System.out.println("\nOverall Total Comparisons: "+(comp1+comp2));

  }

  static long selectionSort(char arr[]) {

      // applies selection sort for n/2 elements

      // returns number of comparisons

      int n = arr.length;

      long comparisons = 0;

 

      // One by one move boundary of unsorted subarray

      for (int i = n-1; i>=n-n/2; i--) {

              // Find the minimum element in unsorted array

              int max_idx = i;

              for (int j = i-1; j>=0; j--) {

                      // there is a comparison everytime this loop returns

                      comparisons++;

                      if (arr[j] > arr[max_idx])

                              max_idx = j;

              }

              // Swap the found minimum element with the first

              // element

              char temp = arr[max_idx];

              arr[max_idx] = arr[i];

              arr[i] = temp;

              System.out.print(n-1-i+"\t");

              printArray(arr);

              System.out.println("\t"+comparisons);

      }

     

      return comparisons;

  }

  static long insertionSort(char arr[]) {

      // applies insertion sort for n/2 elements

      // returns number of comparisons

      int n = arr.length;

      n = n-n/2;   // sort only the first n/2 elements

      long comparisons = 0;

      for (int i = 1; i < n; ++i) {

          char key = arr[i];

          int j = i - 1;

          /* Move elements of arr[0..i-1], that are

                  greater than key, to one position ahead

                  of their current position */

          while (j >= 0) {

              // there is a comparison everytime this loop runs

              comparisons++;

              if (arr[j] > key) {

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

              } else {

                  break;

              }

              j--;

          }

          arr[j + 1] = key;

          System.out.print(i-1+"\t");

          printArray(arr);

          System.out.println("\t"+comparisons);

      }

      return comparisons;

  }  

  static void printArray(char arr[]) {

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

          System.out.print(arr[i]+" ");

  }

}

Explanation:

Explanation is in the answer.

Write the method addItemToStock to add an item into the grocery stock array. The method will: • Insert the item with itemName add quantity items to stock. • If itemName is already present in stock, increase the quantity of the item, otherwise add new itemName to stock. • If itemName is not present in stock, insert at the first null position in the stock array. After the insertion all items are adjacent in the array (no null positions between two items). • Additionally, double the capacity of the stock array if itemName is a new item to be inserted and the stock is full.

Answers

Answer:

#include <stdio.h>

#include <iostream>

using namespace std;

int main()

{

   //varible to indicate size of the array

   int size=20;

   //arrays to hold grocery item names and their quantities

   std::string grocery_item[size];

   int item_stock[size];

   //variables to hold user input

   std::string itemName;

   int quantity;

   //variable to check if item is already present

   bool itemPresent=false;

   //variable holding full stock value

   int full_stock=100;

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

   {

       grocery_item[n]="";

       item_stock[n]=0;

   }

   do

   {

       std::cout << endl<<"Enter the grocery item to be added(enter q to quit): ";

       cin>>itemName;

       if(itemName=="q")

       {

               cout<<"Program ends..."<<endl; break;

       }

       else

       {

           std::cout << "Enter the grocery item stock to be added: ";

           cin>>quantity;

       }

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

   {

       if(grocery_item[n]==itemName)

       {

           itemPresent=true;

           item_stock[n]=item_stock[n]+quantity;

       }

   }

   if(itemPresent==false)

   {

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

       {

           if(grocery_item[n]=="")

           {

               itemPresent=true;

               grocery_item[n]=itemName;

               item_stock[n]=item_stock[n]+quantity;

           }

       

           if(item_stock[n]==full_stock)

           {

               item_stock[n]=item_stock[n]*2;

           }

       }

   }

   }while(itemName!="q");

   return 0;

}

OUTPUT

Enter the grocery item to be added(enter q to quit): rice

Enter the grocery item stock to be added: 23

Enter the grocery item to be added(enter q to quit): bread

Enter the grocery item stock to be added: 10

Enter the grocery item to be added(enter q to quit): bread

Enter the grocery item stock to be added: 12

Enter the grocery item to be added(enter q to quit): q

Program ends...

Explanation:

1. The length of the array and the level of full stock has been defined inside the program.

2. Program can be tested for varying values of length of array and full stock level.

3. The variables are declared outside the do-while loop.

4. Inside do-while loop, user input is taken. The loop runs until user opts to quit the program.

5. Inside do-while loop, the logic for adding the item to the array and adding the quantity to the stock has been included. For loops have been used for arrays.

6. The program only takes user input for the item and the respective quantity to be added.

This represents a group of Book values as a list (named books). We can then dig through this list for useful information and calculations by calling the methods we're going to implement. class Library: Define the Library class. • def __init__(self): Library constructor. Create the only instance variable, a list named books, and initialize it to an empty list. This means that we can only create an empty Library and then add items to it later on.

Answers

Answer:

class Library:      def __init__(self):        self.books = [] lib1 = Library()lib1.books.append("Biology") lib1.books.append("Python Programming Cookbook")

Explanation:

The solution code is written in Python 3.

Firstly, we can create a Library class with one constructor (Line 2). This constructor won't take any input parameter value. There is only one instance variable, books, in the class (Line 3). This instance variable is an empty list.

To test our class, we can create an object lib1 (Line 5).  Next use that object to add the book item to the books list in the object (Line 6-8).  

You're asked to implement classes to manage personnels at a hospital. Create a class diagram that includes classes (and some variables and methods) that manage employees and patients in a hospital management program. Use interfaces and inheritance to create a hierarchy of all employees including doctors, nurses, and patients. Then, write the code outline of these classes. You don't have to implement any of the methods or a main method. Just add a simple comment or println statement describing what the method would do.

Answers

Answer:

Check the explanation

Explanation:

Kindly check the attached image below to see the step by step explanation to the question above.

Write an expression to detect that the first character of userinput matches firstLetter.

import java.util.Scanner; public class CharMatching { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); String userInput; char firstLetter; userInput = scnr.nextLine(); firstLetter = scnr.nextLine().charAt(0); if (/* Your solution goes here */) { System.out.println("Found match: " + firstLetter); } else { System.out.println("No match: " + firstLetter); } return; } }

Answers

Answer: Provided in the explanation segment

Explanation:

Below is the code to run this program.

we have that the

Program

import java.util.Scanner;

public class CharMatching {

  public static void main(String[] args) {

      //Scanner object for keyboard read

      Scanner scnr=new Scanner(System.in);

      //Variable for user input string

      String userInput;

      //Variable for firstletter input

      char firstLetter;

      //Read user input string

      userInput=scnr.nextLine();

      //Read first letter from user

      firstLetter=scnr.nextLine().charAt(0);

      //Comparison without case sensititvity and result

      if(Character.toUpperCase(firstLetter)==Character.toUpperCase(userInput.charAt(0))) {

          System.out.println("Found match: "+firstLetter);

      }

      else {

          System.out.println("No match: "+firstLetter);

      }

  }

}

Output

Hello

h

Found match: h

cheers i hope this helped !!!

In this lab, you use the flowchart and pseudocode found in the figures below to add code to a partially created C++ program. When completed, college admissions officers should be able to use the C++ program to determine whether to accept or reject a student, based on his or her test score and class rank.

// HouseSign.cpp - This program calculates prices for custom made signs.

#include
#include
using namespace std;
int main()
{
// This is the work done in the housekeeping() function
// Declare and initialize variables here
// Charge for this sign
// Color of characters in sign
// Number of characters in sign
// Type of wood

// This is the work done in the detailLoop() function
// Write assignment and if statements here

// This is the work done in the endOfJob() function
// Output charge for this sign
cout << "The charge for this sign is $" << charge << endl;
return(0);
}

Answers

Here is the complete question.

In this lab, you use the flowchart and pseudocode found in the figures below to add code to a partially created C++ program. When completed, college admissions officers should be able to use the C++ program to determine whether to accept or reject a student, based on his or her test score and class rank.

start input testScore,

classRank if testScore >= 90 then if classRank >= 25 then output "Accept"

else output "Reject" endif else if testScore >= 80

then if classRank >= 50 then output "Accept" else output "Reject" endif

else if testScore >= 70

then if classRank >= 75 then output "Accept"

else output "Reject"

endif else output "Reject"

endif

endif

endif

stop

Study the pseudocode in picture above. Write the interactive input statements to retrieve: A student’s test score (testScore) A student's class rank (classRank) The rest of the program is written for you. Execute the program by clicking "Run Code." Enter 87 for the test score and 60 for the class rank. Execute the program by entering 60 for the test score and 87 for the class rank.

[comment]: <> (3. Write the statements to convert the string representation of a student’s test score and class rank to the integer data type (testScore and classRank, respectively).)

Function: This program determines if a student will be admitted or rejected. Input: Interactive Output: Accept or Reject

*/ #include using namespace std; int main() { // Declare variables

// Prompt for and get user input

// Test using admission requirements and print Accept or Reject

if(testScore >= 90)

{ if(classRank >= 25)

{ cout << "Accept" << endl; }

else

cout << "Reject" << endl; }

else { if(testScore >= 80)

{ if(classRank >= 50)

cout << "Accept" << endl;

else cout << "Reject" << endl; }

else { if(testScore >= 70)

{ if(classRank >=75) cout << "Accept" << endl;

else cout << "Reject" << endl; }

else cout << "Reject" << endl; } } } //End of main() function

Answer:

Explanation:

The objective here is to use the flowchart and pseudocode found in the figures below to add code to a partially created C++ program. When completed, college admissions officers should be able to use the C++ program to determine whether to accept or reject a student, based on his or her test score and class rank.

PROGRAM:

#include<iostream>

using namespace std;

int main(){

// Declare variables

int testScore, classRank;

// Prompt for and get user input

cout<<"Enter test score: ";

cin>>testScore;

cout<<"Enter class rank: ";

cin>>classRank;

// Test using admission requirements and print Accept or Reject

if(testScore >= 90)  

{ if(classRank >= 25)

{ cout << "Accept" << endl; }

else

cout << "Reject" << endl;

}

else { if(testScore >= 80)

{ if(classRank >= 50)

cout << "Accept" << endl;

else cout << "Reject" << endl; }

else { if(testScore >= 70)

{ if(classRank >=75) cout << "Accept" << endl;

else cout << "Reject" << endl;

}

else cout << "Reject" << endl; }

}

return 0;

} //End of main() function

OUTPUT:

See the attached file below:

6 things you should consider when planning a PowerPoint Presentation.

Answers

Answer: I would suggest you consider your audience and how you can connect to them. Is your presentation, well, presentable? Is whatever you're presenting reliable and true? Also, no more than 6 lines on each slide. Use colors that contrast and compliment. Images, use images. That pulls whoever you are presenting to more into your presentation.

Explanation:

For dinner, a restaurant allows you to choose either Menu Option A: five appetizers and three main dishes or Menu Option B: three appetizers and four main dishes. There are six kinds of appetizer on the menu and five kinds of main dish.

How many ways are there to select your menu, if...

a. You may not select the same kind of appetizer or main dish more than once.
b. You may select the same kind of appetizer and/or main dish more than once.
c. You may select the same kind of appetizer or main dish more than once, but not for all your choices, For example in Menu Option A, it would be OK to select four portions of 'oysters' and one portion of 'pot stickers', but not to select all five portions of 'oysters'.)

In each case show which formula or method you used to derive the result.

Answers

Answer:

The formula used in this question is called the probability of combinations or combination formula.

Explanation:

Solution

Given that:

Formula applied is stated as follows:

nCr = no of ways to choose r objects from n objects

  = n!/(r!*(n-r)!)

The Data given :

Menu A : 5 appetizers and 3 main dishes

Menu B : 3 appetizers and 4 main dishes

Total appetizers - 6

Total main dishes - 5

Now,

Part A :

Total ways = No of ways to select menu A + no of ways to select menu B

          = (no of ways to select appetizers in A)*(no of ways to select main dish in A) + (no of ways to select appetizers in B)*(no of ways to select main dish in B)

          = 6C5*5C3 + 6C3*5C4

          = 6*10 + 20*5

          = 160

Part B :

Since, we can select the same number of appetizers/main dish again so the number of ways to select appetizers/main dishes will be = (total appetizers/main dishes)^(no of appetizers/main dishes to be selected)

Total ways = No of ways to select menu A + no of ways to select menu B  

          = (no of ways to select appetizers in A)*(no of ways to select main dish in A) + (no of ways to select appetizers in B)*(no of ways to select main dish in B)

          = (6^5)*(5^3) + (6^3)*(5^4)

          = 7776*125 + 216*625

          = 1107000

Part C :

No of ways to select same appetizers and main dish for all the options

= No of ways to select menu A + no of ways to select menu B  

= (no of ways to select appetizers in A)*(no of ways to select main dish in A) + (no of ways to select appetizers in B)*(no of ways to select main dish in B)

=(6*5) + (6*5)

= 60

Total ways = Part B - (same appetizers and main dish selected)      

= 1107000 - 60

= 1106940

A user has called the company help desk to inform them that their Wi-Fi enabled mobile device has been stolen. A support ticket has been escalated to the appropriate team based on the corporate security policy. The security administrator has decided to pursue a device wipe based on corporate security policy. However, they are unable to wipe the device using the installed MDM solution. What is one reason that may cause this to happen?

Answers

Answer:

The software can't locate the device

Explanation:

The device wasn't properly setup in order for the software to locate it.

Write a program named RectangleArea to calculate the area of a rectangle with a length of 15.8 and a width of 7.9. The program should have two classes, one is the RectangleArea holding the Main(), and the other one is Rectangle. The Rectangle class has three members: a property of length, a property of width, and a method with a name of CalArea() to calculate the area. You can invoke the auto-provided constructor or write a self-defined constructor to initialize the rectangle. Calculate and display the area of the rectangle by first initialize an object named myRectangle and then calculate its area using the CalArea() method.

Answers

Answer:

public class RectangleArea {

   public static void main(String[] args) {

       Rectangle myRectangle = new Rectangle(15.8, 7.9);

       double calArea = myRectangle.calcArea(15.8, 7.9);

       System.out.println("The area is "+ calArea);

   }

}

class Rectangle{

   private double length;

   private double width;

   //Defined Constructor

   public Rectangle(double length, double width) {

       this.length = length;

       this.width = width;

   }

   public double calcArea(double len, double wi){

       return len* wi;

   }

}

Explanation:

This is solved with Java programming languageStart by creating both classes RectangleArea and and RectangleSInce both classes are in the same file, only one can be publicClass Rectangle contains the three members are decribed by the questionprivate double length, private double width and the method calcArea(). It also has a sefl-declared constructor.In the class RectangleArea, an object of Rectangle is created and initialized.The method calcArea is called using the created object and the value is printed.

3. You are working for a usability company that has recently completed a usability study of an airline ticketing system. They conducted a live AB testing of the original website and a new prototype your team developed. They brought in twenty participants into the lab and randomly assigned them to one of two groups: one group assigned to the original website, and the other assigned to the prototype. You are provided with the data and asked to perform a hypothesis test. Using the standard significance value (alpha level) of 5%, compute the four step t-test and report all important measurements. You can use a calculator or SPSS or online calculator to compute the t-test. (4 pts)

Answers

Answer:

Check the explanation

Explanation:

Let the population mean time on task of original website be [tex]\mu_1[/tex] and that of new prototype be [tex]\mu_2[/tex]

Here we are to test

[tex]H_0:\mu_1=\mu_2\;\;against\;\;H_1:\mu_1<\mu_2[/tex]

The data are summarized as follows:

                                                       Sample 1             Sample 2

Sample size                                        n=20                    n=20

Sample mean                                 [tex]\bar{x}_1=243.4[/tex]             [tex]\bar{x}_2=253.4[/tex]

Sample SD                                     s1=130.8901          s2=124.8199

The test statistic is obtained from online calculator as

t=-0.23

The p-value is given by 0.821

As the p-value is more than 0.05, we fail to reject the null hypothesis at 5% level of significance and hence conclude that there is no statistically significant difference between the original website and the prototype developed by the team at 5% level of significance.

g Create your own data file consisting of integer, double or String values. Create your own unique Java application to read all data from the file echoing the data to standard output. After all data has been read, display how many data were read. For example, if 10 integers were read, the application should display all 10 integers and at the end of the output, print "10 data values were read" Demonstrate your code compiles and runs without issue. Respond to other student postings by enhancing their code to write the summary output to a file instead of standard output.

Answers

Answer:

See explaination

Explanation:

//ReadFile.java

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class ReadFile

{

public static void main(String[] args)

{

int elementsCount=0;

//Create a File class object

File file=null;

Scanner fileScanner=null;

String fileName="sample.txt";

try

{

//Create an instance of File class

file=new File(fileName);

//create a scanner class object

fileScanner=new Scanner(file);

//read file elements until end of file

while (fileScanner.hasNext())

{

double value=fileScanner.nextInt();

elementsCount++;

}

//print smallest value

System.out.println(elementsCount+" data values are read");

}

//Catch the exception if file not found

catch (FileNotFoundException e)

{

System.out.println("File Not Found");

}

}

}

Sample output:

sample.txt

10

20

30

40

50

output:

5 data values are read

Which of the following is an example of the rewards & consequences characteristic of an organization?
OOO
pay raise
time sheets
pay check
pay scale

Answers

Answer:

Pay raise is an example of the rewards & consequences characteristic of an organization.

I think its pay rase?

What is blue L.E.D. light

Answers

The invention of blue LEDs meant that blue, red, and green could all be combined to produce white LED light, which can function as an alternative energy-saving light source.
A blue led light is just a the color blue with the LED strips


3.34 LAB: Mad Lib - loops in C++

Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.

Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input is quit 0.

Ex: If the input is:
apples 5
shoes 2
quit 0

the output is:
Eating 5 apples a day keeps the doctor away.
Eating 2 shoes a day keeps the doctor away.

Make sure your answer is in C++.

Answers

Answer:

A Program was written to carry out some set activities. below is the code program in C++ in the explanation section

Explanation:

Solution

CODE

#include <iostream>

using namespace std;

int main() {

string name; // variables

int number;

cin >> name >> number; // taking user input

while(number != 0)

{

// printing output

cout << "Eating " << number << " " << name << " a day keeps the doctor away." << endl;

// taking user input again

cin >> name >> number;

}

}

Note: Kindly find an attached copy of the compiled program output to this question.

In this exercise we have to use the knowledge in computational language in C++ to describe a code that best suits, so we have:

The code can be found in the attached image.

What is looping in programming?

In a very summarized way, we can describe the loop or looping in software as an instruction that keeps repeating itself until a certain condition is met.

To make it simpler we can write this code as:

#include <iostream>

using namespace std;

int main() {

string name; // variables

int number;

cin >> name >> number; // taking user input

while(number != 0)

{

// printing output

cout << "Eating " << number << " " << name << " a day keeps the doctor away." << endl;

// taking user input again

cin >> name >> number;

}

}

See more about C++ at brainly.com/question/19705654

Other Questions
Answer ASAP PLZ!!!! I need help (>~ which of the following best describes a rhetorical device? Please help me out! i have a few more of these questions, about 5 HELP ASAP PLEASE! EVERY ANSWER IS APPRECIATED! THANK YOU! Nitrogen gas was collected by water displacement. What was the pressure of the N2 collected if the temperature was 50 degrees celcius? what is the range of the function f(x)=3x^2+12x + 18 what is the slope of the line through (2,-1) and (-2,-3) please please help i will mark brainlist What did the invention of the telegraph allow people to do for the first time?A) send a message across the country in a week's timeB) hear someone's voice who is standing many miles awayC) send a message almost instantly from a great distanceD) see an object clearly that is many miles in the distance Which layer best represents the mantle?A. 1B. 2C.3D.4 HELP ME PLZZZ!!!!!!!!!!!!! TRUE or FALSE: Education was more important in the Renaissance than it was in the Middle Ages. * On the venn diagram, which region(s) represent the union of set A and set B (AuB)? PLEASE HELP ME WITH MY GEOMETRY 20 POINTS f(x) = 16x2 + 32x - 9? 6. What does the detail "He never looked at his father anymore, nor at his mother" reveal about Peter in paragraph148?A He is afraid of his parents.B He has grown uncomfortable with human interaction.C He has no interest in listening to his parents.D He no longer respects his parents. Read the excerpt from the article "The Wolves Among Us".Wolves are exceptional pack hunters. This is why they are able to take down large prey such as moose or deer by working together as a seamless team. Wolf pups as young as eight months old begin helping on the hunt. Wolves can reach speeds of up to 40 miles per hour when chasing prey, and their thick, double-coated fur enables them to keep warm in even the coldest arctic temperatures. Their large, powerful paws can reach up to 5 inches across and help to propel them quickly across the snow.Select the statement from the text that demonstrates the text's structure in "The Wolves Among Us". Their large, powerful paws can reach up to 5 inches across and help to propel them quickly across the snow. This is why they are able to take down large prey such as moose or deer by working together as a seamless team. Wolf pups as young as eight months old begin helping on the hunt. Wolves are exceptional pack hunters. How did the second set of prophecies from the witches come true? In Macbeth SHOW WORK: Evaluate f(-2) f(x)= 3/2x-4 What is the cause of Angelman Syndrome?a) A mutation that occurs randomly after birth or due to a viral infection in the mother during pregnancy.b) The shutting off of the paternal chromosome and the deletion on Chromosome 15 from the mother.c) The shutting off of the maternal chromosome and the deletion on Chromosome 15 from the father.d) A large deletion of chromosome 15 that is inherited from each parent.