In 300 words or more, describe the advantages and concepts of a Chen ER diagram and how the diagram will help shape the overall relationship between tables.
In: Computer Science
Write a C++ program that will take and validates from the user an integer n between 1 and 4. The program will then continue by taking 5 characters from the user. The program will ask the user whether he needs to rotate the characters to the left or to the right. If the user enters a wrong answer, the program will do a rotation to the right. Depending on the answer, the program will rotate the characters "n" times and displays the result on the screen. The program should contain 2 loops. Example 1: The user will enter a value n=3, the characters A B C D E, and rotation to the left. The program will then display DEABC. Example 2: The user will enter a value n=3, the characters A B C D E, and rotation to the right. The program will then display CDEAB.
In: Computer Science
It is about C++linked list code. my assignment is making 1 function, in below circumstance,(some functions are suggested for easier procedure of making function.)
void pop_Stack (struct linked_list* list, int number) //*This is the function to make and below is the explanation that should be written in given code.
This function removes some nodes in stack manner; the tail of the list will be removed, repeatedly. The parameter (variable 'number') means the number of nodes that will be removed. When parameter is bigger than 1, popping a node with n times, you do not remove node at one go. If there is only one node in the list, please make sure it frees (de-allocates) both the node and the list. If the list is not a stack type(list->type_of_list!=1), print the error message “Function pop_Stack: The list type is not a stack” and exit the function. If the 'number' parameter is less than 1 or more than the number of nodes in the stack, respectively print the error message “Function popStack: The number of nodes which will be removed is more than 1” and “Function popStack: The number of nodes which will be removed is more than that in the stack”, then exit the function. The removed nodes should be freed.
Given code is written below,(There is a function to fill in last moment in this code)
linked_list.h: This is the header file of linkLQS.c that declares all the functions and values that are going to be used in linkLQS.c. You do not have to touch this function.
-----------------------------------------------------------------------
(Below code is about linked_list.h)
#include
#include
#include
struct linked_node{
int value;
struct linked_node* next;
struct linked_node* prev;
};
struct linked_list{
int type_of_list; // normal = 0, stack = 1
struct linked_node* head;
struct linked_node* tail;
int number_of_nodes;
};
-----------------------------------------------------------------------------------------------------------------------------
#include "linked_list.h"
#include "string.h"
int list_exist;
struct linked_list* create_list (int number_of_nodes, int
list_type)
{
int a[number_of_nodes];
int i, j;
int bFound;
if (number_of_nodes < 1)
{
printf("Function create_list: the
number of nodes is not specified correctly\n");
return NULL;
}
if(list_exist == 1)
{
printf("Function create_list: a
list already exists\nRestart a Program\n");
exit(0);
}
if(list_type != 0 && list_type != 1)
{
printf("Function create_list: the
list type is wrong\n");
exit(0);
}
struct linked_list * new_list = (struct
linked_list*)malloc(sizeof(struct linked_list));
new_list->head = NULL;
new_list->tail = NULL;
new_list->number_of_nodes = 0;
new_list->type_of_list = list_type;
//now put nodes into the list with random
numbers.
srand((unsigned int)time(NULL));
if(list_type == 0)
{
for ( i = 0; i <
number_of_nodes; ++i )
{
while ( 1
)
{
a[i] = rand() % number_of_nodes + 1;
bFound = 0;
for ( j = 0; j < i; ++j )
{
if ( a[j] == a[i] )
{
bFound =
1;
break;
}
}
if ( !bFound )
break;
}
struct
linked_node* new_node = create_node(a[i]);
insert_node(new_list, new_node);
}
}
else if(list_type == 1)
{
for ( i = 0; i <
number_of_nodes; ++i )
{
while ( 1
)
{
a[i] = rand() % number_of_nodes + 1;
bFound = 0;
for ( j = 0; j < i; ++j )
{
if ( a[j] == a[i] )
{
bFound =
1;
break;
}
}
if ( !bFound )
break;
}
struct
linked_node* new_node = create_node(a[i]);
push_Stack(new_list, new_node);
}
}
list_exist = 1;
printf("List is created!\n");
return new_list;
}
struct linked_node* create_node (int node_value)//This
functon is the example for reference of the assignment
function
{
struct linked_node* node = (struct
linked_node*)malloc(sizeof(struct linked_node));
node->value = node_value;
node->next = NULL;
node->prev = NULL;
return node;
}
void insert_node(struct linked_list* list, struct
linked_node* node)//This functon is the example for reference of
the assignment function
{
node->next = NULL;
node->prev = NULL;
if(list->head == NULL)
//if head is NULL, tail is also NULL.
{
list->head = node;
list->tail = node;
list_exist = 1;
}
else if(list->head == list->tail)
{
node->next =
list->head;
list->head->prev =
node;
list->head = node;
}
else if(list->head != list->tail)
{
node->next =
list->head;
list->head->prev =
node;
list->head = node;
}
(list->number_of_nodes)++;
}
void pop_Stack(struct linked_list* list, int
number)//The function to be written!!
{
~~~~~~~~~~~~~ //your code starts from here
}
In: Computer Science
Hello, I would like to know there is a known vulnerabilities for an SQL server on Windows operating systems and should databases have the ability to set a policy and enforce the rules that the password should abide by?
In: Computer Science
In the Stack Module I gave you a project that shows how to create a Stack using doubly linked nodes.
StackWithDoublyLinkedNodes.zip
It is a template class that needs the Node class. You must use this same Node class (no alterations) to create a Queue class .
public class Queue <T>{
}
Use the NetBeans project above as an example.
I have put a driver program (q1.java) in the module. Also here: q1.java This driver program should then run with your Queue class (no modifications allowed to the driver program).
Your Queue class should have at least the following methods: one or more constructors, enqueue, dequeue, peek, isEmpty, size, makeEmpty.
MUST INCLUDE:
Template Class
constructor
enqueue
dequeue
peek
isEmpty
size
makeEmpty
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Q1.java
public class Q1 {
public static void main(String[] args) {
Queue <String> myQ = new Queue<String>(); //string Q
String[] names = {"harry", "mary", "mosi", "sadie","tom", "janice"};
for (int i=0; i<names.length;i++)
myQ.enqueue(names[i]);
System.out.println("Size is " + myQ.getSize());
for (int i=0; i<6; i++)
System.out.println(myQ.dequeue()); //test that it also works for integers
Integer[]numbers={4,5,6,7,8,17,100};
Queue<Integer> myI = new Queue<Integer>(); //Integer Q
for (int i=0; i<numbers.length;i++)
myI.enqueue(numbers[i]);
System.out.println("Size is " + myI.getSize());
//Verify it adds (and is an integer Q) and doesn't concatenate(String Q)
int total=0;
int tempSize=myI.getSize();
System.out.println("Integers in Queue are:");
for (int i=0; i<tempSize; i++)
//cannot use getSize() here because it changes every time you dequeue
{Integer val = myI.dequeue();
System.out.print(val+ " ");
total=total+val;
}
System.out.println("\nTotal is:" + total);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
StackWithDoublyLinkedNodes.java
public class StackWithDoublyLinkedNodes {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Stack<Integer> s = new Stack<Integer>();
Integer[] x = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
for (int i = 0; i < x.length; i++) {
Integer t = x[i];
s.push(t);
}
while (!s.isEmpty()) {
System.out.println(s.pop());
}
//verify the stack is empty and that
//we took care of the issues
//of trying to pop an empty stack
//and peek at the top of an empty stack
System.out.println(s.pop());
System.out.println(s.peek());
System.out.println("********************************");
//repeat using a stack of Strings
System.out.println("Repeat using a Stack of Strings");
Stack<String> s1 = new Stack<String>();
String[] x1 = {"Hi", "Bye", "One", "Four","CMPSC"};
for (int i = 0; i < x1.length; i++) {
String t1 = x1[i];
s1.push(t1);
}
while (!s1.isEmpty()) {
System.out.println(s1.pop());
}
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Stack.java
public class Stack<T> {
private Node head;
private int size;
Stack() {
head = null;
size = 0;
}
public void push(T newItem) {
Node temp = new Node(newItem);
if (this.isEmpty()) {
head = temp;
} else {
temp.setNext(head);
head.setPrev(temp);
head = temp;
}
size++;
}
public T pop() {
if (isEmpty()) {
return (T)"Empty List";
}
T temp = (T) head.getItem();
head = head.getNext();
if (head != null) {
head.setPrev(null);
}
size--;
return temp;
}
public T peek() {
if(isEmpty()){
return (T)"Empty List";
}
return (T) head.getItem();
}
public int getSize() {
return size;
}
public boolean isEmpty() {
return size == 0;
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Node.java
public class Node<T> {
//Node makes item, next, and prev all private
//and therefore has to provide accessors
//and mutators (gets and sets)
private T item;
private Node next;
private Node prev;
Node(T newItem) {
item = newItem;
next = null;
prev = null;
}
Node(T newItem, Node nextNode, Node prevNode) {
item = newItem;
next = nextNode;
prev = prevNode;
}
/**
* @return the item
*/
public T getItem() {
return item;
}
/**
* @param item the item to set
*/
public void setItem(T item) {
this.item = item;
}
/**
* @return the next
*/
public Node getNext() {
return next;
}
/**
* @param next the next to set
*/
public void setNext(Node next) {
this.next = next;
}
/**
* @return the prev
*/
public Node getPrev() {
return prev;
}
/**
* @param prev the prev to set
*/
public void setPrev(Node prev) {
this.prev = prev;
}
}
In: Computer Science
Language: Java
To be able to code a class structure with appropriate attributes and methods. To demonstrate the concept of inheritance. To be able to create different objects and use both default and overloaded constructors. Practice using encapsulation (setters and getters) and the toString method.
Create a set of classes for various types of video content (TvShows, Movies, MiniSeries). Write a super or parent class that contains common attributes and subclasses with unique attributes for each class. Make sure to include the appropriate setter, getter methods and toString to display descriptions in a nicely formatted output. In addition to default constructors, define overloaded constructors to accept and initialize class data. When using a default constructor, use the setter from the main program to set values. Use a static variable to keep track of the number of objects in the video library. Display the number of items prior to listing them.
Data for movies should contain attributes for the title, release date, genre, studio, and streaming source (Netflix, Prime or Hulu).
Data for TvShow should contain the title, genre (same as others), date of the first episode, number of seasons, network, and running time.
Data for MiniSeries should include attributes for title, genre (same as others), number of episodes, running time, lead actor or actress.
Create a main driver class to create several objects of each type of video content. Use examples of both the default and overloaded constructors. Then display your complete video library with all fields.
All required variables are members of the class. Appropriate use of access specifiers. Encapsulation is implemented with setters and getters. Code is well structured and commented. Code meets standard Java conventions.
There is a default (no-arg) constructor, and an overloaded constructor for each video type. Objects created all have appropriate data content. A static variable is implemented and correctly counts objects created.
Methods are established in the class for all appropriate setters and getters. Inheritance is properly demonstrated with appropriate attributes, methods, and object instantiation.
The VideoLibrary class properly creates all the required objects and displays the entire video library with the number of items and all the data content in a nicely formatted output.
In: Computer Science
New to C programming and I am stuck. The program will print "no input" if no input is given. If a command line argument is given the program will print "input:" followed by the user input. Below is the code I put together to do as desired but I get errors. What do I need to fix to get my code to compile correctly?
#include <stdio.h>
#include <stdlib.h>
int main ()
{
char input;
scanf("%c", &input);
if (input == NULL)
{
printf("no input");
}
else
{
printf("input:",input);
}
return 0;
}
In: Computer Science
Write code for a simple snake game (using dots) on C program.
Using openframeworks. it should be simple because I am new to coding and I cant write complicated code.
just make it simple.
In: Computer Science
int Function(int n)
{
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
for(int k = 0; k < n; k++)
{
Print(“hello world”);
}
}
}
}
In: Computer Science
Write a simple Python program that will generate two random between 1 and 6 ( 1 and 6 are included).
If the sum of the number is grader or equal to 10 programs will display “ YOU WON!!!”. if the sum is less than 10, it will display “YOU LOST”.
After this massage program will ask users a question: “if you want to play again enter Y. if you want to exit enter ‘N’)
If the user enters Y they will continue to play and if they enter N the program terminates.
In: Computer Science
Create your initial post on the DQ 3 Discussion Board in
response to the following questions:
In: Computer Science
Let’s say that we work at some new video store and need to design some classes that will help us organize our database of movies. You are to write the following classes:
Write a class called Video that will have the following properties:
Declare the instance fields title (String), length (int), avail (Boolean)
Declare two constructors
One default
One with title and length as parameters
Write a method that will output the fields of the objects by overriding the print method
Write an accessor method for availability:
public boolean getAvail()
Write a mutator method for availability!
public void setAvail(boolean b)
2. Write another class called Movie that will inherit the properties of the Video class but will also define two new fields: the movie rating and the name of the director. Give the movie class it’s own print method and constructors for default and with title, length, rating, and director as paramenters.
3. In the Main.java class create the following objects:
Video – Name: CPC Sports, 90 mins Available: No
Video - Name: CPC Through the Years, 2 hours, Available: Yes
Movie- Name: Mission Impossible 4, 2 hours 30 mins, Available: No, Director: Brad Bird, Rating: 4 stars
Movie- Name: Star Wars, 2 hours, Available: Yes: Director: George Lucas, Rating 5 stars
Can you change the availability of a movie using the mutator method from Video?
Given Code:
Main.java
class Main {
public static void main(String[] args) {
}
}
Video.java
class Video{
}
Movie.java
class Movie extends Video{
}
In: Computer Science
<!doctype html>
<html lang="en">
<head>
<title>Programming 1</title>
<meta charset="utf-8"/>
</head>
<body>
<script type="text/javascript">
function findAnswer() {
var a = new Date(2020, 12, 29);
// HINT: Be careful with getMonth()
var d = a.getFullYear() + a.getMonth();
var sum = d % 5;
document.getElementById("ans").innerHTML = sum.toString();
}
</script>
<form action="#" method="post" name="form1" id="form1" class="form" >
<input type="button" name="Submit" id="submit" value="Submit" onclick="findAnswer();"/>
</form>
<p id ="ans"></p>
</body>
</html>
none
Will the code from above print anything, if so, what printed ? If not, say NONE.
In: Computer Science
Nice Number Programming: Nice program ask user to enter three integers from keyboard (java console), the three integers represent left bound, right bound and arbitrary digit ‘m’, where left bound is less than right bound. Program should print all nice numbers in the given range that doesn’t contain digit 'm'. The number is nice if its every digit is larger than the sum of digits which are on the right side of that digit. For example 741 is a nice number since 4> 1, and 7> 4+1. with digit m=2 Write a complete program in Java that Call only One method (niceNumbers method) that will print all nice numbers excluding a given digit ‘m’ that also entered by user ? Input Sample : Enter Left bound: 740 Enter Right bound:850 Enter digit to exclude it:2 Output sample: Nice Numbers in Range Left=740, Right=850 with exclude digit m= 2 are: 740 741 750 751 760 810 830 831 840 841 843 850 Your method prototype is like this: public static void niceNumbers(int left, int right, int dight) { ...
In: Computer Science
Write a simple Python program that will generate two random between 1 and 6 ( 1 and 6 are included). If the sum of the number is grader or equal to 10 programs will display “ YOU WON!!!”. if the sum is less than 10, it will display “YOU LOST”. After this massage program will ask users a question: “if you want to play again enter Y. if you want to exit enter ‘N’) If the user enters Y they will continue to play and if they enter N the program terminates.
In: Computer Science