Questions
#include <stdio.h> #include <ctype.h> int main(void) { int ch; unsigned long int charcount=0, wordcount=0, linecount=0; while((ch=getchar())!=EOF){...

#include <stdio.h>

#include <ctype.h>

int main(void) {

int ch;

unsigned long int charcount=0, wordcount=0, linecount=0;

while((ch=getchar())!=EOF){

if(ch==' ' || ch=='\n' || ch=='\t' || ch=='\0' || ch=='\r') {

wordcount++;

}

if(ch=='\n' || ch=='\0') {

linecount++;

}

charcount++;

}

printf("%lu %lu %lu\n", charcount, wordcount, linecount);

getchar();

return 0;

}

When my code reads a blank line, it increment my wordcount by one.

How can I fix this problem? Could you help me with this problem?

In: Computer Science

Database Schema: Book(bookID, ISBN, title, author, publish-year, category) Member(memberID, lastname, firstname, address, phone-number, limit) CurrentLoan(memberID, bookID,...

Database Schema:

Book(bookID, ISBN, title, author, publish-year, category)

Member(memberID, lastname, firstname, address, phone-number, limit)

CurrentLoan(memberID, bookID, loan-date, due-date)

History(memberID, bookID, loan-date, return-date)

Members can borrow books from the library. The number of books they can borrow is limited by the “limit” field of the Member relation (it may differ for different members). The category of a book includes fiction, non-fiction, children’s and reference. The CurrentLoan table represents the information about books that are currently checked out. When the book is returned to the library, the record will be removed from CurrentLoad relation, and will be inserted into History relation with the return-date. A library may have more than one copy of the same book, in which case each copy has its own bookID, but all copies share the same ISBN.

Write SQL statements for each of the following questions.

(1) (16 pts) Create all the relations listed above. Make sure to indicate the primary key and the foreign keys (if any) in your statements.

(2) (10 pts) Insert at least 5 members, 10 books, and enough tuples in the CurrentLoan and History relation. Add tuples as needed to be able to test the following queries for different test cases.

(3) (8 pts) Find the book ID, title, author, and publish-year of all the books with the words “XML” and “XQuery” in the title. These two keywords can appear in the title in any order and do not have to be next to each other. Sort the results by publish year in descending order.

(4) (8 pts) Find the book ID, title, and due date of all the books currently being checked out by John Smith.

(5) (8 pts) Find the member ID, last name, and first name of the members who have never borrowed any books in the past or currently.

Note:

• Please put all the SQL statements in a single file and name it as hw2_yourPirateID.sql.

• Remember to change all the dash “-” in attribute names to underscore “_”.

• For the ease of testing, please add the “drop table” statements at the beginning of your file to drop all the tables.

• Remember to add “commit;” after your last “insert” statement.

• Comment your code as needed. You can use /* … */ to have multi-line comments or use double hyphen (--) for single line commenting. You may use PROMPT … to print any message to the screen. For example, you may use PROMPT Answer for Question 3 (before the query for question 3).

• For this assignment, you need to test your solutions in Oracle and submit your .sql file

In: Computer Science

The goals of the planing phases The techniques ro obtain the goals of the planing phase...

The goals of the planing phases
The techniques ro obtain the goals of the planing phase
The deliverable of the planing phase
How the planing phase to the remaining phases

In: Computer Science

JAVA script! You will write a program that will input the nationalities of your favorite types...

JAVA script!

You will write a program that will input the nationalities of your favorite types of food, examples, and prices of some of your favorite food. You will save a type of food, two examples of that type of food, the price of each of those two examples, and a total price of both together. You must input your own types, examples, and prices, but check a sample run below. You must use the concepts and statements that we have covered so far this semester. Use a loop that loops two times using a counter. Inside the loop, first ask the user to input the nationality of their favorite foods (ex. German, Italian, etc.). The user will now input an example of that type of food and the cost of that food. The user will now input another example of that type of food and the cost of that food. Add the two costs to a total amount variable. Now output the nationality of the type of food and the total amount of the two types of food rounded to two decimal places. Then, ask the user if they would like to list their choices, by answering either y/n or 1/2. If they say y or 1 for yes, print the two examples of that type of food. Hint: When running your program, keep track of the enters in the memory buffer. Whenever an input is skipped over, clear the enter from the input memory buffer. Whenever the program wants an extra input, do not clear the input memory buffer.

In: Computer Science

(1) Explain program-data independence. (2) Explain what advantages NoSQL approaches have over traditional DBMS solutions. (3)...

(1) Explain program-data independence.

(2) Explain what advantages NoSQL approaches have over traditional DBMS solutions.

(3) One company has many departments. A department has many cars and many employees. An employee can loan his/her department’s car for a business trip. Every department needs to keep track the car rental history including “start date”, “return date”, “start mileage”, and “end mileage”. Design an ERD based on above requirements. Please identify (strong and weak) entities, attributes, and (identifying and non-identifying) relationships clearly.

In: Computer Science

You are to design a database for the upcoming Greater Wisconsin River Fishing Contest. Consider the...

You are to design a database for the upcoming Greater Wisconsin River Fishing Contest. Consider the following functional dependencies;

  • SportsPersonId --> SportsPersonFirstName, SportsPersonLastName
  • SportsPersonId --> Address
  • SportsPersonId --> BoatId
  • BoatId --> MotorMake
  • FishId --> SpeciesOfFish, Weight, Length
  • SportsPersonId + FishId --> DateTimeCaught

Please note the following;

  1. This is a “catch and release” contest meaning that once a fish is caught, the specifics are collected, the fish is safely tagged with a unique id, and then is released back to the river. One fish might be caught by numerous sports persons but a sports person can only register the catch of a fish no more than one time.
  2. Each Sports Person must be assigned a boat and a boat can be assigned to multiple sports persons.

Create an ERD in 3NF for these relations. Create appropriate table names for the ERD. Include all applicable fields based on information you have been given and underline the Primary or Composite Primary Key fields. Make sure to include the correct ERD diagram symbols between tables to show the proper relationship type (e.g. 1:1, 1:M, etc.)

In: Computer Science

1. Write a program array_compare.c that determines the number of elements are different between the two...

1. Write a program array_compare.c that determines the number of elements are different between the two integer arrays (same size) when compared element by element (first element with first element, second with second, and so on). The program should include the following function. Do not modify the function prototype.

void count_diff(int *a1, int *a2, int n, int *num_diff);

The function takes two integer array parameter a1 and a2 of size n. The function stores the number of elements that are different to the variable pointed by the pointer variable num_diff.

The function should use pointer arithmetic – not subscripting – to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function. The main function should ask the user to enter the size of the arrays and then the elements of the arrays, and then declare the arrays. The main function calls the count_diff function. The main function displays the result.

Example input/output #1: Enter the length of the array: 5

Enter the elements of the first array: -12 0 4 2 36

Enter the elements of the second array: -12 0 4 2 36

Output: The arrays are identical

Example input/output #2:

Enter the length of the array: 4

Enter the elements of the first array: -12 0 4 36

Enter the elements of the second array: 12 0 41 36

Output: The arrays are different by 2 elements

In: Computer Science

Database Design Give one example of a cardinality ratio for a relationship of degree five.

Database Design

Give one example of a cardinality ratio for a relationship of degree five.

In: Computer Science

q1) Critically analyse the problems you are likely to encounter in creating a cross-platform multimedia projects...

