Questions
simple python program : include comments please Let's continue to practice an example using the PriorityQueue...

simple python program : include comments please

Let's continue to practice an example using the PriorityQueue from the queue module in Python:

Suppose you have been tasked with writing a program that will track the registration waiting list for CCIS 100. Priority is given to seniors, then juniors, etc...

  1. Generate a text file (named waitlist.txt) containing the number of credit hours earned, ID number, and email of students who request to be added to the waitlist (1 piece of data per line).  The file can contain any number of students, but, at minimum, should contain at least 10 students.
  2. Read that information into a list of tuples
  3. Using a PriorityQueue, print the order in which the students should be added to the course if slots open up. Please make sure that the data is printed/formatted in a table with column headings.

In: Computer Science

Define a regular expression that will correctly (and exactly) match a valid Gregorian calendar date of...

Define a regular expression that will correctly (and exactly) match a valid Gregorian calendar date of the form MM/DD/YYYY (with leading zeroes for single-digit months and days) (and ONLY dates in this format). • Months 1, 3, 5, 7, 8, 10, and 12 have 1–31 days • Months 4, 6, 9, and 11 have 1–30 days • Month 2 (February) has 1–28 days (ignore leap years) • Assume that the year falls into the range 1900–2099 HINT: You may find it helpful to define several patterns and combine them using the alternation operator.

In: Computer Science

Write a program in Python language which will do the following: Write a program to prompt...

Write a program in Python language which will do the following:

Write a program to prompt the user to enter a company name, city, state and zip code. Create a dictionary with the data. Output the dictionary. Then remove the city from the dictionary and output again.

In: Computer Science

You were introduced to some common administrative commands in this chapter. However, there are other utilities...

You were introduced to some common administrative commands in this chapter. However, there are other utilities that come with other Linux distributions that were not mentioned in the textbook, such as: linuxconf, LISA, YaST, and TurboUserCfg. Using the Internet, man/info pages, or other reference books as a research resource, write a short paper describing any two of these administrative utilities. Be sure to detail what these utilities do, and what distributions they are typically packaged with. Also, no student is allowed to copy large portions on a source. Each student is required to write in his or her own words what was learned by reading a source.

In: Computer Science

Write a java program called ImperialMetric that displays a conversion table for feet and inches to...

Write a java program called ImperialMetric that displays a conversion table for feet
and inches to metres. The program should ask the user to enter the range of values that
the table will hold.
Here is an example of what should be output when the program runs:
Enter the minimum number of feet (not less than 0):
5
Enter the maximum number of feet (not more than 30):
9

|
|
|
|
|
|
0"
1.524
1.829
2.134
2.438
2.743
1"
1.549
1.854
2.159
2.464
2.769
2"
1.575
1.880
2.184
2.489
2.794
3"
1.600
1.905
2.210
2.515
2.819
4"
1.626
1.930
2.235
2.540
2.845
5"
1.651
1.956
2.261
2.565
2.870
6"
1.676
1.981
2.286
2.591
2.896
7"
1.702
2.007
2.311
2.616
2.921
8"
1.727
2.032
2.337
2.642
2.946
9"
1.753
2.057
2.362
2.667
2.972
10"
1.778
2.083
2.388
2.692
2.997
11"
1.803
2.108
2.413
2.718
3.023
5'
6'
7'
8'
9'

The sample solution used to generate the above example and the automarker scripts
uses System.out.printf() with a format string of "%6.3f" to print the metric values.
We recommend the following formula:
double metres = (feet*12+inches)*0.0254;

In: Computer Science

Exercise 9.2 (c++) (max, min, average, and median code) Write a program that asks users to...

Exercise 9.2 (c++) (max, min, average, and median code)

Write a program that asks users to input up to 20 integers, and then finds the maximum, minimum, average, and median of the numbers that were entered. Use the following information to write your program. The median is the number that appears in the middle of the sorted list of numbers. If the array has an odd number of elements, median is a single number in the middle of the list (array). If the array has an even number of elements, then median is the average of the two numbers in the middle.

Example:
Odd number of elements:   1 4 6 3 8, first sort the numbers: 1 3 4 6 8, then find the median, i.e, 4.
Even number of elements:   1 4 8 3, first sort the numbers: 1 3 4 8, then find the median as the average of 3 and 4, i.e., 3.5

The minimum is the smallest element of the array. To find the smallest element in an array, you need to find the index of the smallest number and access it. You can use the following function to do this. This function is also used in the sort_array function.

