Questions
Exercise: Add Monster Cast Member ------------------------- ### Description In this series of exercises, you will create...

Exercise: Add Monster Cast Member
-------------------------

### Description

In this series of exercises, you will create functions
to create, modify and examine dictionaries that
represent characters in an animated film, and the
cast members who voice the characters. The
keys of the dictionary will be character names.
The values in the dictionary will be voice actor
names.

For this exercise, you will create a function that
adds an entry to a dictionary. They key is a
character name, and the value is the name of the
voice actor.

### Files

* `monsterfunctions.py` : set of functions to work with monster cast dictionaries.

### Function Name

`add_cast_member`

### Parameters

* `monsters`: a dictionary
* `character`: a string, the name of a character
* `cast_member`: a string, the name of an actor

### Action

Adds an entry to `monsters`, using `character` as the
key and `cast_member` as the value.

### Return Value

The modified dictionary.

def create_monster_cast():
d1={}
return d1
def add_cast_member(monsters, character, cast_member):
dict = {
"monsters":monsters,
"character":character,
"cast_member":cast_member
}
return dict

In: Computer Science

Library Management System allows the user to borrow and return the books. The book is identified...

Library Management System allows the user to borrow and return the books. The book is identified by book name, accession number, item category, due date, due time, and status. Before the user proceeds to borrow or return the books, they need to register for an account. Each user can have only one account. The user can be a staff or student. Each user is identified by ID number, name, school/department name, address. The books are arranged on a shelf. The shelf can be of two categories: open shelf or red spot. The user is allowed to reserve the book, in case, if the book is already borrowed by someone. While reserving a book, the user needs to specify the user name, ID number, book name, and accession number.

##Based on the above scenario, draw a Class Diagram. Your diagram should include attributes, methods and multiplicity.

In: Computer Science

A system is set up to take raw grading information from the console and calculate a...

A system is set up to take raw grading information from the console and calculate a consolidated grade. The information comes in as a single line with last name, first name, homework grade ( a total out of 20 ), lab grade ( a total out of 50 ), exam grade average, and a letter ( upper or lower ) indicating Audit, Passfail, or Grade.

Sample input:                    Mary(first name) Poppins(last name) g(indication) 17(homework grade) 28(lab grade) 87(exam grade)

A program should be written that takes the input data and calculates a consolidated grade based upon 10% Homework, 20 % Lab , and 70% Exams. The output should be formatted with no decimals.

first initial last name - final grade  

for a pass/fail student output should indicate only Pass or Fail . For an audit output should say not gradeable.

Using C++

In: Computer Science

Please use C programming to write the code to solve the following problem. Also, please use...

Please use C programming to write the code to solve the following problem. Also, please use the instructions, functions, syntax and any other required part of the problem. Thanks in advance. Use these functions below especially:

void inputStringFromUser(char *prompt, char *s, int arraySize);

void songNameDuplicate(char *songName);

void songNameFound(char *songName);

void songNameNotFound(char *songName);

void songNameDeleted(char *songName);

void artistFound(char *artist);

void artistNotFound(char *artist);

void printMusicLibraryEmpty(void);

void printMusicLibraryTitle(void);

const int MAX_LENGTH = 1024;

You will write a program that maintains information about your personal music library using a Linked List data structure. The program will allow you to add and delete entries from your personal music library, to search your personal music library for songs by song name, and to print out the entire list of your library. This lab will be due in the week of April 1.

