Questions
Intro To Programming In Java(2nd Edition) I'm currently trying to study and understand stuff better, but...

Intro To Programming In Java(2nd Edition)

I'm currently trying to study and understand stuff better, but I need some help.

Can someone please help me define/understand the following:

Section 2.1

-Static Methods
-Control Flow
- Input Parameters and Arguments (single and multiple)
-Overloading
-Return Statement
-Side Effects
-Scope and Lifetime
-Pass-by-Value (Primitives) vs Pass-by-Reference (Arrays)
-Reason of Use: Organize Code

Section 3.1

-Strings (substring, charAt, split, indexOf, contains, length, and == vs equals)
-Constructor
-Instance Methods
-Reference types(String and Arrays) vs Primitive Types(int, boolean, char, double)
-Difference between Static and Instance methods.

Section 3.2

-API and UML
-Class
-Access Modifiers (private, public, and final)
-Instance Variables
-Instance Methods
-Scope and Lifetime
-Constructors

In: Computer Science

Create an ERD based on the following business rules and requirements. Make sure that the ERD...

  1. Create an ERD based on the following business rules and requirements. Make sure that the ERD follows good database design practices covered in Chapter 6. use an online visual paradigm tool to create the ERD
  • NOST offers many different tours. For each tour, the tour name, approximate length (in hours), and fee charged is needed.
  • Tours are classified into five categories: family friendly, adventure, hiking, camping, and water activities.
  • Guides are identified by an employee ID, but the system should also record a guide’s name, home address, and date of hire.
  • Guides take a test to be qualified to lead specific tours. It is important to know which guides are qualified to lead which tours and the date that they completed the qualification test for each tour. A guide may be qualified to lead many different tours. A tour can have many different qualified guides. New guides may or may not be qualified to lead any tours, just as a new tour may or may not have any qualified guides.
  • Every tour must be designed to visit at least three locations. For each location, a name, type, and official description are kept. Some locations (such as the Hobbiton) are visited by more than one tour, while others (such as the Glow Worm cave) are visited by a single tour. All locations are visited by at least one tour.
  • When a tour is actually given, that is referred to as an “outing.” NOST schedules outings well in advance so they can be advertised and so employees can understand their upcoming work schedules. A tour can have many scheduled outings, although newly designed tours may not have any outings scheduled. Each outing is for a single tour and is scheduled for a particular date and time. All outings must be associated with a tour. All tours at NOST are guided tours, so a guide must be assigned to each outing. Each outing has one and only one guide. Guides are occasionally asked to lead an outing of a tour even if they are not officially qualified to lead that tour. Newly hired guides may not have ever been scheduled to lead any outings.
  • Tourists, called “clients” by NOST, pay to join a scheduled outing. For each client, the name, address, and telephone number are recorded. Clients may sign up to join many different outings, and each outing can have many clients. Information is kept only on clients who have signed up for at least one outing, although newly scheduled outings may not have any clients signed up yet.

a) Identify all possible entities and relationships. Name all relationships in both directions, with the exception that the relationship name may be omitted on a relationship travelling from an associative or bridging entity.

(b) Resolve any many-to-many relationships.

(c) Identify

(i) strong and weak entities

(ii) identifying and non-identifying relationships.

(d) Identify the main attributes in each entity including all primary and foreign keys.

(e) Identify the Cardinality and Participation for each relationship.

logical database design question

In: Computer Science

Set up an introduction to a three-level control framework (TLCF) for cybersecurity governance. Of the nine...

Set up an introduction to a three-level control framework (TLCF) for cybersecurity governance.
Of the nine TLCF building blocks, draft summary of policies, strategy, organization, risk management, program management, and metrics.
Describe how the use of TLCF to assess the effectiveness of security program.
Describe a sample process for building out the TLCF to prove a viable security program.

In: Computer Science

Modify the BankAccount class to throw IllegalArgumentException exceptions, create your own three exceptions types. when the...

Modify the BankAccount class to throw IllegalArgumentException exceptions, create your own three exceptions types. when the account is constructed with negative balance, when a negative amount is deposited, or when an amount that is not between 0 and the current balance is withdrawn. Write a test program that cause all three exceptions occurs and catches them all.