q1)

Critically analyse the problems you are likely to encounter in creating a cross-platform multimedia projects and list several ways to deal with these problems

In: Computer Science

. A simple way to encrypt a number is to replace each digit of the number...

. A simple way to encrypt a number is to replace each digit of the number with another digit. Write a C program that asks the user to enter a positive integer and replace each digit by adding 6 to the digit and calculate the remainder by 10. For example, if a digit is 6, then the digit is replaced by (6+6)%10, which is 2. After all the digits are replaced, the program then swap the first digit with the last digit. The main function reads in input and displays output.

A sample input/output:

Enter the number of digits of the input number: 3

Enter the number: 728

Output: 483

2) The user will enter the total number of digits before entering the number.

3) You can use format specifier "%1d" in scanf to read in a single digit into a variable (or an array element). For example, for input 101011, scanf("%1d", &num) will read in 1 to num.

4) As part of the solution, write and call the function encrypt() with the following prototype.

The function assumes that the digits are stored in the array a and computes the encrypted digits and store them in the array b. c represents the size of the arrays. void encrypt(int *a, int *b, int n); The function should use pointer arithmetic – not subscripting – to visit array elements. In other words, eliminate the loop index variables and all use of the [] operator in the function.

5) As part of the solution, write and call the function swap() with the following prototype. void swap(int *p, int *q);

When passed the addresses of two variables, the swap() function should exchange the values of the variables: swap(&i, &j); /* exchange values of i and j */

In: Computer Science

Design a Python program with a While loop that lets the user enter a number. The...

Design a Python program with a While loop that lets the user enter a number. The number should be multiplied by 10 and the result

stored in a variable named "product". The loop should repeat as long as the product variable < 10. Anything not completely obvious to a newbie should be commented on as in line comments. Should be modulated and repeatable as well as there should be an invocation of the main routine at the end of the program.

Grading Rubrick

