Questions
Language C: Suppose you are given a file containing a list of names and phone numbers...

Language C: Suppose you are given a file containing a list of names and phone numbers in the form "First_Last_Phone." Write a program to extract the phone numbers and store them in the output file.

Example input/output:
Enter the file name: input_names.txt
Output file name: phone_input_names.txt

1) Name your program phone_numbers.c

2) The output file name should be the same name but an added phone_ at the beginning. Assume the input file name is no more than 100 characters. Assume the length of each line in the input file is no more than 10000 characters.

3) The program should include the following function: void extract_phone(char *input, char *phone); The function expects input to point to a string containing a line in the “First_Last_Phone” form. In the function, you will find and store the phone number in string phone.

In: Computer Science

1. Explain the factors that might lead to network intrusion through wireless connections. 2. Describe a...

1. Explain the factors that might lead to network intrusion through wireless connections.

2. Describe a cybersecurity attack or data breach that affected you personally.

In: Computer Science

1-Please complete the below python programs. Use spaces for indentations since the website does not take...

1-Please complete the below python programs. Use spaces for indentations since the website does not take tabs.

#inputs to the function are 2 numbers x and y. Print "Sum 6!" if the sum of x and y is bigger or equal to 6. Print "Sum too small!" otherwise.

def sum_6(x,y):

#your answer here, can be multiple lines

___

#input to the function is a list of integers. The function will calculate and return a resultlist with the square of each number in the input list saved in it. For example: if mylist has numbers 1,2,3,4,5, the returned value should be a list with 1,4,9,16,25.

def square_num (mylist):

#your answer here, can be multiple lines

___

#in this main function, create a list with 6 numbers, call the second function in this question, print out the returned result.

def main ():

#your answer here, can be multiple lines

___

2-Write down the regular expression that can match: a string with 1 or more digits followed by exactly 2 small case letters. Sample string: 5678yr. (You do not need to consider the " ")

(same as the below question) Make sure you only write down the regex. Please do NOT include other things like / / around it. You do not need to consider any blanks before or after the regex, nor sentence starting/ending symbols.

Answer:

3-Write down the regular expression that can match: a float with 1 or more digits before the decimal point and exactly 2 digits after. Sample: 2345.34

(same as the below question) Make sure you only write down the regex. Please do NOT include other things like / / around it. You do not need to consider any blanks before or after the regex, nor sentence starting/ending symbols.

Answer:

In: Computer Science

Write the complete code necessary to prompt the user for 4 sequential numbers, calculate the summation...

Write the complete code necessary to prompt the user for 4 sequential numbers, calculate the summation of the 4 numbers and display the results including the words "The summation of 1,2,3,4 is". A summation is defined as n + n+1 + n+2.... Declare necessary variables and be sure to include comments. Include int main(void) { Code goes here } The programming language is C in Visual Basic

In: Computer Science

You've been hired by Avuncular Addresses to write a C++ console application that analyzes and checks...

You've been hired by Avuncular Addresses to write a C++ console application that analyzes and checks a postal address. Prompt for and get from the user an address. Use function getline so that the address can contain spaces. Loop through the address and count the following types of characters:

        ● Digits (0-9)

        ● Alphabetic (A-Z, a-z)

        ● Other

Use function length to control the loop. Use functions isdigit and isalpha to determine the character types. Use formatted output manipulators (setw, left/right) to print the following rows:

        ● Address

        ● String length

        ● Number of digits

        ● Number of alphas

        ● Number of other characters

And two columns:

        ● A left-justified label.

        ● A right-justified value.

Then test the number of digits and number of alphas. If digits is less than two or alphas is less than three, print an invalid address message. Otherwise, print a valid address message. Define constants for the minimum number of digits and alphas, and the column widths. The output should look like this for invalid and valid input:

Welcome to Avuncular Addresses

------------------------------

Enter an address: 1 West Liberty St

Address:     1 West Liberty St

Length:                     16

Digits:                      1

Alphas:                     12

Other:                       3

Address is invalid!

End of Avuncular Addresses

Welcome to Avuncular Addresses

------------------------------

Enter an address: 110 Main St

Address:           110 Main St

Length:                     11

Digits:                      3

Alphas:                      6

Other:                       2

Address is valid!

End of Avuncular Addresses

In: Computer Science

You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays...

