Questions
I am running this code using C to count the words in char array, but somehow...

I am running this code using C to count the words in char array, but somehow it keeps counting the total characters + 1.

Any solution to fix this problem?

#include <stdio.h>

int main()
{
   char input[1001];
   int count =0;

   fgets(input, 1001, stdin);
   char *array = input;
   while(*array != '\0')   
   {
       if(*array == ' '){
           array++;
       }
       else{
       count++;
       array++;
       }
      
   }
   printf("this character's length is %d.", count);
   printf("this characterarray : %s", input);
  

   return 0;
}

In: Computer Science

Active directory (AD) is arguably the most critical component of Windows Server 2008, certainly for larger...

Active directory (AD) is arguably the most critical component of Windows Server 2008, certainly for larger organizations. It enables corporations to manage and secure their resources from a single directory service and with a common interface—a very powerful tool. Because it is so powerful and offers so many features and capabilities, it sometimes can be complex to those looking at it for the first time. This week, we are going to learn about AD in detail, starting with the fundamentals. As we progress during the week, you will begin to see it's not that intimidating after all. First, though, let's get the fundamentals down. What exactly is a directory service, and what are some examples in industry? Next, let's get the definition of active directory down—what exactly is it, and what benefits does it provide? After this, we'll look at the details on how it is implemented in the business environment.

What is a directory service?

What are some examples of a directory service?

What is the definition of AD?

What are the benefits of AD?

How is AD implemented in a business environment?

In: Computer Science

Overview: You will write a program that reads up to 100 numbers from a file. As...

Overview: You will write a program that reads up to 100 numbers from a file. As you read the
numbers, insert them into an array in ascending order.
Specifics:
1A. Write a function called insertIntoSortedArray .
i. It should take three arguments -
a. myArray[ ] : sorted array that should be able to hold at most 100 integers.
b. numEntries : the number of elements inserted so far.
c. newValue : the incoming value to be inserted into the sorted array (i.e.
myArray[]).
ii. The insertIntoSortedArray function should return a count of the elements inserted so
far (i.e. the current size of the array)
This function is defined as follows:
int insertIntoSortedArray ( int myArray[], int numEntries, int newValue);

In: Computer Science

write me a java progrm that does this: y=x^3 +1 drivative of y=3X^2+0 y=mx+b m is...

write me a java progrm that does this:

y=x^3 +1

drivative of y=3X^2+0

y=mx+b

m is slope for x=2 put 2 back to equation y=3(2)^2=12

now we have 12 and y=9 so

9=2(12)+b and we find b=-15

now we write new equation that with these information

y=12x-15 we solve for 12x-15=0, we solve for x and x=15/12=1.25

now we do the same thing above we put at the drivative equation y=3(1.25)^2+0=4.6875

now we put this to 2.943125=(4.6875)*3+b

we solve for b=-2.90625

y=4.6875x-2.90625 and 4.6875x-2.90625=0 we solve for x and =0.62 now we use this as we did above to find another new equation and this go in a loop to do the same thing over and over to find new point and equation

In: Computer Science

using java For this assignment, you will write a program that guesses a number chosen by...

using java

For this assignment, you will write a program that guesses a number chosen by your user. Your program will prompt the user to pick a number from 1 to 10. The program asks the user yes or no questions, and the guesses the user’s number. When the program starts up, it outputs a prompt asking the user to choose a number from 1 to 10. It then proceeds to ask a series of questions requiring a yes or no answer. For example: Is your number evenly divisible by 3? (Yes or No).The user will enter “Yes” or “No” to each question. When the program is sure it knows the user’s number it outputs the number. For example, Your number is 9.

Your program must always guess the user’s number in less than five questions.

In: Computer Science

Briefly explain what are the chief differences between queues, dequeues and priority queue? How can you...

Briefly explain what are the chief differences between queues, dequeues and priority queue? How can you determine when it is appropriate to use a queue, a dequeue, or a priority queue? Write a simple example program using any of the 3.

In: Computer Science