/**
A bank account has a balance that can be changed by
deposits and withdrawals.
*/
public class BankAccount
{
private double balance;

/**
Constructs a bank account with a zero balance
*/
public BankAccount()
{   
balance = 0;
}

/**
Constructs a bank account with a given balance
@param initialBalance the initial balance
*/
public BankAccount(double initialBalance)
{   
if (initialBalance < 0)
throw new NegativeBalanceException(
"Cannot create account: " + initialBalance + " is less than zero");   
  
balance = initialBalance;
}

/**
Deposits money into the bank account.
@param amount the amount to deposit
*/
public void deposit(double amount)
{
if (amount < 0)
throw new NegativeAmountException(
"Deposit of " + amount + " is less than zero");
double newBalance = balance + amount;
balance = newBalance;
}

/**
Withdraws money from the bank account.
@param amount the amount to withdraw
*/
public void withdraw(double amount)
{   
if (amount < 0)
throw new NegativeAmountException(
"Withdrawal of " + amount + " is less than zero");
  
if (amount > balance)
throw new InsufficientFundsException(
"Withdrawal of " + amount + " exceeds balance of " + balance);
  
double newBalance = balance - amount;
balance = newBalance;
}

/**
Gets the current balance of the bank account.
@return the current balance
*/
public double getBalance()
{   
return balance;
}
}
---------------

/**
A class to test the BankAccount class.
*/
public class BankAccountTester2
{
public static void main(String[] args)
{
BankAccount harrysChecking = new BankAccount();
  
try
{
harrysChecking.deposit(300);
System.out.println("success");
}
catch (IllegalArgumentException e)
{
System.out.println("exception");
}
System.out.println("Expected: success");

try
{
harrysChecking.withdraw(100);
System.out.println("success");
}
catch (IllegalArgumentException e)
{
System.out.println("exception");
}
System.out.println("Expected: success");

try
{
harrysChecking.deposit(-100);
System.out.println("success");
}
catch (IllegalArgumentException e)
{
System.out.println("exception");
}
System.out.println("Expected: exception");

try
{
harrysChecking.withdraw(300);
System.out.println("success");
}
catch (IllegalArgumentException e)
{
System.out.println("exception");
}
System.out.println("Expected: exception");
}
}
-------------------------

Hint:

/**
This exception reports a negative initial balance on a bank account.
*/
public class NegativeBalanceException extends RuntimeException
{
public NegativeBalanceException()
{
}

public NegativeBalanceException(String message)
{
super(message);
}
}

In: Computer Science

C PROGRAM In Stage 1, you will be implementing the Draw Line command to draw horizontal...

C PROGRAM

In Stage 1, you will be implementing the Draw Line command to draw horizontal and vertical lines.

The Draw Line command is given four additional integers, which describe two pixels: the start and end pixels of the line.

Each pixel consists of two numbers: the index of the row, and the index of the column.

For example, the command 1 10 3 10 10 tells your program to draw a line (1), starting at the pixel at row 10 and column 3, and ending at the pixel at row 10 and column 10.

When given the Draw Line command, your program should set the colour of the relevant elements in the canvas array, starting at the provided start pixel location, and continuing along the horizontal or vertical line until it reaches the end pixel location (including both the start and end pixels themselves).

Hints

  • Your program will only be drawing either horizontal or vertical lines in Stage 1, which means that either row1 and row2 will be the same, or col1 and col2 will be the same.
  • If row1 == row2 && col1 == col2, your program should draw a single pixel, at the location (row1, col1), (row2, col2).

Handling Invalid Input

  • If the given command both starts and ends outside the canvas, you should do nothing, and ignore that Draw Line command. Note that ignoring the command should still read in it's arguments. Otherwise, if one end pixel of the line is within the canvas you should draw the section of the line that is within the canvas.
  • If the given start and end pixels would not give an entirely horizontal or vertical line, your program should ignore that Draw Line command and do nothing. Note that ignoring the command should still read in it's arguments.

Input Commands

  • Input to your program will be via standard input (similar to typing into a terminal).
  • You can assume that the input will always be integers and that you will always receive the correct number of arguments for a command. You will never be given a integer that represents a command that doesn't exist.
  • You can assume that input will always finish with the "End of Input" signal (Ctrl-D in the terminal).

Starter Code.

#include <stdio.h>

// The dimensions of the canvas (20 rows x 36 columns).
#define N_ROWS 20
#define N_COLS 36

// Shades (assuming your terminal has a black background).
#define BLACK 0
#define WHITE 4

// IF YOU NEED MORE #defines ADD THEM HERE


// Provided helper functions:
// Display the canvas.
void displayCanvas(int canvas[N_ROWS][N_COLS]);
// Clear the canvas by setting every pixel to be white.
void clearCanvas(int canvas[N_ROWS][N_COLS]);


// ADD PROTOTYPES FOR YOUR FUNCTIONS HERE