You've been hired by Yogurt Yummies to write a C++ console application that calculates and displays the cost of a customer’s yogurt purchase. Use a validation loop to prompt for and get from the user the number of yogurts purchased in the range 1-9. Then use a validation loop to prompt for and get from the user the coupon discount in the range 0-20%. Calculate the following:

        ● Subtotal using a cost of $3.50 per yogurt.

        ● Subtotal after discount

        ● Sale tax using rate of 6%.

        ● Total

Use formatted output manipulators (setw, left/right) to print the following rows:

        ● Yogurts purchased

        ● Yogurt cost ($)

        ● Discount (%)

        ● Subtotal ($)

        ● Subtotal after discount ($)

        ● Tax ($)

        ● Total ($)

And two columns:

        ● A left-justified label (including units)

        ● A right-justified value.

Define constants for the yogurt cost, sales tax rate, and column widths. Format all real numbers to two decimal places. Run the program with invalid and valid inputs. The output should look like this:

Welcome to Yogurt Yummies

-------------------------

Enter the number of yogurts purchased (1-9): 12

Error: '12' is an invalid number of yogurts.

Enter the number of yogurts purchased (1-9): 4

Enter the percentage discount (0-20): 30

Error: '30.00' is an invalid percentage discount.

Enter the percentage discount (0-20): 10

Yogurts:                             4

Yogurt cost ($):                  3.50

Discount (%):                    10.00

Subtotal ($):                    14.00

Total after discount ($):        12.60

Tax ($):                          0.76

Total ($):                       13.36

End of Yogurt Yummies

In: Computer Science

In Java Write a program that allows Professor Poindexter to get class averages including the average...

In Java
Write a program that allows Professor Poindexter to get class averages including the average for allher/his classes. Professor Poindexter has M classes. M will be input from the terminal. For each class he/she will input each student’s grade for that class until 0 is input. Once the goof prof inputs 0, The class average for that class is output in the form:

  Average for Class X 1 is XXX.XX

Finally, once all the M class data is input, the final message will be output:

The Average for All of Professor Poindexter’s M classes is XX.XX

Here is the data you will use for your run:

How many classes does Professor Poindexter Have?

2

Input a student grade for class 1:

100

80

90

0

The Average for Class 1 is XX.XX

Input the grades for class 2:

80

75

90

99

0

The Average for Class 2 is XX.XX

The Average for All of Professor Poindexter’s M classes is XX.XX

In: Computer Science

stone Atone aLone Clone clonS cOons coNns conEs coneY Money Word ladders were invented by Lewis...

stone

Atone

aLone

Clone

clonS

cOons

coNns

conEs

coneY

Money

Word ladders were invented by Lewis Carroll in 1878, the author of Alice in Wonderland. A ladder is a sequence of words that starts at the starting word, ends at the ending word, In a word ladder puzzle you have to change one word into another by altering a single letter at each step. Each word in the ladder must be a valid English word and must have the same length. For example, to turn stone into money, one possible ladder is given on the left.

Many ladder puzzles have more than one possible solution. Your program must determine the shortest word ladder. Another path from stone to money is

stone store shore chore choke choky cooky cooey coney money

Instructions

Your program will accept starting and ending words from the input file called "infile.txt". Then, you read the dictionary file called “dictionary.txt '' store all words in a LinkedList. Finally, you build a word ladder between starting and ending words

There are several ways to solve this problem. One simple method involves using stacks and queues. The algorithm (that you must implement) works as it follows

Get the starting word and search through the dictionary to find all words that are one letter different. Create stacks for each of these words, containing the starting word (pushed first) and the word that is one letter different. Enqueue each of these stacks into a queue. This will create a queue of stacks! Then dequeue the first item (which is a stack) from the queue, look at its top word and compare it with the ending word. If they equal, you are done - this stack contains the ladder. Otherwise, you find all the words one letter different from it. For each of these new words create a deep copy of the stack and push each word onto the stack. Then enqueue those stacks to the queue. And so on. You terminate the process when you reach the ending word or the queue is empty.

You have to keep track of used words! Otherwise, an infinite loop occurs.

Example

The starting word is smart. Find all the words one letter different from smart, push them into different stacks and store stacks in the queue. This table represents a queue of stacks.

----------------------------------------------------
| scart | start   | swart | smalt | smarm |
| smart | smart | smart | smart | smart   |
----------------------------------------------------

Now dequeue the front and find all words one letter different from the top word scart. This will spawn seven stacks:

---------------------------------------------------------------------
| scant | scatt | scare | scarf | scarp | scars   | scary |
| scart | scart | scart | scart | scart | scart   | scart |
| smart | smart | smart | smart | smart | smart | smart |    ----------------------------------------------------------------------

which we enqueue to the queue. The queue size now is 11. Again dequeue the front and find all words one letter different from the top word start. This will spawn four stacks:

----------------------------------------
| sturt   | stare | stark | stars |
| start   | start   | start   | start   |
| smart | smart | smart | smart |
----------------------------------------

Add them to the queue. The queue size now is 14. Repeat the procedure until either you find the ending word or such a word ladder does not exist. Make sure you do not run into an infinite loop!

Queue

You are to implement a Queue data structure based on Java’s Queue class using LinkedList.

Stack

You are to use Java's Stack class.

Output

Your program must output to the console one word ladder from the start word to the end word. Every word in the ladder must be a word that appears in the dictionary. This includes the given start and end words--if they are not in the dictionary, you should print "There is no word ladder between ..." Remember that there may be more than one ladder between the start word and the end word. Your program may output any one of these ladders. The first output word must be the start word and the last output word must be the end word. If there is no way to make a ladder from the start word to the end word, your program must output "There is no word ladder between ..."

import java.util.*;
import java.io.*;
public class WordLadder {

   private static LinkedList< String > dict;
   private static LinkedList< String > visited;
   private static String start, end;

   public static void main(String[] args) throws IOException{
    // TODO Auto-generated method stub
      File dictfile = new File("dictionary.txt");
      File infile = new File("infile.txt");
      dict = new LinkedList<>();
    // load the dictionary
      try(
         Scanner in = new Scanner(dictfile);){
         while(in.hasNext()) {
           
            dict.add(in.next());
         }
      }
      try(Scanner in = new Scanner(infile);)
      {
         while(in.hasNext()) {
       
           
            start = in.next();
           
            end = in.next();
           
            if(start.length()!=end.length() || !dict.contains(start) || !dict.contains(end) ){
               System.out.println("There is no word ladder between "+start+ " and "+end);
               continue;
            }
       
            findLadder(start,end);
       
         }
      }
   


   }
  
   public static void findLadder(String start,String end) {
   
      Queue< Stack< String >> queue = new LinkedList<>();
      visited = new LinkedList<>();
      Stack< String > copiedStack = new Stack<>();
    // Left as exercise
   

   }  

   public static boolean isAnEdge(String w1, String w2) {
        // Left as exercise
}
      

Output:

[line, fine]

[dear, fear]

There is no word ladder between stone and money

[fake, lake, lase, last, cast, cost, coat]

[like, line, fine, fire, fore, core, cord, cold, hold, held, help]

There is no word ladder between blue and pink

[face, fake, lake, like]

[help, held, hold, cold, cord, core, fore, fire, fine, find, mind]

[lice, line, fine, fire, fore, core, cord, cold, hold, held, help]

There is no word ladder between door and lice

  

In: Computer Science

Create a project named Bonus that first demonstrates a race condition using this scenario, then make...

Create a project named Bonus that first demonstrates a race condition using this scenario, then make it thread-safe and show what the execution would look like after your fix.

I need my code to be in java with fully commented

In: Computer Science

C++ If you tried to compile a source file that doesn't contain a main() function, would...

C++

If you tried to compile a source file that doesn't contain a main() function, would this error be detected by the preprocessor, the compiler, or the linker? Briefly justify your answer.

Hint: think about how the files that don't have main() get processed in a project with multiple files. Alternatively, try it out and look at the error message you get.

In: Computer Science

Create the following java program with class list that outputs: //output List Empty List Empty List...

Create the following java program with class list that outputs:

//output

List Empty
List Empty
List Empty
Item not found
Item not found
Item not found

Original list
Do or do not. There is no try. 

Sorted Original List
Do There do is no not. or try. 

Front is Do
Rear is try.
Count is 8
Is There present? true
Is Dog present? false

List with junk
junk Do or moremorejunk do not. There is no try. morejunk 
Count is 11

List with junk removed
Do or do not. There is no try. 
Count is 8

List Full
List Full
List Full
List Full
List Full
List Full

After filling List
dummy dummy dummy dummy dummy dummy dummy Do or do not. There is no try. 
Count is 15

After removing dummy
Do or do not. There is no try. 
Count is 8

// main

public class AssignmentThree
{
   public static void main(String[] args)
   {
       List myList = new List(15);
      
       // Cause List Empty Message
       myList.removeFront();
       myList.removeRear();
       myList.removeItem("a");
      
       // Cause Not found message
       myList.addToFront("x");
       myList.removeItem("y");
       myList.removeItem("x");
       myList.addAfterItem("x", "z");
       myList.addBeforeItem("x", "z");
          
       // Normal behavior
       myList.addToFront("not.");
       myList.addToFront("or");
       myList.addToRear("is");
       myList.addToRear("try.");
       myList.addAfterItem("is", "no");
       myList.addBeforeItem("is", "There");
       myList.addToFront("Do");
       myList.addAfterItem("or", "do");
      
       myList.print("Original list");
       myList.printSorted("Sorted Original List");
          
       sop("\nFront is " + myList.getFront());
       sop("Rear is " + myList.getRear());
       sop("Count is " + myList.askCount());
       sop("Is There present? " + myList.isPresent("There"));
       sop("Is Dog present? " + myList.isPresent("Dog"));
  
       myList.addToFront("junk");
       myList.addToRear("morejunk");
       myList.addAfterItem("or", "moremorejunk");
      
       myList.print("List with junk");
       sop("Count is " + myList.askCount());
      
       myList.removeFront();
       myList.removeRear();
       myList.removeItem("moremorejunk");
       myList.print("List with junk removed");
       sop("Count is " + myList.askCount());
       sop("");
      
       // Cause List Full message
       for(int ii = 0; ii < 10; ++ii)
       {
           myList.addToFront(DUMMY);
       }
      
       myList.addToRear(DUMMY);
       myList.addBeforeItem("no", DUMMY);
       myList.addAfterItem("There", DUMMY);
      
       myList.print("After filling List");
       sop("Count is " + myList.askCount());
      
       while(myList.isPresent(DUMMY)) myList.removeItem(DUMMY);
      
       myList.print("After removing " + DUMMY );
       sop("Count is " + myList.askCount());
   }
  