int index_of_smallest(const int a[], int start_index, int used_size)
{
      int min = a[start_index],   index_of_min = start_index;


     for(int i = start_index+1; i < used_size; i++)

     {
          if(a[i] < min )
          {
                min = a[i];
                index_of_min = i;
           }

      }
     return index_of_min;
}

To sort an array that has used_size elements, use the following function:

void sort_array(int a[], int used_size)
{
      int index_of_next_smallest;
      int temp;

      for(int i = 0; i < used_size -1; i++)
      {
              index_of_next_smallest = index_of_smallest(a, i, used_size);
              // swap two elements
              temp = a[i];
              a[i] = a[index_of_next_smallest];
              a[index_of_next_smallest] = temp;
       }
}

Note that you should write three more functions; 1) one similar to the one that finds the index of smallest number for finding the index of the largest number, 2) one that computes the average and returns it to the main, 3) and the last one that takes the sorted array and will return the median. Call your programex92.cpp.

use c++ and #include <iostream>

In: Computer Science

I know how to do this with arrays, but I have trouble moving my code to...

I know how to do this with arrays, but I have trouble moving my code to use with linked lists

Write a C program that will deal with reservations for a single night in a hotel with 3 rooms, numbered 1 to 3. It must use an infinite loop to read commands from the keyboard and quit the program (return) when a quit command is entered. Use a switch statement to choose the code to execute for a valid command. The valid commands are: R or r: reserve a room C or c: cancel a reservation W or w: remove a request from the waiting list L or l: list the current reservations for the night Q or q: quit the program Any other input: print an error message and prompt for another command.