Program Compiles Cleanly syntax errors
25 pts -5 per error
Program runs without runtime errors ( validation) run-time errors
25 pts -5 per error
Program give correct answers Logic errors
30 pts -5 per error
Program is repeatable Not repeatable
5 pts -5 pts
Program is well modularized Barely Modularized
10 pts - 5 pts
Documented Well Documented Some
5 pts - 3 pts
Something Cool (but relevant) beyond strict requirements Something extra
5 pts + 3 pts
Best possible grade : 105

In: Computer Science

What is the legal basis of the argument that privacy is a right?

What is the legal basis of the argument that privacy is a right?

In: Computer Science

hello! So I have this CIS assignment lab but when I try to make the code...

hello! So I have this CIS assignment lab but when I try to make the code I don't really know where to start from. My professor is very hard and he likes to see the outcomes as they are shown in the problem. Please help me! the program should be a C++ PLS

Write a program that can be used as a math helper for an elementary student. The program should display two random integer numbers that are to be added, such as:
    247
+ 129
-------

The program should wait for the students to enter the answer. If the answer is correct, a message of congratulations should be printed. If the answer is incorrect, a message should be printed showing the correct answer.

The program displays a menu allowing the user to select an addition, subtraction, multiplication, or division problem. The final selection on the menu should let the user quit the program. After the user has finished the math problem, the program should display the menu again. This process is repeated until the user chooses to quit the program.
Input Validation: If the user select an item not on the menu, display an error message and display the menu again.

Requirements:

Addition
Generate two random numbers in the range 0 - 9.

Subtraction

Generate two random numbers in the range 0 - 9.
num1 = rand() % 10;
num2 = rand() % 10;
Make sure num2 <= num1...
while (num2 > num1)
num2 = rand() % 10;

Multiplication

Generate two random numbers. The first in the range 0 - 10, the second in the range 0 - 9.

Division

Generate a single digit divisor
num2 = rand() % 9;
Generate a num1 that is a multiple of num2 so the division has no remainder. The num1 is never zero.
num1 = num2 * (rand() % 10 + 1);

All constant values must be declare as a constant variable. Use the constant variable in the calculation.
Validating the selection (1 to 5). If the selection is not in the range between 1 and 5, the program keeps asking the input until the correct selection is entered.
Comments in your program to explain the code logic and calculation.


Output sample:

Menu
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Division problem
5. Quit this program

Enter your choice (1-5): 1
   1
+ 2
   ---
   4

Sorry, the correct answer is 3.
Menu
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Division problem
5. Quit this program
Enter your choice (1-5): 7
The valid choices are 1, 2, 3, 4, and 5. Please choose: 2
    8
+ 6
    ---
    2
Congratulations! That's right.
Menu
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Division problem
5. Quit this program
Enter your choice (1-5): 3
     9
*   4
    ---
   36

Congratulations! That's right.
Menu
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Division problem
5. Quit this program
Enter your choice (1-5): 4
8 / 2 = 4
Congratulations! That's right.
Menu
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Division problem
5. Quit this program
Enter your choice (1-5): 4
6 / 2 = 3
Congratulations! That's right.
Menu
1. Addition problem
2. Subtraction problem
3. Multiplication problem
4. Division problem
5. Quit this program
Enter your choice (1-5): 5

"Thank you for using math helper!"

In: Computer Science

Consider a set of n boxes with their positions numbered from 1 to n. Initially all...

Consider a set of n boxes with their positions numbered from 1 to n. Initially all the boxes
are CLOSED. These n boxes are subject to modifications over n iterations as follows. At the ith
iterations the boxes at the positions whose ids are multiples of i are flipped, i.e. changed from
CLOSED to OPEN or vice-versa. For example, at iteration 1, boxes at all positions are
flipped, at iteration 2, boxes at positions 2,4,6,etc. are flipped, at iteration 3, boxes at positions 3,6,9, etc.
are flipped.
Propose an algorithm for find out, that after n such iterations how many boxes will be OPEN.
Note that the answer requires only how many boxes, not their positions. Describe the rationale
for the algorithm, give the pseudocode, and its complexity. Grading scheme: (your grade will be
based on whichever class your algorithm falls in)
- For algorithms with complexity O(kn), where k is the number of digits of n.

In: Computer Science

Grocery Store using Java Arraylist Requirements: 1. Need Product Class and Stock Class 2. Use arraylist...

Grocery Store using Java Arraylist

Requirements:

1. Need Product Class and Stock Class

2. Use arraylist to store/ add product in stock

3. Product must have name, code number and quantity in stock

4. Print list of the products and their stock quantity

5. Search products based on their name 6. Remove product based on their code number

7. Sell product and deduct quantity from stock

8. Stock Class contains methods of search product, add product and check quantity of the product

9. Product Class contains method of get product details

In: Computer Science