   private static void sop(String s)
   {
       System.out.println(s);
   }
      
   private static final String DUMMY = "dummy";
}

In: Computer Science

Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa....

Write a program to convert the time from 24-hour notation to 12-hour notation and vice versa. Your program must be menu driven, giving the user the choice of converting the time between the two notations. Furthermore, your program must contain at least the following functions: a function to convert the time from 24-hour notation to 12-hour notation; a function to convert the time from 12-hour notation to 24-hour notation; a function to display the choices; function(s) to get the input; and function(s) to display the results. (For 12-hour time notation, your program must display AM or PM.) c++

In: Computer Science

Give an O(lg n)-time EREW algorithm to perform the prefix computation on an array x[1. ....

Give an O(lg n)-time EREW algorithm to perform the prefix computation on an array x[1. . n]. Do not use pointers, but perform index computations directly.

In: Computer Science

A Mystery Algorithm Input: An integer n ≥ 1 Output: ?? Find P such that 2...

A Mystery Algorithm

Input: An integer n ≥ 1

Output: ??

Find P such that 2 P is the largest power of two less than or equal to n.

Create a 1-dimensional table with P +1 columns. The leftmost entry is the Pth column and the rightmost entry is the 0th column.

Repeat until P < 0

If 2 P ≤ n then

put 1 into column P

set n := n − 2 P

Else

put 0 into column P

End if

Subtract 1 from P

Return the filled-in table

(a) In general, what is the output of the Mystery algorithm?

(b) What is the run time of the Mystery Algorithm? Your answer should be a function of n. You may assume that “Find P such that 2 P is the largest power of two less than or equal to n” takes Θ(1) time to compute.

In: Computer Science

Your task is to write an article describing the differences you have found or noticed so...

Your task is to write an article describing the differences you have found or noticed so far between C++ and Java.

First you should go through the W3schools C++ tutorials as described in the week’s description, taking some notes about the differences between C++ and Java as you do so. Then, you should write your document.

Your document does not need to be long, but it should be well-written. Imagine that you are writing this for Java programmers who want to know about C++.   You will be telling them about some of the differences between the two languages that you noticed as you began to learn about C++.

It would best to submit your article as a Word. Be sure to include your name and a title at the top of the article, much like we do with identifying documentation when programming, no specific format is required, as long as the information is there and your document doesn’t look too bad.

Practice writing about topics in Computer Science is important for students studying the discipline.

In: Computer Science