NoSQL databases can store relationship data—they just store it differently than relational databases do. How would you describe the differences between a relational database and a NoSQL database? What do you see as the business advantages that a NoSQL database has over a relational database?
In: Computer Science
Describe an aspect of your everyday life that has been touched by Big Data and/or Business Intelligence Systems. Be sure to include your thoughts on the advantages or challenges you feel Big Data poses for modern data driven businesses.
In: Computer Science
In: Computer Science
Question 1: Car Dealership Scenario. Complete parts A – D based on the database specifications listed below.
Database Specification
Parts A - D
Queries: Write and run SQL queries for the following questions. Use the minimum number of tables required for each query.
In: Computer Science
For each of bubble sort and insertion sort, state briefly
(i) what the best case input is,
(ii) what the best case running time complexity (in big O) is for an input file of N elements is and
(iii) why the best case running time complexity is like that
In: Computer Science
Below is my c program code you have to change all the functions names variables name , every thing so it wont look same but runs the same and make sure you run the program and share the output so i get to know that the program is running thank you.
#define _CRT_SECURE_NO_DEPRECATE
#include
#include
#include
#include
#include
struct patient {
int id;
int age;
bool annualClaim;
int plan;
char name[30];
char contactNum[15];
char address[50];
};
#define MAX_LENGTH 500
struct patient patients[100];
int patientCount = 0;
struct claim {
int id;
int claimedYear;
int amountClaimed;
int remaininigAmount;
};
struct claim claims[100];
void subscribe()
{
system("cls");
patients[patientCount].id = patientCount + 1;
printf("Enter age: ");
scanf("%d", & patients[patientCount].age);
printf("\n\n%-25sHealth Insurence Plan\n\n", " ");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20s|%-20s|%-20s|\n", " ", "Plan 120(RM)", "Plan
150(RM)", "Plan 200(RM)");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20d|%-20d|%-20d|\n", "Monthly Premium", 120, 150,
200);
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20d|%-20d|%-20d|\n", "Annual Claim Limit", 120000,
150000, 200000);
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20d|%-20d|%-20d|\n", "Lifetime Claim Limit",
600000, 750000, 1000000);
printf("-----------------------------------------------------------------------------------------------\n");
printf("\n\n%-25sAge Group and Health Insurence Plan\n\n", "
");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-25s%-30s\n", "Types of Claim", " ", "Eligibility
Amount");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20s|%-20s|%-20s|\n", " ", "Plan 120(RM)", "Plan
150(RM)", "Plan 200(RM)");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20s|%-20s|%-20s|\n", "Room Charges", "120/day",
"150/day", "200/day");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20s|%-20s|%-20s|\n", "Intensive Care Unit",
"250/day", "400/day", "700/day");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20s|%-20s|%-20s|\n", "Hospital Supplies and
Services", " ", " ", " ");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-60s|\n", "Surgical Fees", "As charged Sbject to
approval by ZeeMediLife");
printf("-----------------------------------------------------------------------------------------------\n");
printf("|%-30s|%-20s|%-20s|%-20s|\n", "Other Fees", " ", " ", "
");
printf("-----------------------------------------------------------------------------------------------\n\n");
int ch;
do {
printf("Select a Claim Limit Type\n1-Annual Claim Limit 2-Lifetime
Claim Limit: ");
scanf("%d", & ch);
} while (ch < 1 || ch > 2);
if (ch == 1)
patients[patientCount].annualClaim = true;
else
patients[patientCount].annualClaim = false;
do {
printf("Select a plan\n1-Plan120 2-Plan150 3-Plan200: ");
scanf("%d", & ch);
} while (ch < 1 || ch > 3);
patients[patientCount].plan = ch;
printf("Enter Name: ");
scanf("%s", & patients[patientCount].name);
printf("Contact Number: ");
scanf("%s", & patients[patientCount].contactNum);
printf("Enter Address: ");
scanf("%s", & patients[patientCount].address);
FILE * fp;
fp = fopen("patients.txt", "a");
fprintf(fp, "%d,%s,%d,%d,%d,%s,%s\n", patients[patientCount].id,
patients[patientCount].name, patients[patientCount].age,
patients[patientCount].annualClaim, patients[patientCount].plan,
patients[patientCount].contactNum,
patients[patientCount].address);
fclose(fp);
time_t s;
struct tm * currentTime;
s = time(NULL);
currentTime = localtime( & s);
claims[patientCount].id = patients[patientCount].id;
claims[patientCount].amountClaimed = 0;
claims[patientCount].claimedYear = currentTime -> tm_hour +
1900;
if (patients[patientCount].annualClaim == true)
{
if (patients[patientCount].plan == 1)
claims[patientCount].remaininigAmount = 120000;
else if (patients[patientCount].plan == 2)
claims[patientCount].remaininigAmount = 150000;
else
claims[patientCount].remaininigAmount = 200000;
} else
{
if (patients[patientCount].plan == 1)
claims[patientCount].remaininigAmount = 600000;
else if (patients[patientCount].plan == 2)
claims[patientCount].remaininigAmount = 750000;
else
claims[patientCount].remaininigAmount = 1000000;
}
patientCount++;
fp = fopen("claims.txt", "a");
if (fp == NULL)
printf("File Dont exist");
fprintf(fp, "%d,%d,%d,%d\n", claims[patientCount].id,
claims[patientCount].claimedYear,
claims[patientCount].amountClaimed,
claims[patientCount].remaininigAmount);
fclose(fp);
system("pause");
}
void claimProcess()
{
int id;
bool found = false;
system("cls");
printf("Enter patient ID for which you want to claim insurrence:
");
scanf("%d", & id);
int i;
for (i = 0; i < patientCount; i++)
{
if (patients[i].id == id)
{
found = true;
break;
}
}
if (found == false)
{
printf("subscriber not found\n");
return;
}
int numOfDaysHospitalized, suppliesCost, surgicalFee,
otherCharges;
bool ICU;
printf("How many days were you haspitalized: ");
scanf("%d", & numOfDaysHospitalized);
int ICUFlag;
do {
printf("Select A Ward Type\n1-Normal Ward 2-ICU: ");
scanf("%d", & ICUFlag);
} while (ICUFlag < 1 || ICUFlag > 2);
if (ICUFlag == 2)
ICU = true;
else
ICU = false;
printf("Enter Cost of Supplies and Services: ");
scanf("%d", & suppliesCost);
printf("Enter Surgical Fees: ");
scanf("%d", & surgicalFee);
printf("Enter Other Charges: ");
scanf("%d", & otherCharges);
int ICUCharges = 0;
if (ICU == true)
{
if (patients[i].plan == 1)
ICUCharges = numOfDaysHospitalized * 120;
else if (patients[i].plan == 2)
ICUCharges = numOfDaysHospitalized * 150;
else
ICUCharges = numOfDaysHospitalized * 200;
} else
{
if (patients[i].plan == 1)
ICUCharges = numOfDaysHospitalized * 250;
else if (patients[i].plan == 2)
ICUCharges = numOfDaysHospitalized * 400;
else
ICUCharges = numOfDaysHospitalized * 700;
}
int totalClaimAmount = numOfDaysHospitalized + suppliesCost +
surgicalFee + otherCharges + ICUCharges;
if (patients[i].annualClaim == true)
{
if (patients[i].age > 60)
{
printf("The subscriber age has exceeded the limit(60 Year), Not
Eligible");
return;
}
}
int j;
for (j = 0; j < patientCount; j++)
{
if (claims[j].id == patients[i].id)
break;
}
int amountToBeBorne = 0;
if (totalClaimAmount <= claims[j].remaininigAmount)
{
claims[j].amountClaimed += totalClaimAmount;
claims[j].remaininigAmount -= totalClaimAmount;
} else
{
amountToBeBorne = totalClaimAmount -
claims[j].remaininigAmount;
claims[j].amountClaimed += (totalClaimAmount -
amountToBeBorne);
claims[j].remaininigAmount = 0;
printf("\n\nThe amount that can be claimed is less then the claim
by subscriber. %d RM should be given by subscriber themselves\n",
amountToBeBorne);
}
FILE * fp;
fp = fopen("claims.txt", "w");
for (int i = 0; i < patientCount; i++)
fprintf(fp, "%d,%d,%d,%d\n", claims[i].id, claims[i].claimedYear,
claims[i].amountClaimed, claims[i].remaininigAmount);
fclose(fp);
printf("Subscriber ID: %d\nSubscriber Name: %s\nSubscriber Claimed
Year: %d\nSubscriber amount Claimed: %d\nSubscriber Remaining
Claimed: %d\n", claims[j].id, patients[i].name,
claims[j].claimedYear, claims[j].amountClaimed,
claims[j].remaininigAmount);
system("pause");
}
void accountInfo()
{
system("cls");
int ch;
printf("1-Total Amount Claimed by LifeTime Claim Limit
subscriber\n");
printf("2-Total number of Annual Claim Limit who have exhausted all
their eligible amount\n");
scanf("%d", & ch);
if (ch == 1)
{
int totalAmountClaimedByLifeTimeSubs = 0;
for (int i = 0; i < patientCount; i++)
{
if (patients[i].annualClaim == false)
{
for (int j = 0; j < patientCount; j++)
{
if (claims[j].id == patients[i].id)
{
totalAmountClaimedByLifeTimeSubs += claims[j].amountClaimed;
}
}
}
}
printf("\nTotal amount Claimed By LifeTime Subscribers is: %d\n",
totalAmountClaimedByLifeTimeSubs);
} else
{
int count = 0;
for (int i = 0; i < patientCount; i++)
{
if (claims[i].remaininigAmount <= 0 &&
patients[i].annualClaim == true)
count++;
}
printf("Total number of Annual Claim Limit Subcriber who have
exhausted all their amount are: %d\n", count);
}
system("pause");
}
void searchingFunctionalities()
{
system("cls");
int ch;
printf("1-Search by ID\n2-Search by age\n");
scanf("%d", & ch);
if (ch == 1)
{
int id;
printf("Enter patient ID for which you want Search: ");
scanf("%d", & id);
int i;
for (i = 0; i < patientCount; i++)
{
if (patients[i].id == id)
{
printf("\nSubscriber Name: %s\nSubscriber Age: %d\nSubscriber
Contact: %s\nSubscriber Address: %s\n", patients[i].name,
patients[i].age, patients[i].contactNum,
patients[i].address);
break;
}
}
printf("Subscriber Not Found");
} else
{
int age;
printf("Enter age for which you want Search: ");
scanf("%d", & age);
for (int i = 0; i < patientCount; i++)
{
if (patients[i].age == age)
{
printf("\nSubscriber Name: %s\nSubscriber ID: %d\nSubscriber
Contact: %s\nSubscriber Address: %s\n", patients[i].name,
patients[i].id, patients[i].contactNum, patients[i].address);
}
}
}
system("pause");
}
void loadData()
{
char line[MAX_LENGTH];
const char * delimiter = ",\n";
FILE * fp;
fp = fopen("patients.txt", "r");
char c;
if (fp == NULL)
{
printf("file not found");
return;
}
while (fp != NULL)
{
if (fgets(line, MAX_LENGTH - 1, fp) == NULL)
break;
if (line[1] == '\0')
break;
patients[patientCount].id = atoi(strtok(line, delimiter));
strcpy(patients[patientCount].name, strtok(NULL, delimiter));
patients[patientCount].age = atoi(strtok(NULL, delimiter));
patients[patientCount].annualClaim = strtok(NULL, delimiter);
patients[patientCount].plan = atoi(strtok(NULL, delimiter));
strcpy(patients[patientCount].contactNum, strtok(NULL,
delimiter));
strcpy(patients[patientCount].address, strtok(NULL,
delimiter));
strcpy(line, "\0");
patientCount++;
}
fclose(fp);
fp = fopen("claims.txt", "r");
int claimCount = 0;
while (fp != NULL)
{
if (fgets(line, MAX_LENGTH - 1, fp) == NULL)
break;
if (line == "\n")
break;
claims[claimCount].id = atoi(strtok(line, delimiter));
claims[claimCount].claimedYear = atoi(strtok(NULL,
delimiter));
claims[claimCount].amountClaimed = atoi(strtok(NULL,
delimiter));
claims[claimCount].remaininigAmount = atoi(strtok(NULL,
delimiter));
strcpy(line, "\0");
claimCount++;
}
fclose(fp);
}
int menu()
int ch;
do {
system("cls");
printf("Select one of the below option to continue\n");
printf("1-Insurence Plan Subscription\n");
printf("2-Claim Processing\n");
printf("3-Accounts Information\n");
printf("4-Searching Functionalities\n");
printf("5-Exit\n");
scanf("%d", & ch);
} while (ch > 5 || ch < 1);
return ch;
}
int main()
{
int ch;
loadData();
do {
ch = menu();
if (ch == 1)
subscribe();
else if (ch == 2)
claimProcess();
else if (ch == 3)
accountInfo();
else if (ch == 4)
searchingFunctionalities();
else
break;
} while (ch != 5);
system("pause");
return 0;
}
In: Computer Science
Rock-Paper-Scissors
Implement Rock-Paper-Scissors such that the user can play the computer in a best-of series! The user inputs the number of rounds which should be positive and odd. This is a free form assignment but structure your code similar to the test cases provided. USING MATLAB ONLY!!!
Program Inputs
• How many rounds would you like to play (odd rounds only)?:
XXX
– XXX should be positive and odd. Restart the game if the input is not positive or odd.
Program Outputs
• XXX wins this round
– Replace XXX with either User or Computer depending on who wins the round • Game Over!
– After the Game is over display the times User and Computer won after the total number of rounds. Finally display who wins the entire game.
Sample Outputs:
Test Case 1:
Welcome to Rock-Paper-Scissors! Play if you dare! How many rounds would you like to play (odd rounds only)? 3 You choose to do best out of 3 rounds ********************************************************* Round 1 ********************************************************* Rock (0)... Paper (1)... Scissors (2)... Shoot: 1 The computer chooses Rock and you picked Paper User wins this round! *********************************************************
********************************************************* Round 2 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 2 The computer chooses Rock and you picked Scissors Computer wins this round! *********************************************************
********************************************************* Round 3 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 1 The computer chooses Scissors and you picked Paper Computer wins this round! *********************************************************
********************************************************* Game over! User won 1 out of 3 rounds Computer won 2 out of 3 rounds
Computer wins! Did you expect anything else? *********************************************************
Test Case 2:
Welcome to Rock-Paper-Scissors! Play if you dare! How many rounds would you like to play (odd rounds only)? 3 You choose to do best out of 3 rounds ********************************************************* Round 1 ********************************************************* Rock (0)... Paper (1)... Scissors (2)... Shoot: 5 How dare you cheat at rock paper scissors! You lose this round! You muggle! *********************************************************
********************************************************* Round 2 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 7 How dare you cheat at rock paper scissors! You lose this round! You muggle! *********************************************************
********************************************************* Game over! User won 0 out of 3 rounds Computer won 2 out of 3 rounds
Computer wins! Did you expect anything else? *********************************************************
Test Case 3:
Welcome to Rock-Paper-Scissors! Play if you dare! How many rounds would you like to play (odd rounds only)? 1 You choose to do best out of 1 rounds ********************************************************* Round 1 ********************************************************* Rock (0)... Paper (1)... Scissors (2)... Shoot: 5 How dare you cheat at rock paper scissors!
You lose this round! You muggle! *********************************************************
********************************************************* Game over! User won 0 out of 1 rounds Computer won 1 out of 1 rounds
Computer wins! Did you expect anything else? *********************************************************
Test Case 4:
Welcome to Rock-Paper-Scissors! Play if you dare! How many rounds would you like to play (odd rounds only)? 2 2 is not a valid number of rounds... Try again! *********************************************************
How many rounds would you like to play (odd rounds only)? 1 You choose to do best out of 1 rounds ********************************************************* Round 1 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 1 The computer chooses Paper and you picked Paper This round is a tie! Replaying this round... *********************************************************
********************************************************* Round 1 ********************************************************* Rock (0)...
Paper (1)... Scissors (2)... Shoot: 1 The computer chooses Scissors and you picked Paper Computer wins this round! *********************************************************
********************************************************* Game over! User won 0 out of 1 rounds Computer won 1 out of 1 rounds
Computer wins! Did you expect anything else? *********************************************************
In: Computer Science
Is the L(r1) = L(r2) where r1 = (ab*+c)(λ+∅) and r2 = (a+c)(b*+∅)? what are the languages of L(r1), L(r2)? show the definition's using regular expression, assume Σ = (a,b,c)
In: Computer Science
1. Which tag do you use to access an external style sheet? *
a) <a>
b) <head>
c) <style>
d) <link>
2. Which of the following CSS properties below specifies the name of the font to use? *
a) font-face
b) font-type
c) font-family
d) font-use
3. Choose the INVALID value for the area element’s shape attribute. *
a) square
b) rect
c) circle
d) poly
4. Which of these CSS properties DOES NOT have the top, right, left, and bottom specification? *
a) margin
b) border
c) padding
d) None of the above
c) circle
d) poly
5. The hover pseudo-class gives the author access to text styling under which situation? *
a) When the mouse is over an element.
b) When the mouse moves off of an element.
c) When the mouse is to the left of an element.
d) None of the above
6.CSS inline style requires _________ style in order to declare an individual element’s format. *
a) attribute
b) behaviour
c) tag
d) None of the above
7.Select the CORRECT CSS property in order to set image.jpg as the background image. *
a) background-image:url[image.jpg];
b) bground-image:url[image.jpg];
c) background-image:url(image.jpg);
d) bground-image:url(image.jpg);
8. In __________ positioning, elements are positioned relatively to other elements.
a) relative
b) absolute
c) surface
d) dynamic
In: Computer Science
Complete the code(in C) that inserts elements into a list. The list should always be in an ordered state.
#include <stdio.h>
#include <stdlib.h>
/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};
/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);
/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the
list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}
/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}
/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}
/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x)
{
struct element *newelement;
newelement = elementalloc();
struct element *iter = listhead;
while( ) {
}
return listhead;
}
/* print the list and the respective memory locations in list
order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead,
listhead->value);
listhead = listhead->next;
}
}
In: Computer Science
Complete the code that inserts elements into a list. The list should always be in an ordered state.
#include <stdio.h>
#include <stdlib.h>
/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};
/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);
/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the
list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}
/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}
/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}
/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x)
{
struct element *newelement;
newelement = elementalloc();
struct element *iter = listhead;
while( ) {
}
return listhead;
}
/* print the list and the respective memory locations in list
order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead,
listhead->value);
listhead = listhead->next;
}
}
In: Computer Science
Design and Requirements
In order to execute its task the program must compare character values. For instance, a character named symbol is an upper case letter if and only if the boolean expressions ‘A’ <= symbol and
symbol <= ‘Z’ both evaluate true. Analogous expressions can be used to check for lower case letters between ‘a’ and ‘z’ and for digits between ‘0’ and ‘9’. To see if symbol is the ‘$’ or ‘_’ character, the relational operator == shall be used.
Declare a String variable title to store the title of the window as shown in Figure 1 below.
Declare a String variable solicitation to store the input solicitation line, see the template in Figure 1.
Input is solicited on a dialog window as shown in Figure 1, follow the template layout including the icon. In the method that creates the window you must not use the String literals
Figure 1
Declare a String variable input and assign input the String value returned by the window
Validate the input: check out if input is null (the result of the Cancel button) or the empty string (OK button applied with no text written in the window). Empty Strings have zero length, thus input is not accepted if either input == null or input length == zero is true. Using the corresponding Java Boolean expression build an if block. Within the block print the message
No input to process
Program exits
to the console and apply the System.exit(0); statement to terminate the program (no else block is needed here).
Declare an int variable index and a char type variable symbol
Assign index 0 and symbol the the first character of input (use the index variable, not the 0 literal).
Declare two String variables named messageOK and messageNot_OK and assign the String values shown on the message dialogs of Figure 2 and Figure 3. Follow the output templates exactly, including the icons.
Figure 2 Figure 3
Apply an if-else structure to display Figure 2 or Figure 3 according to the cases of a correct or a wrong first character in input. Build a single boolean expression to control the if statement. In the JOptionPane method literals are not allowed, use the declared String variables messageOK or messageNot_OK.
In order to check the second character, re-assign index.
Before the check we have to see if there is a second character. Build and if – else structure, the if is controlled by the expression input.length()>=2
In the if block re-assign the variables symbol, messageOK and messageNot_OK
Copy the previous if – else code into this if block as a nested structure. The boolean expression that controls the nested if( ) must be fitted to the check of the second character (digits are allowed now)
In the else statement of the outer structure print the following message to the console:
There is no second character to check
In: Computer Science
Complete the code that inserts elements into a list. The list should always be in an ordered state.
#include <stdio.h>
#include <stdlib.h>
/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};
/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);
/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the
list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}
/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}
/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}
/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x)
{
struct element *newelement;
newelement = elementalloc();
struct element *iter = listhead;
while( ) {
}
return listhead;
}
/* print the list and the respective memory locations in list
order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead,
listhead->value);
listhead = listhead->next;
}
}
In: Computer Science
Read the following specification and then answer the questions that follow. Specification:
A soccer league is made up of at least four soccer teams. Each soccer team is composed of seven(7) to eleven(11) players, and one player captains the team. A team has a name and a record of wins and losses. Players have a number and a position. Soccer teams play games against each other. Each game has a score and a location. Teams are sometimes lead by a coach. A coach has a level of accreditation and a number of years of experience, and can coach multiple teams. Coaches and players are people, and people have names and addresses.
Question: Carry out an initial object oriented design for the above specification.
You must identify and write down. Classes that you think will be required [5 marks]
Their attributes and behaviours [2 marks]
Any inheritance relationships you can identify [3 marks]
Any other relationships (aggregation or otherwise between the classes) [2 marks]
In: Computer Science
The questions in this assessment use the following.
class R { ... }
class A extends R { ... }
abstract class B extends R { ... }
final class C extends R { ...}
class D extends A { ... }
class E extends B { ... }
class F extends B { ... }
// none of the classes implement a toString() method
[0] Draw a class hierarchy for the classes defined above.
[1] No or Yes: class R extends Object
[2] class G extends C does not compile. Why?
[3] class G extends E, F does not compile. Why?
[4] B doh = new B(); does not compile. Why?
[5] System.out.println(new R()); prints: R@6bc7c054 Why?
[6] No or Yes: class D can have subclasses (children).
[7] If public String toString() { return "Arizona"; }
is added to class A, then System.out.println(new D());
prints what?
[8] Assume the following is added to class C.
public String toString() {
int azAgeIn2018 = 2018 - 1912;
return "Arizona is " + azAgeIn2018 + " years young!";
}
What does System.out.println(new C()); print?
[9] System.out.println(new R().hashCode()); prints: 1808253012.
No public int hashCode() method is implemented in class R.
Briefly explain why this compiles and runs?
[10] If public int hashCode() { return 48; } is added to
class R, then what does the following statement print?
System.out.println("Arizona is state# " + new R().hashCode());In: Computer Science