Questions
c++ do add comments for better understanding Lapindrome is defined as a string which when split...

c++

do add comments for better understanding

Lapindrome is defined as a string which when split in the middle, gives two halves having the same characters and same frequency of each character. If there are odd number of characters in the string, we ignore the middle character and check for lapindrome. For example gaga is a lapindrome, since the two halves ga and ga have the same characters with same frequency. Also, abccab, rotor and xyzxy are a few examples of lapindromes. Note that abbaab is NOT a lapindrome. The two halves contain the same characters but their frequencies do not match.
Your task is simple, declare a C++ Class Lapindrome that has a function checkLapindrome which display Yes if the string is Lapindrome otherwise, it should display No. The structure of the Class is given below. You are required to implement every function given in the class Lapindrome.

class Lapindrome
{
private:
int size; char* cstr;
public:
Lapindrome (int size=10); //initialize size and cstr
void setStr(char* cstr); //Assign the value of cstr to member variable cstr
char* getStr();
//returns the string cstr. void checkLapindrome (); //Display Yes if the cstr is Lapindrome otherwise No ~Lapindrome();
//Destructor

};

In: Computer Science

Would you consider a career in UX? Why or why not? How much experience/knowledge do you...

Would you consider a career in UX? Why or why not?

How much experience/knowledge do you have in user interface design, prototyping and usability?

In: Computer Science

Consider the following program that creates an ArrayList of objects of a type A, and sorst...

Consider the following program that creates an ArrayList of objects of a type A, and sorst them. Supply the missing code. Sample output when you run the program is shown below.

import java.util.*;

class A

{ int i, j, k;

public A(int i, int j, int k){

this.i=i;

this.j=j;

this.k=k;

}

public String toString(){

return "A("+i+","+j+","+k+")";

}

}

class SortA {

public static void main(String[] args){

ArrayList aL=new ArrayList();

Random rand= new Random(1000); //1000 is a seed value

for (int p=0; p<10; p++){

int i = rand.nextInt(100);

int j = rand.nextInt(200);

int k = rand.nextInt(300);

aL.add(new A(i, j, k));

}

System.out.println("----- Original arraylist------");

for (A a: aL){

System.out.println(a);

}

System.out.println("----- Sorting by first integer-------");

/*YOUR CODE - Use anonymous interface types to sort by first integer Field in A, and then print the resulting ArrayList */

System.out.println("----- Sorting by second integer-------");

/*YOUR CODE - Use anonymous interface types to sort by the second integer Field in A, and then print the resulting ArrayList */

System.out.println("----- Sorting by third integer-------"); /*YOUR CODE - Use anonymous interface types to sort by the third integer Field in A, and then print the resulting ArrayList */

} }

Output

----- Original list -------

A(87,135,276)

A(24,192,149)

A(41,45,164)

A(50,179,259)

A(72,183,36)

A(75,46,202)

A(23,41,222)

A(71,189,202)

A(93,142,49)

A(42,35,176)

----- Sorting by first integer-------

A(23,41,222)

A(24,192,149)

A(41,45,164)

A(42,35,176)

A(50,179,259)

A(71,189,202)

A(72,183,36)

A(75,46,202)

A(87,135,276)

A(93,142,49)

----- Sorting by second integer-------

A(42,35,176)

A(23,41,222)

A(41,45,164)

A(75,46,202)

A(87,135,276)

A(93,142,49)

A(50,179,259)

A(72,183,36)

A(71,189,202)

A(24,192,149)

----- Sorting by third integer-------

A(72,183,36)

A(93,142,49)

A(24,192,149)

A(41,45,164)

A(42,35,176)

A(75,46,202)

A(71,189,202)

A(23,41,222)

A(50,179,259)

A(87,135,276)

In: Computer Science

C program //In this assignment, we will find the smallest positive integer that // can be...

C program

//In this assignment, we will find the smallest positive integer that
// can be expressed as a sum of two positive cube numbers in two distinct ways.
// More specifically, we want to find the smallest n such that n == i1*i1*i1 + j1*j1*j1,
// n == i2*i2*i2 + j2*j2*j2, and (i1, j1) and (i2, j2) are not the same in the sense that
// not only (i1, j1) not euqal to (i2, j2), but also (i1, j1) not equal to (j2, i2).
// We practice using loops in this assignment.
// Also, we practice how to do an early exit in a loop. We exit the loop once we find the smallest n.
// Once we are done, we will be delighted surprised to find out that this number already played a big role in
// our computer science study.
#include <stdio.h>
int main()
{
   int i, j, n;

   //We assume the smallest such n is no more than 1000000
   for(n=1; n<=1000000; n++)
   {
       //Use count to record the number of different ways of summing two positive cube numbers to n
       int count = 0;
       //TO DO
       //Fill in code below

   }


   //Do not change code below
printf("%d is the solution:\n", n);
   for(i=1; i<=100; i++)
       for(j = i; j<= 100; j++)
           {
               if (i*i*i + j*j*j == n)
               {
                   printf("%d * %d * %d + %d * %d * %d = %d\n", i, i, i, j, j, j, n);
}
           }

   return 0;
   //Do not try to hard code the solution, that is not the way to learn.
}