int main(void) {
    int canvas[N_ROWS][N_COLS];

    clearCanvas(canvas);

    // TODO: Add your code here!

    // Hint: start by scanning in the command.
    //
    // If the command is the "Draw Line" command, scan in the rest of
    // the command (start row, start col, length, direction) and use
    // that information to draw a line on the canvas.
    //
    // Once your program can draw a line, add a loop to keep scanning
    // commands until you reach the end of input, and process each
    // command as you scan it.

    displayCanvas(canvas);

    return 0;
}



// ADD CODE FOR YOUR FUNCTIONS HERE



// Displays the canvas, by printing the integer value stored in
// each element of the 2-dimensional canvas array.
//
// You should not need to change the displayCanvas function.
void displayCanvas(int canvas[N_ROWS][N_COLS]) {
    int row = 0;
    while (row < N_ROWS) {
        int col = 0;
        while (col < N_COLS) {
            printf("%d ", canvas[row][col]);
            col++;
        }
        row++;
        printf("\n");
    }
}


// Sets the entire canvas to be blank, by setting each element in the
// 2-dimensional canvas array to be WHITE (which is #defined at the top
// of the file).
//
// You should not need to change the clearCanvas function.
void clearCanvas(int canvas[N_ROWS][N_COLS]) {
    int row = 0;
    while (row < N_ROWS) {
        int col = 0;
        while (col < N_COLS) {
            canvas[row][col] = WHITE;
            col++;
        }
        row++;
    }
}

In: Computer Science

(using c) You will build a system to manage patients’ data in a hospital. The hospital...

(using c) You will build a system to manage patients’ data in a hospital. The hospital patient management system stores specific information in the form of health record to keep track of the patients’ data.

Your program should read the information from a file called “patients.txt” that should be on the following format: Patient Name#Gender#Date of admission#Date of birth #Illness#Address (City)#Blood type (using c)

Example of data input:

Alma Mukhles#F#2212019#01012000#Ear infection#Nablus#B+

Ahmed A. Ali#M#01102020#05101970#Low blood pressure#AlBireh#A-

Your program should be able to do the following tasks:

Options:

1. Read data: read the data of the patients from the file.

2. Create linked list: create a linked list.

3. Sort data: use Radix sort to sort the data based on the patients’ names.

4. Add patient: add a new patient.

5. Update patient: update patient’s information.

6. Delete patient: soft delete (explained below).

7. Search for patients a. Name b. Date of birth

8. List patients

a. All patients

b. Category (i.e., illness)

c. City

d. Discharged (Patients who were deleted from the system)

9. Export medical report: export XML file following medial health record standards.

10. Exit: exit from the system and store the information back to the file.

Notes:

- Deleted patients should not be deleted from the linked list (data). Instead, there should be a flag in their record indicating if they are discharged. This means, when exporting the data, all patients, including the records that have been deleted should be kept. However, when listing all patients in the linked list, this data should not be listed.

- For simplicity you my limit the number of patients to n=100 and the number of characters m in each name to 50. - You are allowed to use only character comparisons. Thus, you are not allowed to use the String library functions.

- Export medical report: this should export an XML format of the data in the linked list using the following format:
<patient>

<name>Alma Mukhles</name>

<gender>F</gender>

<admissionDate value=”2212019” />

<birthDate value=”01012000” />

<diagnosis>Ear infection</diagnosis>

<city>Nablus</city>

<bloodType>B+</bloodType>

</patient>

<patient>

<name>Ahmed A. Ali</name>

<gender>M</gender>

<admissionDate value=”01102020” />

<birthDate value=”05101970” />

<diagnosis>Low blood pressure </diagnosis>

<city> AlBireh </city>

<bloodType>A-</bloodType>

</patient>

The   data   is   exported   to   a   file   called   Report.xml

In: Computer Science

There are two algorithms that perform a particular task. Algorithm 1 has a complexity function: f(n)...

There are two algorithms that perform a particular task. Algorithm 1 has a complexity function: f(n) = 5n + 50. Algorithm 2 has a complexity function g(n) = n^2 + 10g . (Show your answer)

a)Which algorithm is more efficient when n = 5?

b) Which algorithm is more efficient when n = 20?

c) what are complexity of f(n) and g(n)

In: Computer Science

A positive integer n is said to be prime (or, "a prime") if and only if...

A positive integer n is said to be prime (or, "a prime") if and only if n is greater than 1 and is divisible only by 1 and n . For example, the integers 17 and 29 are prime, but 4, 21 and 38 are not prime. Write a function named "is_prime" that takes a positive integer argument and returns as its value the integer 1 if the argument is prime and returns the integer 0 otherwise.