You must use a linked list to represent the reservation list, and another linked list to represent the waiting list. You can determine whether each list will be singly- or doubly linked, and whether each list has just a front pointer, or a front and rear pointer. The two lists do not need to have the same design (that is one could be singly-linked with a front pointer, and the other doubly-linked with front and rear pointers. The reservation list can have at most as many nodes as there are rooms in the hotel Actions taken in response to a valid command (r, c, w, or l) must be implemented using programmer-defined functions, one per command. Any needed data must be passed to the functions, not declared globally. Implement reservation ids using a simple integer counter. Names will have fewer than 15 characters.

Actions for each command are:

Reservation: If there is a free room, reserve a room by inserting a node on the reservation list containing the next reservation id and the name associated with the reservation. When there is space available, print the reservation id for the person at the keyboard, and prompt for and read the name associated with the reservation. If there are no rooms, print an appropriate message and ask if the person wants to be entered on the waiting list. If they do, add a node to the waiting list array, print the reservation id for the person at the keyboard, and prompt for and read the name associated with the waiting list entry. The waiting list must be implemented as a queue (insert nodes at the back of the list and remove nodes from the front of the list when a room becomes available)

Cancellation: If there is a room reserved under that reservation id, cancel the reservation by removing the node associated with the reservation. Otherwise print a message that the id is not valid. If a room is cancelled and there are entries on the waiting list, remove the first entry on the waiting list and insert the data in the reservation list, then print a message indicating that reservation id is now confirmed. Note that, if the nodes on both lists are the same type, you can simply insert the node you removed from the waiting list into the reservation list.

Wait cancellation: If there is a waiting list entry with that reservation id, the node containing that reservation id should be removed from the waiting list. Otherwise print a message indicating that id is not on the waiting list.

List reservations: Print the reservation ids and associated names of all rooms that are reserved. Do not print anything for rooms that are vacant. If there are no rooms reserved, print a message indicating that. If there are any entries on the waiting list you should also print the reservation number and name of all elements on the waiting list.

Quit: end the program by returning from the main function. Any other command: print an error message and prompt for another command.

Use an integer counter for reservation ids that starts at 1. Reservation ids are not reused. Use another integer to keep track of the number of rooms reserved. Your solution will be for a boutique hotel with only 3 (very expensive) rooms. But make liberal use of #define statements so it would be trivial to adapt your solution to a larger hotel.

In: Computer Science

In Cybersecurity Law, what is are the similarities and differences between a narrow and broad view...

In Cybersecurity Law, what is are the similarities and differences between a narrow and broad view of the Digital Millennium Copyright Act? How is each court interpretation of the law different, but the same?

In: Computer Science

I need new and unique answers, please. (Use your own words, don't copy and paste), Please...

I need new and unique answers, please. (Use your own words, don't copy and paste), Please Use your keyboard (Don't use handwriting) Thank you...

Question 1: [5 Points]

For each of the following systems, choose a suitable architecture style, then justify your choice.

  1. An aquarium contains exotic tropical fish. The fish require the water temperature to be between 20 C - 23 C otherwise the fish will get sick. An automated heater is used to maintain the water temperature within that range. It turns on when the water gets too cold. It turns off when the water reaches the desired temperature.

                                   

  1. A university admission processing system. After all applicants have submitted their application, their application would be reviewed by the university, the college, then finally the department. Applicants would be notified of the admission decision after all admission boards have reviewed all applications.

                          

  1. A security check-in system which provides face, fingerprint, voice, height, weight and other document identification admission means. They cooperate together to provide authentication integrity. The system has its recognition rules and preinstalled facts about trusted and target people.

  1. Travel agency application which helps customers make travel plans including air, hotel, car rental, attraction visits, and time schedules. This application makes use of existing web services of airlines, car rentals, hotels, and attractions.

  1. An application that needs to be portable and that can be easily divided into application-specific and platform-specific portions.

In: Computer Science

Write a Java program to play the game Tic-Tac-Toe. Start off with a human playing a...

Write a Java program to play the game Tic-Tac-Toe. Start off with a human playing a human, so each player makes their own moves.

Follow the design below, creating the methods indicated and invoking them in the main program.

Use a char array of size 9 as the board; initialize with the characters 0 to 8 so that it starts out looking something like the board on the left.

0|1|2

3|4|5

6|7|8

and then as moves are entered the board looks like this

0|O|2

3|X|5

6|X|O

Make sure the board lines up properly so that the entries and borders all line up properly. DO NOT print a board that looks like or is similar to the output below where columns are misaligned.

0| O|2

3|X | 5

6 | X|O

You will need a variable to keep track of whose turn it is. Use a char variable named turn and initialize to X when the game starts. After a move, if there is no winner and no draw, switch to the O and continue to take turns as the game progresses. Declare additional variables as you build your program.

  1. After the variable declarations, begin a while loop which will keep the game going the user indicates to stop the game. (see a. below)
    1. When a new games starts, allow the user to terminate the program by entering an S or s (remember String has toLowerCase and toUpperCase methods). Any other entry will start a new game.
  2. If you are starting a new game, invoke a method to initialize the board and turn and another method to print the board
  3. Start an inner while loop that runs as long as the game isn’t over (a win or draw will terminate the game but not the program).
  4. Invoke a method to allow the user to make a move
    1. If there is no empty spot, (the game is a draw), print a message and ask the user whether to start a new game or terminate the program
    2. If the value entered is invalid (not 0 to 8), print a message and allow the user to re-enter a move
    3. If the user enters a value but it’s already taken, print a message and allow the user to retry
    4. If the user enters a value and it’s available, set the spot to X or O (depending upon the value of turn) and print the board
  5. After a valid move is made, invoke a method to check if the last one to make a move won the game
    • Winner - print the winner and start a new game
    • No winner - switch turn and ask for the next position

SAMPLE OUTPUT – NOTE OUTPUT BOLDED TO SHOW HANDLING OF BAD ENTRIES

Enter S to stop game, any other letter to play

x

Starting new game

0|1|2

3|4|5

6|7|8

Enter move, a number between 0 and 8

5

0|1|2

3|4|X

6|7|8

Enter move, a number between 0 and 8

5

Spot is taken, choose another

Enter move, a number between 0 and 8

0

O|1|2

3|4|X

6|7|8

Enter move, a number between 0 and 8

4

O|1|2

3|X|X

6|7|8

Enter move, a number between 0 and 8

2

O|1|O

3|X|X

6|7|8

Enter move, a number between 0 and 8

3

O|1|O

X|X|X

6|7|8

X is the winner

Enter S to stop game, any other letter to play

x

Starting new game

0|1|2

3|4|5

6|7|8

Enter move, a number between 0 and 8

0

X|1|2

3|4|5

6|7|8

Enter move, a number between 0 and 8

3

X|1|2

O|4|5

6|7|8

Enter move, a number between 0 and 8

9

9 is not a valid choice

Enter move, a number between 0 and 8

z

z is not a valid choice

Enter move, a number between 0 and 8

6

X|1|2

O|4|5

X|7|8

Enter move, a number between 0 and 8

1

X|O|2

O|4|5

X|7|8

Enter move, a number between 0 and 8

5

X|O|2

O|4|X

X|7|8

Enter move, a number between 0 and 8

8

X|O|2

O|4|X

X|7|O

Enter move, a number between 0 and 8

4

X|O|2

O|X|X

X|7|O

Enter move, a number between 0 and 8

2

X|O|O

O|X|X

X|7|O

Enter move, a number between 0 and 8

7

X|O|O

O|X|X

X|X|O

Game is a draw

Enter S to stop game, any other letter to play

In: Computer Science

______ ______ can be appropriately described as the application of computer science to high-level, real-world problems.

______ ______ can be appropriately described as the application of computer science to high-level, real-world problems.

In: Computer Science

Part 1: Write a Python function called reduceWhitespace that is given a string line and returns...

Part 1: Write a Python function called reduceWhitespace that is given a string line and returns the line with all extra whitespace characters between the words removed.

For example, ‘This line has extra space characters'

'This line has extra space characters’

• Function name: reduceWhitespace

• Number of parameters: one string line

• Return value: one string line The main file should handle the file operations to read from a .txt file you create and call the function from the module you create.

In main you should also print out your text from the file before the function call and print the result after the function call, showing that the function works. Additionally, write the lines with reduce whitespaces into a text file.

Your function should also include the specification (docstring).

Note: the code will be tested by giving it a .txt file, so you should prompt the user for the text file.

Lab 9 Part 2:

In the same module, write a Python function named countAllLetters that is given a string line and returns a list containing every letter and character in the line and the number of times that each letter/character appears (with upper/lower case letters counted together).

For example,

‘This is a short line’ -> [(‘t’,2), (‘h’,2), (‘i’,3), (‘s’,3), (‘ ‘,4), (‘a’,1),

(‘o’,1), (‘r’,1), (‘l’,1), (‘n’,1), (‘e’,1)]

• Function name: countAllLetters

• Number of parameters: one string line

• Return value: a list

The main file should handle the file operations to read from a new .txt file you create and call the function from the module you create. In main, you should print out the text you read from the file, then call the function and then print out the resulting list, showing that the function works. You do not need to write the output into a text file.

Your function should also include the specification (docstring).

Note: the code will be tested by giving it a .txt file, so you should prompt the user for the text file.

Please zip both files

In: Computer Science

IN MY SQL: - Display each Author’s ID, first and last names and the total number...

IN MY SQL:

- Display each Author’s ID, first and last names and the total number of pages for all of the Books they have written.

- Display each Book genre as well as the number of Books written in that genre with the column header “Number Of Books”

- Display the Author’s first and last name, as well as their ID, and the Book title and number of pages for all of the books they have written that have more than the average number of pages for all of the books that have been written, listed by author’s first and last name along with the book title, and the book’s number of pages.

- Display the Author’s or Authors’ ID, first and last name of the Author who has the most Books in the Coastal Publishing database.

LINK TO WHAT THE SETUP AND INSERTS LOOK LIKE:

https://docs.google.com/document/d/1Qb30rS-g03pUBBFGBRwq-f9L8CsHY0Dz_HKpt_lt9uM/edit?usp=sharing

In: Computer Science

// Sunrise Freight charges standard // per-pound shipping prices to the five states they serve //...

// Sunrise Freight charges standard

// per-pound shipping prices to the five states they serve

// –- IL IN OH MI WI

// -- 0.60 0.55 0.70 0.65 0.67

// Modify this program to reduce its size

// by using arrays

start

Declarations

string state

num pounds

string foundIt

string BAD_STATE_MSG = "Sorry, we do not ship to ”

string FINISH = “XXX”

getReady()

while state <> FINISH

findPrice()

endwhile

finishUp()

stop

getReady()

output "Enter state or ", FINISH, " to quit"

input state

return

findPrice()

foundIt = "N"

if state = "IL" then

price = 0.60

foundIt = "Y"

else

if state = "IN" then

price = 0.55

foundIt = "Y"

else

if state = "MI" then

price = 0.70

foundIt = "Y"

else

if state = "OH" then

price = 0.65

foundIt = "Y"

else

if state = "WI" then

price = 0.67

foundIt = "Y"

endif

endif

endif

endif

if foundIt = "N" then

output BAD_STATE_MSG, state

else

output “Enter pounds “

input pounds

output “Cost per pound to ship to ”, state, “ is ”, price

output “Total cost is ”, price * pounds

endif

output "Enter next state or ", FINISH, " to quit"

input state

return

finishUp()

output "End of job"

return

In: Computer Science

Suppose that we want to make change for n cents using the least number of coins....

Suppose that we want to make change for n cents using the least number of coins. The coins are of denominations c 0 , c 1 , . . . , c k for some integers c > 1, and k ≥ 1. (a) Design a greedy algorithm to solve this problem. (b) Prove that your algorithm finds an optimal solution by showing the greedy-choice property and optimal substructure for it. Clearly state each property and then prove them.

In: Computer Science