Your Personal Music Library. The data in your personal music library will be stored in memory with the use of a linked list, with one list node per song. Each node will contain three strings: a song’s name, its artist, and its genre (the type of music). The linked list must be kept in sorted alphabetical order, by song name, beginning with A through Z (i.e. increasing alphabetical order). No two songs in your personal music library should have the same name. Your program should be “menu” driven, with the user being offered a choice of the following five “commands”:
Command I. Insert a new song into the library. The program should prompt the user for a new song name, its artist’s name, and its genre. This information must be placed in a new node that has been created using the malloc function (to be clear, you must use malloc for this purpose). This node should then be inserted at the appropriate (alphabetical) position in the linked list. Don’t forget that the music library must be stored in increasing order, by song name. If a node with the given song name is already in the music library, an error message should be output, and the new node should not be inserted into the linked list.
Command D. Delete an entry from your the library. The program should prompt the user for the name of the song to be deleted, and then find and delete the node containing that song name from the library. If no node with the given song name is found, an error message should be output. All memory allocated for a deleted entry must be released back to the system using the free function. This includes not only the memory allocated for the node, but also the strings in the node that would have been separately allocated.
Command S. Search for a user supplied song name in the library. The program should print the name, artist, and genre of the song, with each piece of information on a separate line. If no node with the given song name is found, an error message should be output.
Command P. Print your personal music library, in alphabetical order by song name. Print the song name, artist, and genre of each song, each on a separate line. A blank line should be printed between each song.
Command Q. Quit the program. When the program is given the Q command, it should delete all of the nodes in the linked list, including all the strings contained

in each node. Deletion means both removing from the list, but also freeing all dynamically allocated memory using call the free function. It should then print the (what should be an empty) linked list.
To assist you in the production of your program, we have provided you with a file, musiclibrary.c, that contains part of the complete program. This program is provided on the course website along with this lab. This “skeleton” of the lab 9 program includes all of the C statements required to implement the menu driven parts of the program. It also includes a few helpful functions for reading data and printing messages. You should take this file and edit it to become your version of Lab9.c. Note, however, that you may not change any of the code in the existing implementation of the skeleton program, except where indicated in comments. In particular, you must use the inputStringFromUser() function and the prompts provided to obtain inputs from the user, and you must use the given Node structure. In addition we strongly recommend that you do your work for this lab in the following way:

• Read the entire skeleton program carefully. Take note of the provided functions for reading strings, printing the name, artist and genre of a song, and for printing error messages. Using these functions will make it easier for you to satisfy the exercise and marker programs.
• Add the function for inserting a new node(the I command) into the linked list. Your function will need to read the name, artist, and genre of a song. Test your program by trying to insert nodes into the linked list. Try to insert nodes with both new and duplicate song names.
• Add a function for printing the linked list (the P command). Test your program by inserting songs into the linked list and then printing them out. Are the entries in the correct order? • Add a function that searches the linked list for a given song name and then either prints the appropriate song or, if a node is not found, prints an error message. This is the S command.
• Add the statements that need to be executed when the Q command is entered. These statements should delete the linked list by using calls to the free function. To check your work, print the linked list after the elements have been deleted. • Add a function for deleting a song from the personal music library. It will need to search the linked list for a given song name, delete the appropriate node from the linked list, and then use the free function to release the memory used to store the node, as well as all the memory that the node uses for storing strings. If the given song name is not found in the music library, print an error message.
We recommend that you test your program after attempting to complete each step. This way, if your program no longer works, you will know which statements are causing the error. Complete each step before moving on to the next one.

Sample Output From Executing The Program
Here is a sample output from an execution of the program that you are to prepare.

Personal Music Library.
Commands are I (insert), D (delete), S (search by song name), P (print), Q (quit).
Command --> P
The music library is empty.
Command --> I
Song name --> The Shade
Artist --> Metric
Genre --> Rock

Command --> I
Song name --> Heads Will Roll
Artist --> Yeah Yeah Yeahs
Genre --> Punk

Command --> I
Song name --> Bad Boys Need Love Too
Artist --> Bahamas (Afie Jurvanen)
Genre --> Folk

Command --> P

My Personal Music Library:

Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk

Heads Will Roll
Yeah Yeah Yeahs
Punk

The Shade
Metric
Rock

Command --> I
Song name --> Heads Will Roll
Artist --> Yeah Yeah Yeahs
Genre --> Punk

A song with the name 'Heads Will Roll' is already in the music library.
No new song entered.

Command --> I
Song name --> Adult Diversion
Artist --> Alvvays
Genre --> Pop

Command --> P

My Personal Music Library:

Adult Diversion
Alvvays
Pop

Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk

Heads Will Roll
Yeah Yeah Yeahs
Punk

The Shade
Metric
Rock

Command --> S

Enter the name of the song to search for --> Bad Boys Need Love Too

The song name 'Bad Boys Need Love Too' was found in the music library.

Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk

Command --> S

Enter the name of the song to search for --> Young Blood

The song name 'Young Blood' was not found in the music library.

Command --> D

Enter the name of the song to be deleted --> The Shade

Deleting a song with name 'The Shade' from the music library.

Command --> P

My Personal Music Library:

Adult Diversion
Alvvays
Pop

Bad Boys Need Love Too
Bahamas (Afie Jurvanen)
Folk

Heads Will Roll
Yeah Yeah Yeahs
Punk

Command --> Q

Deleting a song with name 'Adult Diversion' from the music library.

Deleting a song with name 'Bad Boys Need Love Too' from the music library.

Deleting a song with name 'Heads Will Roll' from the music library.

The music library is empty.

In: Computer Science

int main() {    footBallPlayerType bigGiants[MAX];    int numberOfPlayers;    int choice;    string name;   ...

int main()
{
   footBallPlayerType bigGiants[MAX];
   int numberOfPlayers;
   int choice;
   string name;
   int playerNum;
   int numOfTouchDowns;
   int numOfcatches;
   int numOfPassingYards;
   int numOfReceivingYards;
   int numOfRushingYards;
   int ret;
   int num = 0;
   ifstream inFile;
   ofstream outFile;
   ret = openFile(inFile);
   if (ret)
       getData(inFile, bigGiants, numberOfPlayers);
   else
       return 1;
   /// replace with the proper call to getData
   do
   {
       showMenu();
       cin >> choice;
       cout << endl;
       switch (choice)
       {
       case 1:
           cout << "Enter player's name: ";
           cin >> name;
           cout << endl;
           playerNum = searchData(bigGiants, num, name);
           printPlayerData(bigGiants, num, playerNum);
           break;
       case 2:
           printData(bigGiants, num);
           break;
       case 3:
           cout << "Enter player name: ";
           cin >> name;
           cout << endl;
           playerNum = searchData(bigGiants, num, name);
           cout << "Enter number of touch downs to be added: ";
           cin >> numOfTouchDowns;
           cout << endl;
           /// replace with call to update TouchDowns from group 1
           break;
       case 4:
           cout << "Enter player name: ";
           cin >> name;
           cout << endl;
           playerNum = searchData(bigGiants, num, name);
           cout << "Enter number of catches to be added: ";
           cin >> numOfcatches;
           cout << endl;
           break;
       case 5:
           cout << "Enter player name: ";
           cin >> name;
           cout << endl;
           playerNum = searchData(bigGiants, num, name);
           cout << "Enter number of passing yards to be added: ";
           cin >> numOfPassingYards;
           cout << endl;
           /// replace with call to updatePassingYards from group 3
           break;
       case 6:
           cout << "Enter player name: ";
           cin >> name;
           cout << endl;
           playerNum = searchData(bigGiants, num, name);
           cout << "Enter number of receiving yards to be added: ";
           cin >> numOfReceivingYards;
           cout << endl;
           /// replace with call to update Receiving Yards from group 4
           break;
       case 7:
           cout << "Enter player name: ";
           cin >> name;
           cout << endl;
           playerNum = searchData(bigGiants, num, name);
           cout << "Enter number of rushing yards to be added: ";
           cin >> numOfRushingYards;
           cout << endl;
           /// replace with call to update Rushing Yards from group 5
           break;
       case 99:
           break;
       default:
           cout << "Invalid selection." << endl;
       }
   } while (choice != 99);
   char response;
   cout << "Would you like to save data: (y,Y/n,N) ";
   cin >> response;
   cout << endl;
   if (response == 'y' || response == 'Y')
       saveData(outFile, bigGiants, num);
   inFile.close();
   outFile.close();
   return 0;
}
/// If file cannot be opened, a 1 is returned.
/// Parameter: ifstream
int openFile(ifstream& in) {
   string filename;
   cout << "Please enter football data file name: ";
   cin >> filename;
   in.open(filename.c_str());
   if (!in)
   {
       cout << filename << " input file does not exist. Program terminates!" << endl;
       return 1;
   }
   return 0;
}
/// Function requests file name from the user and opens file.
/// Post condition: If no error encountered, file is opened.
/// If file cannot be opened, a 0 is returned.
/// Parameter: ofstream
int openOutFile(ofstream& out) {
   string filename;
   cout << "Please enter the name of the output file: ";
   cin >> filename;
   out.open(filename.c_str());
   if (!out)
   {
       return 0;
   }
   return 1;
}
void showMenu()
{
   cout << "Select one of the following options:" << endl;
   cout << "1: To print a player's data" << endl;
   cout << "2: To print the entire data" << endl;
   cout << "3: To update a player's touch downs" << endl;
   cout << "4: To update a player's number of catches" << endl;
   cout << "5: To update a player's passing yards" << endl;
   cout << "6: To update a player's receiving yards" << endl;
   cout << "7: To update a player's rushing yards" << endl;
   cout << "99: To quit the program" << endl;
}
/// Reads data into the structure array
/// Precondition: ifstream is open, howMany initialized to 0
/// Postcondition: the structure array contains data from the input file
/// the howMany parameter contains the number of rows read
/// Parameters: ifstream, structure array, int file read counter
void getData(ifstream& inf, footBallPlayerType list[], int& howMany)
{
   howMany = 0;
   while (inf)
   {
       inf >> list[howMany].name >> list[howMany].position >> list[howMany].touchDowns >> list[howMany].catches >> list[howMany].passingYards >> list[howMany].receivingYards >> list[howMany].rushingYards;
       howMany++;
   }
}

/// Prints statistics for a selected player
/// Precondition: structure array contains data, length contains number of
void printPlayerData(footBallPlayerType list[], int length, int playerNum)
{
   if (0 <= playerNum && playerNum < length)
       cout << "Name: " << list[playerNum].name
       << " Position: " << list[playerNum].position << endl
       << "Touch Downs: " << list[playerNum].touchDowns
       << "; Number of Catches: " << list[playerNum].catches << endl
       << "Passing Yards: " << list[playerNum].passingYards
       << "; Receiving Yards: " << list[playerNum].receivingYards
       << "; Rushing Yards: " << list[playerNum].rushingYards << endl << endl;
   else
       cout << "Invalid player number." << endl << endl;
}
void printData(footBallPlayerType list[], int length)
{
   cout << left << setw(15) << "Name"
       << setw(14) << "Position"
       << setw(12) << "Touch Downs"
       << setw(9) << "Catches"
       << setw(12) << "Pass Yards"
       << setw(10) << "Rec Yards"
       << setw(12) << "Rush Yards" << endl;
   for (int i = 0; i < length; i++)
       cout << left << setw(15) << list[i].name
       << setw(14) << list[i].position
       << right << setw(6) << list[i].touchDowns
       << setw(9) << list[i].catches
       << setw(12) << list[i].passingYards
       << setw(10) << list[i].receivingYards
       << setw(12) << list[i].rushingYards << endl;
   cout << endl << endl;
}
/// Saves updated data to file name entered by user
/// Precondition: structure array contains data, length of array is filled
/// Postcondition: If requested file is opened, updated data is written to the
/// Parameters: ofstream, structure array, int length of array
void saveData(ofstream& outF, footBallPlayerType list[], int length)
{
   int ret;
   ret = openOutFile(outF);
   if (!ret) {
       cout << "Output file did not open...data will not be output to a file. " << endl;
       return;
   }
   for (int i = 0; i < length; i++)
       outF << list[i].name
       << " " << list[i].position
       << " " << list[i].touchDowns
       << " " << list[i].catches
       << " " << list[i].passingYards
       << " " << list[i].receivingYards
       << " " << list[i].rushingYards << endl;
}
/// Finds a football player by name
int searchData(footBallPlayerType list[], int length, string n)
{
   for (int i = 0; i < length; i++)
       if (list[i].name == n)
           return i;
   return -1;
}

I need help with my errors

The header file below

#include <iostream>#include <fstream>#include <string>#include <iomanip>using namespace std;struct footBallPlayerType{ string name; string position; int touchDowns; int catches; int passingYards; int receivingYards; int rushingYards;};const int MAX = 30;int openFile(ifstream&);int openOutFile(ofstream& out);void showMenu();void getData(ifstream& inf, footBallPlayerType list[], int& length);void printPlayerData(footBallPlayerType list[], int length, int playerNum);void printData(footBallPlayerType list[], int length);void saveData(ofstream&

In: Computer Science

1. Name four of the principles of any professional engineering code of ethics (indicate which code you are referencing).


 1. Name four of the principles of any professional engineering code of ethics (indicate which code you are referencing).

 2. Name four reasons it is important for professional engineers to have and follow a code of ethics in their practice.

 3. Name an engineering professional society. Indicate whether this society is one in which you are: (a) an active member, (b) not an active member currently, but you intend to become one or have tried to be one, (c) not an active member, but you know that this society would be appropriate for someone with your major to join, or (d) not a member and this society is not relevant to your major.

 4. Name four reasons it is important or beneficial for professional engineers to have societies and be active in them.

 5. What is a Risk Cost Benefit Analysis? What does it measure?

 6. What is the difference between (a) safety factor (also known as Realized Factor of Safety) and (b) design factor (also known as Required Factor of Safety)? How is each one determined? Which should be greater?

 7. Name four ethical considerations for an engineering project.

 8. Name four ways ethical issues in engineering projects can be addressed or resolved.


 9. Describe an example/case study in which a culture of safety had to be cultivated in order to address problems caused by a previous lack of concern for safety.

 10. Name four factors/conditions that either promote or discourage a culture of safety in a professional environment.


 11. What is a "stakeholder?" Why is it important to consider them when designing a product for market?

 12. Name four duties an ethical professional engineer has to her or his client.


 13. What is the "Precautionary Principle?" What arguments are there in favor of using it for environmental and social impact of technology? What are some criticisms of it?

 14. Name a particular technological artifact and identify four values that are embedded in the technology.


In: Computer Science

Implement a Factory Design Pattern for the code below: MAIN: import java.util.ArrayList; import java.util.List; import java.util.Random;...

Implement a Factory Design Pattern for the code below:

MAIN:

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Main {
public static void main(String[] args) {
Character char1 = new Orc("Grumlin");
Character char2 = new Elf("Therae");

int damageDealt = char1.attackEnemy();
System.out.println(char1.name + " has attacked an enemy " +
"and dealt " + damageDealt + " damage");

char1.hasCastSpellSkill = true;

damageDealt = char1.attackEnemy();
System.out.println(char1.name + " has attacked an enemy " +
"and dealt " + damageDealt + " damage");

int damageTaken = char2.takeHit();
System.out.println(char2.name + " has taken a hit and " +
"been dealt " + damageTaken + " damage");

char2.hasDodgeAttackSkill = true;

damageTaken = char2.takeHit();
System.out.println(char2.name + " has taken a hit and " +
"been dealt " + damageTaken + " damage");
}
}

CHARACTER:

import java.util.Random;

public abstract class Character {
protected String name;
protected int strength;
protected int resilience;
protected boolean hasCastSpellSkill;
protected boolean hasDodgeAttackSkill;

public int attackEnemy() {
Random random = new Random();

int damageDealt;
if (hasCastSpellSkill) {
int spellDamage = random.nextInt(5);
damageDealt = this.strength + spellDamage;
} else {
damageDealt = strength;
}
return damageDealt;
}

public int takeHit() {
Random random = new Random();

int damageDealt = random.nextInt(15);
int damageTaken;
if (hasDodgeAttackSkill) {
double chanceToDodge = random.nextDouble();

if (chanceToDodge > 0.50) {
damageTaken = 0;
} else {
damageTaken = damageDealt - resilience;
}
} else {
damageTaken = damageDealt - resilience;
}

if (damageTaken < 0) {
damageTaken = 0;
}
return damageTaken;
}
}

ELF:

public class Elf extends Character {
public Elf(String name) {
this.name = name;
this.strength = 4;
this.resilience = 2;
}
}

ORC:

public class Orc extends Character {
public Orc(String name) {
this.name = name;
this.strength = 10;
this.resilience = 9;
}
}

In: Computer Science

Could you implement a gpa calculator so that it asks for a letter grade for each...

Could you implement a gpa calculator so that it asks for a letter grade for each of four classes, calculates the gpa, and prints the GPA out along with the student id, major, and name.

/*****************************Student.java*************************/


public class Student {

   // private data members
   private String id;
   private String name;
   private String major;
   private double gpa;

   // default constructor which set the data member to defualt value
   public Student() {

       this.id = "";
       this.name = "";
       this.major = "";
       this.gpa = 0;
   }

   // parameterized constructor
   public Student(String id, String name, String major, double gpa) {
       this.id = id;
       this.name = name;
       this.major = major;
       this.gpa = gpa;
   }

   // getter and setter
   public String getId() {
       return id;
   }

   public void setId(String id) {
       this.id = id;
   }

   public String getName() {
       return name;
   }

   public void setName(String name) {
       this.name = name;
   }

   public String getMajor() {
       return major;
   }

   public void setMajor(String major) {
       this.major = major;
   }

   public double getGpa() {
       return gpa;
   }

   public void setGpa(double gpa) {
       this.gpa = gpa;
   }

   // print student data
   public void printStudent() {

       System.out.println("Student ID: " + id);
       System.out.println("Student name: " + name);
       System.out.println("Student major: " + major);
       System.out.println("Student GPA: " + gpa);
   }

}

/**************************StudentApplication.java*******************/


public class StudentApplication {

   public static void main(String[] args) {
      
       //create object by default constructor
       Student s1 = new Student();
       //create object by overloaded constructor
       Student s2 = new Student("S12345", "Virat Kohli", "Computer Science", 4.5);
       //set the information of object 1
       s1.setName("John Doe");
       s1.setId("S123456");
       s1.setMajor("Electronics");
       s1.setGpa(4.0);
      
       s1.printStudent();
       System.out.println();
       s2.printStudent();
   }
}

In: Computer Science

Your client, Wholesaler, sold a large number of freezers to Retailer on credit. This occurred on...

Your client, Wholesaler, sold a large number of freezers to Retailer on credit. This occurred on May 1, 2017. Wholesaler had purchased these freezers from Manufacturer on March 1, 2017. Manufacturer had purchased the components from Supplier on November 1, 2016. Assume that each transaction is a credit sale and that every creditor timely filed a UCC-1 such that they are secured parties.

A. Now assume that Cindy bought a freezer for her house from Retailer on May 15, 2017. Retailer filed the UCC-1 on July 1, 2017. Cindy sold that freezer to her friend, Cool Girl, on January 5, 2018. Cool Girl was paying Retailer for the debt in Cindy’s name until Cool Girl lost her job on March 1, 2018. Cool Girl has not made a payment since but he has not told Cindy about this either. What are Retailer’s rights as to this freezer? Would that change if Retailer did not file a UCC-1? Why or why not?

B. Assume that Supplier never filed when it sold to Manufacturer. Manufacturer files for Chapter 7 bankruptcy on January 5, 2017 and Manufacturer had not paid Supplier at that time. What are Supplier’s rights and remedies? What is the likely result for Supplier in this Chapter 7 bankruptcy since Supplier never filed?

In: Accounting

Your client, Winston, sold a large number of freezers to Rita on credit. This occurred on...

Your client, Winston, sold a large number of freezers to Rita on credit. This occurred on May 1, 2017. Winston had purchased these freezers from Manny on March 1, 2017. Manny had purchased the components from Supplier on November 1, 2016. Assume that each transaction is a credit sale and that every creditor timely filed a UCC-1 such that they are secured parties.

B. Now assume that Cindy bought a freezer for her house from Rita on May 15, 2018. Rita filed the UCC-1 on July 1, 2018. Cindy sold that freezer to her friend, Cool Girl, on January 5, 2019. Cool Girl was paying Rita for the debt in Cindy's name until Cool Girl lost her job on March 1, 2019. Cool Girl has not made a payment since but he has not told Cindy about this either. What are Rita's rights as to this freezer? Would that change if Rita did not file a UCC-1? Why or why not?

C. Assume that Supplier never filed when it sold to Manny. Manny files for Chapter 7 bankruptcy on January 5, 2018 and Manny had not paid Supplier at that time. What are Supplier's rights and remedies? What is the likely result for Supplier in this Chapter 7 bankruptcy since Supplier never filed?

In: Finance