Can you make it in vba excel and in the form of functions because its hard for me

In: Computer Science

LANGUAGE C Code function: I wanted to create an array, i.e. index[100], and store 3 elements...

LANGUAGE C

Code function:

I wanted to create an array, i.e. index[100], and store 3 elements into it.

The elements that i wanted to store is from the same variable, however its value will always change in the while loop

e.g. index[0]=1, index[1]=3, index[2]=5

However it seems that my code has a problem that my compiler warns me that the variable index is set but not used. And also, is it not possible to store the elements into the array using the while loop in my code? As i am not familiar with c language. Can sir/madam fix the codes below and teaches the proper way?

NOTE: i use gcc compiler in unix environment. Any assistance is very much appreciated in advance

#include <stdio.h>

int main(){
   int c=0;
   int j=2;
   int i=0;
   int index[100];

   int a=1;
  
   while(c<=j){
       index[c]=a;
       a+=2;
       c+=1;

   }

   for(i=0;i++;i<=j){
       printf("%d",index[i]);
   }
}

In: Computer Science

Big-O: Describe the worst case running time of the following pseudocode or functions in Big-Oh notation...

Big-O: Describe the worst case running time of the following pseudocode or functions in Big-Oh notation in terms of the variable n. Show your work

a) O( )

int m1(int n, int m) {

if (n < 10) return n;

else if (n < 100)

return happy (n - 2, m);

else

return happy (n/2, m);

}

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

b) O ( )

void m2 (int n) {

j = 0;

while (j < n) {

for (int i = 0; i < n; ++i)

{ System.out.println(”i = ” + i);

for (int k = 0; k < i; ++k)

System.out.println(”k = ” + k);

}

j = j + 1; }

}

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

c) O ( )

void m3 (int n) {

for (int i = 0; i < n * n; ++i) {

for (int k = 0; k < i; ++k)

System.out.println(”k = ” + k);

for (int j = n; j > 0; j--)

System.out.println(”j = ” + j);

}

} ------------------

d) O ( )

void m4 (int n, int x) {

for (int k = 0; k < 500; ++k)

if (x > 500) {

for (int i = 0; i < n * k; ++i)

for (int j = 0; j < n; ++j)

System.out.println(”x = ” + x);

}

}

In: Computer Science

what are cloud computing security concerns and their countermeasures

what are cloud computing security concerns and their countermeasures

In: Computer Science

Explain and demonstrate a Linked List by adding following items into a Linked List: 10, 30,...

Explain and demonstrate a Linked List by adding following items into a Linked List: 10, 30, 15, 25 (show your work, you may write on paper and upload if you prefer)

In: Computer Science

I. Describe the differences between discretionary access control model and mandatory access control model II. File...

I. Describe the differences between discretionary access control model and mandatory access control model

II. File permissions in Linux can be also represented in digits from 0-7 for the owner, group and others with reading as the most significant bit (E.g., the value 6 represents the permission right rw- for a file). Suppose a file in Linux has the permission as the digits 764.

• What does this permission right indicate for the owner/user, group and others?

• What is the letter representation of this permission right?

In: Computer Science

develop a recursive function to compute LCS (x,y)

develop a recursive function to compute LCS (x,y)

In: Computer Science

i'm getting an infinite loop on this code: can you explain what I should do? public...

i'm getting an infinite loop on this code: can you explain what I should do?

public class TriviaLinkedList {

private TriviaNode head;

private int items;

public TriviaLinkedList(TriviaNode head, int items) {

this.head = head;

this.items = items;

}

public TriviaNode getHead() {

return head;

}

public void setHead(TriviaNode head) {

this.head = head;

}

public int getItems() {

return items;

}

public void setItems(int items) {

this.items = items;

}

public String toString() {

return "head=" + head + ", items=" + items;

}

  

public void insertList(TriviaNode node){

if(head == null){

head = node;

}

  

else {

TriviaNode node1 = head;

head = node1;

head.next = node1;

}

this.items++;

}

  

public void deleteList(int id){

TriviaNode first = head;

TriviaNode second = head;

while(first!=null) {

  

if(first.getGame().getId() == id) {

if(first == head) {

head = first.next;

}

  

else if(first.next != null) {

second.next = first.next;

}

else {

second.next = null;

this.items--;

System.out.println("Game: "+id+" was deleted");

return;

}

second = first;

first = first.next;

}

      System.out.println("Unfortunately Game: "+id+" was not found");

}

}

}

  

In: Computer Science