Questions
I need to combine two programs that can do the following (a) what ls command does...

I need to combine two programs that can do the following

    (a) what ls command does and 
     (b) to check each file name to print its content if its name has ".lst" extension.

These are the two programs

Program - 1

/*
 * simple-ls.c
 * Extremely low-power ls clone.
 * ./simple-ls .
 */

#include <sys/types.h>

#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>

int
main(int argc, char **argv) {

        DIR *dp;
        struct dirent *dirp;

        if (argc != 2) {
                fprintf(stderr, "usage: %s dir_name\n", argv[0]);
                exit(1);
        }

        if ((dp = opendir(argv[1])) == NULL ) {
                fprintf(stderr, "can't open '%s'\n", argv[1]);
                exit(1);
        }

        while ((dirp = readdir(dp)) != NULL )
                printf("%s\n", dirp->d_name);

        closedir(dp);
        return(0);
}

Program - 2

/*
 * Stripped down version of 'cat', using unbuffered I/O.
 * ./simple-cat < simple-cat.c
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define BUFFSIZE 32768

int
main(int argc, char **argv) {
        int n;
        char buf[BUFFSIZE];

        while ((n = read(STDIN_FILENO, buf, BUFFSIZE)) > 0) {
                if (write(STDOUT_FILENO, buf, n) != n) {
                        fprintf(stderr, "write error\n");
                        exit(1);
                }
        }

        if (n < 0) {
                fprintf(stderr, "read error\n");
                exit(1);
        }

        return(0);
}

That is, you will design and implement this lscat.c program will do what simple-ls.c program does (to loop through each entry in the directory to be printed), and the program checks whether an entry is a file name and its name contains a character-pattern (".lst" at the end of the file name). If so, then it prints the file-content (that is, to open and print the content). For this part (to print the file content) the program may use the code-segment of "simple-cat" program. When the program prints the file-content, please have a user-friendly heading to show the beginning and the end of the file content being printed) as shown below (or you may have your own heading).

   *** Start of the file: sample.lst *** 
       ...
   *** End of the file: sample.lst ***
Thank You

In: Computer Science

With regard to the self-driving car, and the research conducted by the Moral Machine project; provide...

  1. With regard to the self-driving car, and the research conducted by the Moral Machine project; provide your own ranking for the following (1= most important to save; 9= least important to save).                                                                                     
  1.   

# Ranking

Category

Sparing the young

Sparing the fit

Inaction (doing nothing)

Sparing the most (#) people

Sparing the lawful

Sparing humans over animals

Sparing pedestrians

Sparing women

Sparing people of higher social status

  1. Which group did you prioritize as most important? Which group was the least important? Provide your rationale for these two placements.                                  
  1. Would you consider purchasing a self-driven car that was designed to save other people (pedestrians, other cars with people) over you and your passengers? Why or why not?  

        /2

  1. What is your biggest fear about how advancements in Artificial Intelligence are progressing? Answer in a detailed paragraph.

In: Computer Science

C++ comments would be nice, especially with "Customers.dat" part. Please don't use an already answered solution...

C++

comments would be nice, especially with "Customers.dat" part.

Please don't use an already answered solution from chegg. I've unfortunately had that happen at many occasions.

I'll most certainly upvote if program is right. I always do

......

......

Statement: Create a program that will loop and prompt to enter the highlighted data items in the structure below. This is every item except customerNumber , isDeleted and newLine;


const int NAME_SIZE = 20;
const int STREET_SIZE = 30;
const int CITY_SIZE = 20;
const int STATE_CODE_SIZE = 3;

struct Customers {
    long customerNumber;
    char name[NAME_SIZE];
    char streetAddress_1[STREET_SIZE];
    char streetAddress_2[STREET_SIZE];
    char city[CITY_SIZE];
    char state[STATE_CODE_SIZE];
    int zipCode;

    char isDeleted;
    char newLine;
};

Always set the item isDeleted to 'N' and newline to '\n'. The item newLine is a convenient item that is there to assist in viewing the contents of the file using "type filename" the cmd window.

Notepad will show the binary chars and will not line up the data as expected. You may see some odd characters after the expected data for the character arrays. That is normal for C/C++.

The item customerNumber should start at 0 and increase by 1 for every record written.


Once the data in the structure is loaded, write it to the file "Customers.dat" and prompt to continue. If the reply is to not continue, close the file and exit.

The file "Customers.dat" must be opened in Binary mode.
Deliverable is a working CPP program.

In: Computer Science

write a java merge sort called MERGE-SORT-A(), Using recursive calls and NO INSERTION-SORT() as a sub-procedure.

write a java merge sort called MERGE-SORT-A(), Using recursive calls and NO INSERTION-SORT() as a sub-procedure.

In: Computer Science

FoxMeyer was the fifth largest drug wholesaler in the United States (1995) with annual sales of...

FoxMeyer was the fifth largest drug wholesaler in the United States (1995) with annual sales of about 5 billion US$ and daily shipments of over 500,000 items. In order to take advantages of new technology, FoxMeyer started a 100 Million dollar project to implement SAP’s R/3 ERP system in 1993. But the implementation was a disaster for FoxMeyer. Four years later, the pharmaceutical giant filed for bankruptcy. Also, it sued SAP and Anderson Consulting, claiming them to be responsible for the failure of the ERP system.

1. Please identify the process component of IS in this case. Are there any problems with the process component of the ERP problem? Please explain.

Generally speaking, if you talk about how the ERP system was implemented and the problem with it, you will get 0 on this question.

2. ) Please identify the structural component of IS in this case. Are there any problems with the structure component of the ERP problem? Please explain.

Explain the why, Why did these things happen?

In: Computer Science

(JAVA) We will write a program to check the spelling of the word entered by user,...

(JAVA)

We will write a program to check the spelling of the word entered by user, using data from a dictionary, which is text file. The program will ask user to enter a word for spell check, and then check in the text file (dictionary.txt) if the word exists. (The dictionary.txt file is provided) If the word exists in text file, the output will be “Word is correctly spelled”. If the word doesn’t exist in the text file, program will write the message “Word doesn’t exist in the Dictionary” and will request user to enter “yes” or “no” to save the word in another text file. If user wants to write the word in a text file, user will enter “yes” (This text file can be named anything, for example “PersonalDictionary.txt”). Note: at this step, you need to write the word in the text file and display the message “****** is saved successfully in the file” (Asterisks denote the word entered by the user). If user doesn’t want to write/save the word in the file, user will enter “no” and the program will display a message “****** is not stored in the file” (Where asterisks denote the word). After this, program will ask the user to enter another word or enter some key (for example: -1) to exit the program. The program will use “dictionary.txt” file to read the list of words to be compared with. The program will create and write into a file (you can name it anything, for example “updateDictionary.txt”), the list of words that don’t match.

1. (60 points) Program runs successfully

a. (10 points) Inputs word from the user using a Scanner object.

b. (10 points) Reads the dictionary text file and save the data in a variable

c. (10 points) Repeats until user exit the program (Using Sentinel value to stop)

d. (15 points) Writes the word into a new personal dictionary file

e. (15 points) Outputs the final summary correctly for spelling check

2. (40 points) Program contents follow readability standards including:

a. (10 points) Correct use of arrayLists or any other data type

b. (10 points) Successfully write and use a method outside of the main method

c. (10 points) Correct variable types with Useful, Camel-case identifiers and proper tabbing.

d. (10 points) Document your code with at least 5 helpful comments

i. Put comments above the lines of code they are documenting, not to the right

I cannot attach the dictionary.txt file i appologize

In: Computer Science

This program must be in java, use printf, and request user input for a file name....

This program must be in java, use printf, and request user input for a file name.

  1. NameSubsLast3 (30 points)

Write a program that does the following.

Write a program that does the following.

Requests the name of an input file and uses it to create an input file Scanner.

Requests the name of an output file and uses it to create a PrintWriter.

I have posted firstNames.txt and outNames.txt in the homework for Lesson 6.

Calls createArray to create a one-dimensional String array with 100 rows, and accepts the reference to that array.

Reads in first names from the input file into the array created by createArray. You may assume that the file has no more than 100 names. Also assume that each name has at least 3 characters. (Hint: use the next method). There could be more than one name on a line.

Calls lastThree with a reference to the array created in createArray, and the number of names read in, to create a set of Strings and return a one-dimensional String array as described below.

Prints to the output file on a separate line the String in each row of the array created in createArray followed by a space followed by the String created in lastThree.

createArray: (10)

Creates a one-dimensional String array with 100 rows and returns the reference to that array.

lastThree: (12)

Accepts the reference to the array originally created in createArray and the number of rows that were read in from the file. This array should have a length that equals the number of names read in from the input file.

Obtain the String with last three characters of each name.

Converts each String to upper case, and place each upper case three character String created into a corresponding row in a new one-dimensional String array.

Returns the one-dimensional String array

Example:

If input file is:

Jonathan Jim Bernie

Shondra Nataly

Angel

Brittany Jordan Elvis Ben

The output file, line by line, would be:

Jonathan HAN

Jim JIM

Bernie NIE

Shondra DRA

Nataly ALY

Angel GEL

Brittany ANY

Jordan DAN

Elvis VIS

Ben BEN

In: Computer Science

SIGNS = '03,21-04,19=ARI;04,20-05,20=TAU;05,21-06,21=GEM;06,22-07,22=CAN;' + \ '07,23-08,22=LEO;08,23-09,22=VIR;09,23-10,23=LIB;10,24-11,20=SCO;' + \ '11,21-12,21=SAG;12,22-01,20=CAP;01,21-02,21=AQU;02,22-03,20=PIS;' def find_astrological_sign(month, date

SIGNS = '03,21-04,19=ARI;04,20-05,20=TAU;05,21-06,21=GEM;06,22-07,22=CAN;' + \ '07,23-08,22=LEO;08,23-09,22=VIR;09,23-10,23=LIB;10,24-11,20=SCO;' + \ '11,21-12,21=SAG;12,22-01,20=CAP;01,21-02,21=AQU;02,22-03,20=PIS;' def find_astrological_sign(month, date): ''' (int, int) -> str Given two int values representing a month and a date, return a 3-character string that gives us what star sign a person born in that month and on that date belongs to. Use the SIGNS string (already defined for you at the top of this file) to figure this out. NOTE: A lot of string slicing to do here. The information for each sign is exactly 16 characters long. >>> find_astrological_sign(8, 24) 'VIR' >>> find_astrological_sign(1, 15) 'CAP' How can this be done using lists?

In: Computer Science

1. A company that wants to send data over the Internet will use an encryption program...

1. A company that wants to send data over the Internet will use an encryption program to ensure data security. All data will be transmitted as four-digit integers. The application should read a four-digit integer entered by the user and encrypt it as follows:  Replace each digit with the remainder of the new value divided by 10 by adding 6 to the digit. Then replace the number in the first digit with the third, and the number in the second digit with the fourth. Print the encrypted integer on the screen.  Write a separate application where an encrypted four-digit integer is entered and decrypted (reversing the encryption scheme) and finds the original number.

Note: code should be written in Java Language.

In: Computer Science

Can you provide an example on how a decision tree might be used in practice?

Can you provide an example on how a decision tree might be used in practice?

In: Computer Science

PYTHON - please finish the methods below that are apart of a linkedlist class #return the...

PYTHON - please finish the methods below that are apart of a linkedlist class


#return the data value at index(position) in the list. values remain unchanged
def __getpos__(self, position):
   
    #do not change, checks for valid index
    if self.size == 0:
        raise IndexError
    elif position is None:
        return self.pop(self.size - 1)
    elif type(position) != int:
        raise TypeError
    elif position < 0 or position >= self.size:
        raise IndexError
    

#replace the data value at requested position(index). return nothing
def __setpos__(self,position,value):

    #do not change, checks for valid index
    if self.size == 0:
        raise IndexError
    elif position is None:
        return self.pop(self.size - 1)
    elif type(position) != int:
        raise TypeError
    elif position < 0 or position >= self.size:
        raise IndexError

In: Computer Science

I was supposed to conver a singly linked list to a doubly linked list and everytime...

I was supposed to conver a singly linked list to a doubly linked list and everytime I run my program the output prints a bunch of random numbers constantly until I close the console.

Here is the code.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

struct node {
int data;

struct node *next;
struct node *prev;
};

//this always points to first link
struct node *head = NULL;

//this always points to last link
struct node *tail = NULL;

//return length of list
int sizeList (struct node *pointer)
{
int length = 0;
struct node *temp;

if(pointer == head)
{
for (temp = head; temp != NULL; temp = temp-> next)
length++;
}
else
{
for (temp = tail; temp != NULL; temp = temp-> prev)
length++;
}
return length;
}

//insert element from last node
struct Node* insertLast (struct node *tail, int newelement)
{
struct node *temp = (struct node*) malloc(sizeof(struct node));
temp-> data = newelement;

if (tail == NULL){
head = temp;
tail = temp;
}
else
{
tail-> next = temp;
temp-> prev = tail;
}
//point last to new last node
tail = temp;

return tail;
};

void printList(struct node *pointer)
{
int length = 0;
struct node *temp;

//check if pointer is head and print head of node
if (pointer == head)
{
for (temp = head; temp != NULL; temp = temp-> next)
printf("%d ", temp-> data);
}
//check if pointer is tail and print the list from tail node using previous pointer
else
{
for (temp = tail; temp != NULL; temp = temp-> prev)
printf("%d ", temp-> data);
}

printf("\n");
}

int get (struct node *pointer, int position)
{
struct node *temp;
int length = sizeList(pointer);
int tempPosition = 0;

if (length < position)
{
printf("Enter the position with in %d.", length);
return -1;
}
//check if pointer is head and return the element from the position
if (pointer == head)
{
for (temp = head; temp != NULL; temp = temp-> next)
{
if(++tempPosition == position)
{
return temp-> data;
}
}
}
//check if pointer is tail and return the element from the position
else
{
for (temp = tail; temp != NULL; temp = tail-> prev)
{
if (++tempPosition == position)
{
return temp-> data;
}
}
}
return 0;
}

//delete node from position
struct node* removeEle(struct node *head, int position)
{
struct node *temp = head, *deleteNode = NULL;
int i;

//traverse list until we get each position
for (i=1; i<position && temp != NULL; i++)
{
temp = temp-> next;
}

//if position is 1, move the head pointer to next and free node and return to head
if (position ==1)
{
deleteNode = temp;
temp = temp-> next;
temp-> prev = NULL;
head = temp;

free (deleteNode);
return head;
}

//if deleteNode is last position move the tail to previous node and free last node
else if (temp == tail)
{
deleteNode = tail;
tail = tail-> prev;
tail-> next = NULL;

free(deleteNode);
return head;
}
//swap temp pointers to skip node
else if (temp != NULL)
{
temp-> prev-> next = temp-> next;
temp-> next-> prev = temp-> prev;

free(temp); //delete n node
return head;
}
else
{
printf("It's an invalid position..\n");
return head;
}
};

void reverseList(struct node *node)
{
//stop and return if node is null
if (!node)
return;

//swap next and prev pointer of node
struct node* temp = node-> next;
node-> next = node-> prev;
node-> prev = temp;

//node of prev is null stop and update head and tail pointer
if(!node-> prev)
{
head = node;
if(head-> next == NULL)
{
tail = head;
}
struct node *temp = head;
while(temp-> next != NULL)
{
temp = temp -> next;
}
tail = temp;
return;
}
//invoke recursive api
reverseList(node-> prev);
}

int main()
{
struct Node *tail = NULL;

//insert element at last
tail = insertLast(tail, 10);
tail = insertLast(tail, 20);
tail = insertLast(tail, 30);
tail = insertLast(tail, 40);
tail = insertLast(tail, 50);

printf("Printing from Head: ");
printList(head);
printf("\n");

printf("Printing from Tail: ");
printList(tail);
printf("\n");

printf("Size of list from Head: %d\n", sizeList(head));
printf("Size of list from Tail: %d\n", sizeList(tail));

//remove element from position 4
printf("Get the element from head at position 4: ");
int element = get(head, 4);

if(element != -1)
{
printf("%d\n", element);
}

//remove element from position 2
printf("Get the element from tail at position 2: ");
element = get(tail, 2);

if(element != -1)
{
printf("%d\n", element);
}

printf("Remove element from position 3\n");
head = removeEle(head, 3);

printf("Printing from Head after removal: ");
printList(head);
printf("\n");

//invoke reverse list
reverseList(head);

printf("Printing from Head after reverseList: ");
printList(head);
printf("\n");

printf("Printing from tail after reverseList: ");
printList(tail);
printf("\n");

return 0;
}

In: Computer Science

Question 1. Your task is to create a full program for a Restaurant of your choice....

Question 1. Your task is to create a full program for a Restaurant of your choice. You will have the output appear at first saying Welcome to ______ Restaurant where the _____ will be whatever you name your restaurant

Today’s choices are 1.__________ 2._________ 3._______ 4.________

NOTE each _____ will say an item and its price for example pizza 2.99 Please choose 1 of the choices. In each case, as the user picks a choice It will calculate the total cost of the item based on a tax of 8.5%(multiply cost by 0.085) and add to original cost It will output what the user chose and the total cost for the bill in correct money format IF the user enters in something other than 1 through 4 it will say. INVALID CHOICE and the cost will be $0.00 It will then say. Thank You and have a nice day!

In: Computer Science

Write a program, using your favourite programming language, to parse time log files to report how...

Write a program, using your favourite programming language, to parse time log files to report how much time in total spent on project. The time log file TimeLogCarbon.txt.

Time Log:
2/23/12: 9:10pm - 11:40pm getting familiar with Flash
2/29/12: 12:50pm - 2:00pm getting familiar with Flash
3/1/12: 6:00pm - 11:40pm getting familiar with Flash
3/3/12: 3:00pm - 7:00pm step-debug Energy Game code
3/4/12: 8:00pm - 11:40pm start carbon game
3/5/12: 2:00pm - 3:00pm, 4:00pm - 4:30pm carbon game
3/6/12: 11:30am - 1:30pm carbon game data structures and classes for the first action
3/7/12: 11:00am - 5:00pm tested basic concept
3/8/12: 1:00am - 1:30am changed vector calling,
10:30am - 2:30pm, 4:00pm - 5:00pm wrote code to draw points indicator and marshal the data code;
3/9/12: 12:00am - 2:30am added CarbonActionCategoryView.as and captured some icons
11:30am - 4:50pm research how to resize; labor work to capture icons; research how to use event/delegate;
3/10/12: 1:50am - 6:00am event/delegate alternative implementation; score fields implementation
10:40am - 1:00pm define CarbonConsts.as for those names; implemented points fields
3/12/12: 10:45am - 5:00pm research on scrollpane, to no avail
3/13/12: 11:00am - 5:00pm research on Slider customization and make some progress without fully satisfication
3/14/12: 12:10pm - 5:00pm continue to research on Slider and got some idea
3/15/12: 3:30am - 4:30am experiment with CarbonSlider concept
11:00am - 5:00pm "Flash Training with Paul Trani" and continue to experiment with CarbonSlider concept
3/16/12: 10:00am - 5:00pm integrate the CarbonSlider class into the Game project
8:00pm - 9:00pm added the display of the slider thumb value;
9:30pm - 11:00pm clean-up the resources and adjust slider.x; start to modify CarbonPointsIndicator.as
3/17/12: 6:00am - 7:00am
12:00pm - 12:50pm, 4:00pm - 7:00pm bad CarbonPointsIndicator modification
3/18/12: 9:10am - 9:40am draw 2-pixels rectangle and 1-pixel tick for Points Indicator
9:40am - 10:30am debug biofueled cars & trucks, mix in wood in coal plants
11:30am - 3:30pm scrollpane implementation - alternative
11:00pm - 12:00am read Adobe Flash Professional online help
3/19/12: 5:00am - 6:00am read Adobe Flash Professional online help
3/20/12: 9:00am - 10:00am discuss with Dr. Lant and Blanca.
10:00am - 11:00am slider width will be proportional per page or section, total score is changed to total carbon points, options remaining tops 100
3/23/12: 1:30pm - 3:30pm install Adobe Illustrator
4:00pm - 5:00pm Flash Professional online help
3/29/12: 3:11am - 7:00am background shape study, to no avail
11:00am - 12:50pm continue background shape study - no longer needed
3:00pm - 5:05pm scroll pane automatically adjusted based on the view size; dynamically created static texts
10:25pm - 11:00pm adjust positions of text fields
3/30/12: 9:50am - 11:30am loading images in AS 3 training; flash work cycle training
11:40am - 2:20pm experiment with ideas; learn illustrator
3:20pm - 5:05pm re-captured all .png files; .ai files do not have any advantage over .png files
3/31/12: 7:00am - 9:00am change the color of points indicator; add PPU; use Bitmap instead of MovieClip;
4/2/12: 12:10pm - 1:42pm study mask and Shape; come up with the concept of carbon progressbar
1:43pm - 5:00pm implement the carbon progressbar using mask and shape
7:00pm - 7:40pm implement the carbon progressbar by drawing bar and outline
11:00pm - 12:05am added total options and options
4/3/12: 1:30am - 3:00am added Options In Total static text field; Options Remaining will not go negative.
4/4/12: 3:50pm - 5:00pm update the icons
8:35pm - 11:50pm continue to update the icons; use the colors in .ai file
4/9/12: 12:30pm - 6:00pm update based on feedback
9:50pm - 2:30am
4/10/12: 8:56am - 9:57am
- 10.remove "other"
- 9. add "Replace Cement"
- 8. move current points slightly to the right
- 7. center max points on last tic mark
- 6. provide a bit more white space for four large boxes at the top
- 5. At top of left-hand column, label boxes "Tons of Carbon per unit"
- 4. PPU boxes. Align vertically. Expand. "Points per Unit" at the top of this column.
- 3. decrease Improve Insulation limit from 20 to 15
- 2. optionsRemaining and optionsUsed
- 1. total carbon points bar
5/19/12: 4:03pm - 6:57pm update based on teachers' feedback and dynamically dragging slide
6/4/12: 3:30pm - 5:04pm prev/more options implementation
8:15pm - 10:00pm
3/13/13: 2:11pm - 5:12pm Make numbers in the yellow triangles bigger and bolder; Make numbers in the options used and remaining bigger and bolder

In: Computer Science

Please complete in only C++, using loops Assignment: For this assignment you’ll be designing a program...

Please complete in only C++, using loops

Assignment: For this assignment you’ll be designing a program which can take the input of a decimal number and a numerical base, and convert the decimal number to that base. For example, if given the decimal number seven and the base two, your program should output it as 111, which is how seven is represented in binary. Another example, 8,943 in base 10, is 13,236 in base 9.

You’ll need to perform these operations on the following combinations:

A: 15, base 2.

B: 38, base 16.

C: 54, base 6.

D: 19, base 8.

E: 27, base 3.

In: Computer Science