Add comments to the following code: PeopleQueue.java import java.util.*; public class PeopleQueue {     public static...

Add comments to the following code:

PeopleQueue.java

import java.util.*;
public class PeopleQueue {

    public static void main(String[] args) {
        PriorityQueue<Person> peopleQueue = new PriorityQueue<>();
        Scanner s = new Scanner(System.in);
        String firstNameIn;
        String lastNameIn;
        int ageIn = 0;
        int count = 1;
        boolean done = false;

        System.out.println("Enter the first name, last name and age of 5 people.");
        while(peopleQueue.size() < 5) {
            System.out.println("Enter a person");
            System.out.print("First Name: ");
            firstNameIn = s.nextLine();
            System.out.print("Last Name: ");
            lastNameIn = s.nextLine();
            System.out.print("Age: ");
            while(!done) {
                try {
                    ageIn = Integer.parseInt(s.nextLine());
                    done = true;
                } catch (NumberFormatException e) {
                    System.out.println("Error: Please enter a number for age");
                    System.out.print("Age: ");
                }
            }
            Person person = new Person(firstNameIn, lastNameIn, ageIn);
            peopleQueue.add(person);
            System.out.println("Added to queue: " + firstNameIn + " " + lastNameIn + ", Age: " + ageIn + "\n");
            done = false;
        }

        NameCompare nameCompare = new NameCompare();
        List<Person> people = new ArrayList(peopleQueue);
        Collections.sort(people, nameCompare);

        System.out.println("Sorted by Last Name\n");
        for (int i = 0; i < people.size(); i++) {
            System.out.println("Name: " + people.get(i).getFirstName() + " "
                                        + people.get(i).getLastName() + ", Age: "
                                        + people.get(i).getAge());
        }


        System.out.println("\nSorted by Age and removed from queue\n");
        while (!peopleQueue.isEmpty()) {
            System.out.println("Removed Person " + count + " -" + peopleQueue.remove());
            count++;
        }
    }
}


Person.java

public class Person implements Comparable<Person> {

    private int age;
    private String firstName;
    private String lastName;

    public Person(String first, String last, int theirAge) {
        this.firstName = first;
        this.lastName = last;
        this.age = theirAge;
    }

    public String getFirstName() {
        return this.firstName;
    }

    public String getLastName() {
        return this.lastName;
    }

    public void setLastName(String last) {
        this.lastName = last;
    }

    public int getAge() {
        return this.age;
    }

    @Override
    public int compareTo(Person person) {
        if(this.equals(person))
            return 0;
        else if(getAge() < person.getAge())
            return 1;
        else
            return -1;
    }

    public String toString() {
        return " Name: " + getFirstName() + " " + getLastName() + ", Age: " + getAge();
    }


}


NameCompare.java

import java.util.Comparator;
public class NameCompare implements Comparator<Person> {

    public int compare(Person p1, Person p2) {
        int i = p1.getLastName().compareTo(p2.getLastName());
        if(i != 0) return -i;
        return i;
    }
}

In: Computer Science

how can you count the number of different letters there are in a word in C...

how can you count the number of different letters there are in a word in C programming?

In: Computer Science

Computer/Network Security How do you implement write access through web server?

Computer/Network Security

How do you implement write access through web server?

In: Computer Science

Based on what you have learned on the WAN technologies, there are three different types of...

  • Based on what you have learned on the WAN technologies, there are three different types of environments that need your help. The three types of environments include a small business, a medium corporate, and a large enterprise environment. What type of technology would you recommend for these different types of companies? Justify your answer.

  • What network optimization tools, methods, or techniques do you think will be most important to you as you manage your organization's network? Explain why?

In: Computer Science

PRELAB - Week of September 16 You’ve created a general-purpose function for allocating an array with...

PRELAB - Week of September 16

You’ve created a general-purpose function for allocating an array with elements of any data type:

array = createArray(numElems, elemSize);

and which supports the following function for obtaining its number of elements:

size = getArraySize(array);

and that’s all you’ll need for this pre-lab. All you’re asked to do for next week is to be able to:

1. Open a file

2. Read an integer giving the number of employee records in the file

3. Allocate an array of employee records (structs) to hold the records in the file

4. Read the records into the allocated array where an employee record is declared as:

typedef struct {

intempID, ssn, position;

float salary;}

Record;

To get comfortable with structs you’ll probably want to loop through the array and print the four members of each record–but you’d probably do that anyway just to verify that you get the results you expect from your test file!

In: Computer Science

Java assignment, abstract class, inheritance, and polymorphism. these are the following following classes: Animal (abstract) Has...

Java assignment, abstract class, inheritance, and polymorphism.

these are the following following classes:

Animal (abstract)

  • Has a name property (string)
  • Has a speech property (string)
  • Has a constructor that takes two arguments, the name and the speech
  • It has getSpeech() and setSpeech(speech)
  • It has getName and setName(name)
  • It has a method speak() that prints the name of the animal and the speech.

o Example output: Tom says meow.

Mouse

  • Inherits the Animal class
  • Has a constructor takes a name and also pass “squeak” as speech to the super class
  • Has a method chew that takes a string presenting the name of a food.

o Example output: Jerry is chewing on cheese.

Cat

  • Inherits the Animal class
  • Has a constructor takes a name and also pass “meow” to the super class
  • Has a method chase that takes a Mouse object.  

o Example output: Tom is chasing Jerry.

TomAndJerry

  • Has a static method makeAnimalSpeak that takes an Animal object and makes it animal speak.
  • Has a main method that
    • Create a variable of Animal type and assign it a mouse named “Jerry”
    • Create a variable of Animal type and assign it a cat named “Tom”
    • all the method makeAnimalSpeak on the animals you have created
    • Make the mouse chew on “cheese”
    • Make the cat chase the mouse

Sample run:

Jerry says squeak.

Tom says meow.

Jerry is chewing on cheese.

Tom is chasing Jerry.

In: Computer Science

What chmod command would you use to impose the following permissions? 1. on a directory(called dir1)...

What chmod command would you use to impose the following permissions?

1. on a directory(called dir1) and all its subdirectories such that: the owner would have read, write, and execute; the group would have read and execute; and others would have read(write the command in two ways: using rwx and using numeric value)

2. on file (called file1)such that: the owner would have read and write; the group would have no permissions; and others would have write

(write the command in two ways: using rwx and using numeric value)

3. set the special permission SGID and sticky bit for dir1.(you don't need to change the defined permission in 1)

Starting from the Linux default permissions for file and directories, what umask command would you use to ensure that for all new:

4. directories, the owner would have read, write, and execute; members of the group would have read and execute; and others would have read

5. files, the owner would have read and execute; the group would have read, write, and execute; and others would have execute

In: Computer Science

I am struggling with this java code Objectives: Your program will be graded according to the...

I am struggling with this java code

Objectives: Your program will be graded according to the rubric below. Please review each objective before submitting your work so you don’t lose points. 1. Create a new project and class in Eclipse and add the main method. (10 points)

2. Construct a Scanner to read input from the keyboard. (10 points)

3. Use the Scanner to read the name, number of balls, and yards per ball of a yarn type specified by a pattern. Prompt the user to input this data as shown in the example below, and store the data in variables. (15 points)

4. Use the Scanner to read the name and yards per ball of a substitute yarn. Prompt the user to input this data, and store the data in variables. (10 points)

5. Use conditional statements to check that each numerical input is a positive integer. Give the user one chance to correct each invalid input. Prompt the user to input a positive value as shown in the example. (15 points)

6. Calculate the number of substitute yarn balls. Use a method of the Math class to round up to the nearest full ball, and store the result in a variable. (20 points)

7. Print the number of substitute yarn balls to the console, matching the format of the example. (10 points)

8. Use meaningful variable names, consistent indentation, and whitespace (blank lines and spaces) to make your code readable. Add comments where appropriate to explain the overall steps of your program. (10 points)

In: Computer Science

Please discuss the design principles that guide the authors of instruction sets in making the right...

Please discuss the design principles that guide the authors of instruction sets in making the right balance. Provide examples of application of each of the three design principles while designing instruction sets.

In: Computer Science