In: Computer Science

2.Find an error in the following program var tvShow = "The Office"; if (tvShow =null) {...

2.Find an error in the following program

var tvShow = "The Office";

if (tvShow =null) {

   console.log("You did not enter a TV show.");

else {

   console.log(tvShow+ “  “);

}

3.Write a statement that assigns finalResult with the division of number1 by number2. Ex: If number1 is 6 and number2 is 2, finalResult is 3.

Var number1=6;

Var number2=2;

__________________________________________ (write an arithmetic calculation which gives the result 0)

Var finalResult=0;

4.What is the final value of numItems?

bonus = 0;

numItems = 1;

if (bonus > 10) {

   numItems = numItems + 3;

}

Solution:

5.Display elements at indices 2 and 3 in the array userNumbers separated by a space.

Var userNumbers=[1,6,41,8,24,4];

/* Your Solution Goes here */

6. Matching basic document tag order

7. The HTML below has an error. What deprecated tag is causing the error?

<!DOCTYPE html>

<html lang="en">

  <meta charset="UTF-8">

  <title>Learning HTML</title>

  <body>

    <center>This page uses deprecated HTML.</center>

  </body>

</html>

8.What is the difference between line breaks and Whitespace in html?

9.What is output to the console?

var names = [];

names[0] = "Sue";

names[1] = "Bob";

names[2] = "Jeff";

console.log(names[0] + names[1]);

10.Write the  missing table tags in the following program.

<table>

  (a)

    <th>Head 1 (b)

    <th>Head 2</th>

    (c) Head 3</th>

  </tr>

  <tr>

    (d) Item 1</td>

    <td>Item 2 (e)

    <td>Item 3</td>

  (f)

</table>

In: Computer Science

Nearby is a main() function demonstrating the use of the function earliest_word. Implement this function according...

Nearby is a main() function demonstrating the use of the function earliest_word. Implement this function according to the documentation given. My solution is about 25 lines plus some closing curly braces.

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

char *earliest_word(char *fname, int *nwords);

// Opens the file fname and reads words from it

// until the end of file is reached then closes

// the file. If the file to be opened doesn't

// exist, returns NULL and sets nwords to

// -1. Tracks the alphabetic "earliest" word that

// is read in as indicated by strcmp(). Tracks how

// many words in total are read and sets nwords to

// that value. Allocates a block of memory and

// copies the earliest word found into the block

// using strcpy(). Returns a pointer to the

// freshly allocated block.

//

// ASSUMPTIONS: Words are no longer than 127

// characters so will fit in an array of size

// 128. Files have at least one word in them.

int main(){

int count; char *file; char *early;

file = "vegetables.txt";

// pumpkin carrot beet squash cucumber

early = earliest_word(file, &count);

printf("%s: %d words, %s earliest\n",

   file,count,early);

// vegetables.txt: 5 words, beet earliest

free(early);

file = "fruits.txt";

// banana peach orange apple pineapple strawberry

early = earliest_word(file, &count);

printf("%s: %d words, %s earliest\n",

   file,count,early);

// fruits.txt: 6 words, apple earliest

free(early);

file = "not-there.txt";

early = earliest_word(file, &count);

if(early==NULL){

printf("%s not found\n",file);

// not-there.txt not found

}

return 0;

}

C programming

In: Computer Science

Which of the following represents the greatest risk? Group of answer choices The director of IT...

Which of the following represents the greatest risk? Group of answer choices

The director of IT (a key employee) resigned

An IT hardware failure occurred

The president of the company was fired for embezzlement

The company’s database is corrupted with no backup facilities

In: Computer Science

C++ 1. What is the minimum number of steps if there are 1, 2, 3, 4,...

C++

1. What is the minimum number of steps if there are 1, 2, 3, 4, or more disks? Try and solve the puzzle and fill in the table.

1 1
2 3
3 7
4 15
5 ?
6 ?
7 ?
8 ?

2. Write an explicit formula for the minimum number of steps required for the puzzle? Use H(n) = ? where n is the number of disks

3. What would be the best ADT to use for the posts in the puzzle? Why is that data structure best?

4. What would be the base case (n = 1) of this problem if a recursive solution was employed? Use three of the ADTs from the previous question for storage. The three posts are labeled A, B, C. Post A is the the starting post and Post C is the ending post. Write the answer in in pseudo code.

5. What are the rest of the cases given the base case?

if (n == 1)

            disk = A.top()

            A.pop()

            C.push(disk)


please refer to concept of "Tower of Hanoi"

In: Computer Science

We will create a program that will guess a number between 1 and 100 chosen by...

We will create a program that will guess a number between 1 and 100 chosen by the user.Your program will be iteratively built in several stages, where each stage focuses on implementing just one type of operation. Each stage will build upon the work from the previous stage. This is known as iterative design, a process that allows us to focus on working on a single, simple task at a time, but the resulting software slowly evolves into something much more complex.

Required Concepts: The final homework requires that you implement the following concepts: 1. Storage operations (store data in program) 2. Output operations (print data to screen) 3. Input operations (get data from user) 4. Selection operations (multiple selection based on player input) 5. Mathematical operations (arithmetic, equality, relational) 6. Repetition operations (loop game logic to model multiple turns) 7. Nested selection operations (validate that user’s selection meets rules requirements) CODE IN JAVA!!

In: Computer Science

Use R code to do the following!!!! 1. Create a vector v1 that will contain integers...

Use R code to do the following!!!!

1. Create a vector v1 that will contain integers from -30 to 60.
2. Copy v1 into a vector v2 and add names 'odd' or 'even' based on the value.
3. Copy v1 into a vector v3 and if the number can be divided by 3, replace it by 'NA'.
4. Assign the mean of v3 to v4 ignoring the 'NA'.

In: Computer Science

Have a look at the code below. Write a switch statement to check for the mode...

Have a look at the code below. Write a switch statement to check for the mode type. When the designated mode is matched, display an appropriate string for that mode. The default case should display the statement, “We do not offer this mode of course delivery.”

public class SwitchCourse
{
    enum CourseMode { ONLINE, RESIDENTIAL, HYBRID }
    CourseMode myCourse = CourseMode.HYBRID;
  
    public void myCourse()
    {
        switch (/*___*/)
        {
            case ONLINE:
                System.out.println("You will not need to attend classes on campus.");
                break;
            case RESIDENTIAL:
                System.out.println("All of your classes will be held on campus.");
                break;
            case HYBRID:
                System.out.println("You will be required to attend one class a week on campus.");
                break;
            /*____*/
                /*_____*/
        }
    }

}

In: Computer Science

What is LUN, and how can it be applied to SAN management?

What is LUN, and how can it be applied to SAN management?

In: Computer Science

Python - Create/Initialize a dictionary with 5 state/capital pairs of your choosing. The state is the...

Python

- Create/Initialize a dictionary with 5 state/capital pairs of your choosing. The state is the key and the capital is the value (e.g. “Kansas”:”Topeka”). Only one statement is needed to do this.

- Then prompt the user for a state.

e.g. The output

Enter a state, and I will display the capital.

State: Colorado

Colorado's capital is Denver.

- If that state exists in the dictionary, display the capital, else display "I'm sorry, but I still need to record " followed by the state entered.

e.g. the output

Enter a state, and I will display the capital.

State: Nebraska

I'm sorry, but I still need to record Nebraska.

- Modify the else to also include the ability to add the state and capital to the dictionary.

e.g. the output

Enter a state, and I will display the capital.

State: Nebraska

I'm sorry, but I still need to record Nebraska.

What is Nebraska's capital? Lincoln

The recorded states and capitals thus far are:

{'Kansas': 'Topeka', 'Iowa': 'Des Moines', 'Michigan': 'Lansing', 'California': 'Sacramento', 'Colorado': 'Denver', 'Nebraska': 'Lincoln'}

In: Computer Science

Code should be Written in C Using initialization lists, create 5 one-dimensional arrays, one for each...

Code should be Written in C

  1. Using initialization lists, create 5 one-dimensional arrays, one for each of these:
  • hold the names of the people running in the election
  • hold the names of the subdivision
  • hold the vote counts in the Brampton subdivision for each candidate
  • hold the vote counts in the Pickering subdivision for each candidate
  • hold the vote counts in the Markham subdivision for each candidate

Use the data from the example below.

* Your C program should take the data in the arrays and produce the output below, neatly formatted as shown:

Candidates                            Subdivisions                 Totals

                             Brampton  Pickering Markham        

Aubrey                     600            800          800            2200

Blake 700            700          600            2000

Chubbs 800           700          800           etc

Oliver 400            450         300             

Zamier 900            900       900            

Totals                     3400            etc                              etc

  1. Create a function that will find the total votes in one subdivision and return that to main( ). Call this function 3 times to produce the 3 totals in the last line of output.

  1. Create a function that will find the total votes for one candidate and return that to main( ). Call this function 5 times to produce the 5 totals in the last column of output. Be very careful with the parameter list here. Send the function only the information it needs.
  1. Create a function that will output the first 2 lines of headings.

In: Computer Science

create a C++ program using Visual Studio that could be used by a college to track...

create a C++ program using Visual Studio that could be used by a college to track its courses. In this program, create a CollegeCourse class includes fields representing department, course number, credit hours, and tuition. Create a child (sub class) class named LabCourse, that inherits all fields from the the CollegeCourse class, includes one more field that holds a lab fee charged in addition to the tuition. Create appropriate functions for these classes, and write a main() function that instantiates and uses objects of each class. Save the file as Courses.cpp. Compile this application using Visual Studio and run it to make sure it is error free. Please attach your project folder in a zipfile when submitting. GRADING RUBRIC: - define a class named CollegeCourse - private fields for department, course number, credit hours, and tuition - public function(s) setting the private fields - public function that displays a CollegeCourse's data - define a class named LabCourse - inherit from CollegeCourse - include field that holds a lab fee - public function(s) setting the private field (don't forget the parent) - public function that displays a LabCourse's data (don't forget the parent) - main() function that instantiates a LabCourse, populates all private and inherited fields, calls both private and inherited methods

In: Computer Science