c++ code please
show differint h files and cpp files
2.3 Task 1
You are working as a programmer designing a vehicular system for the newly forced Edison Arms Company. The weapon system is a generic weapon housing that can fit a number of different weapons that are all controlled by a tank in the same way. Most importantly, is the emphasis on safety. During combat, the weapon systems cannot become unreliable or fail lest the pilots be put in unnecessary danger. The weapons generate heat which will also be a factor. Therefore you will need to provide mechanisms to combat this.
2.3.1 fireControl
This is the mounting system for the weapons. It can store a number of weapons and control them as well as handle problems. It is defined as follows:
fireControl -weapons:weapon ** -numWeapons: int --------------------------- +fireControl(numWeapons:int, weaponList: string *) +~fireControl()
+accessWeapon(i:int):weapon *
The class variables are as follows:
weapons: A 1D array of weapon pointers. It must be able to accept any type of weapon defined in the hierarchy.
numWeapons: The number of weapons that are mounted into the system. The class methods are as follows:
fireControl: This is the constructor. It will receive a list of weapon names as a string array plus the number of weapons. It must allocate memory for the weapons variable and create a weapon based on the information provided by the string array. Create one weapon of the type indicated at each index of the array. If the name of the weapon contains missile, then a missile type weapon must be created and similarly for laser. This should not be case sensitive. For example given the string [”Laser Beam”, ”laser rifle”,”missile pod”, ”missiles”], 4 weapons would be created, the first two being of the class laser, and the last two of the class missile. The default strength for a laser weapon should be set to 5 when creating laser weapons.
∼fireControl: The class destructor. It must deallocate all of the memory assigned to the class.
accessWeapon: This receives an int which provides an index in the weapons list. It will return the weapon that is stored at that position. If no such weapon is found there, then throw a weaponFailure exception.
2.3.2 weaponFailure
This is a custom exception class used in the context of this system. It will inherit publicly from the exception class. You will need to override specifically the what method to return the statement ”Weapon System Failure!” without the quotation marks. The name of this class is weaponFailure. This exception will be used to indicate a failure of the weapon system. You will implement this exception in the fireControl class as a struct with public access. You will need to research how to specify exceptions due to the potential for a ”loose throw specifier error” and what clashes this might have with a compiler. Remember that implementations of classes and structs must be done in .cpp files.
As a hint, all of the exception structs in this practical will have three functions:
• A constructor
• a virtual destructor with a throw() specifier
• a const what function which returns a const char* with a throw()
specifier.
2.3.3 ammoOut
This is a custom exception class used in the context of this system. It will inherit publicly from the exception class. You will need to override specifically the what method to return the statement ”Ammo Depleted!” without the quotation marks. The name of this class is ammoOut. This exception will be used to indicate a depletion of ammunition for a weapon. You will implement this exception in the weapon class as a struct with public access. You will need to research how to specify exceptions due to the potential for a ”loose throw specifier error” and what clashes this might have with a compiler. Remember that implementations of classes and structs must be done in .cpp files.
2.3.4 Weapon Parent Class
This is the parent class of laser and missile. Both of these
classes inherit publicly from
it. It is defined according to the following UML diagram:
weapon -ammo:int -type:string -name: string ------------------- +weapon() +weapon(a:int, t:string, n:string) +getAmmo():int +setAmmo(a:int):void +getType():string +setType(s:string):void +getName():string +setName(s:string):void +ventWeapon(heat:T):void
+∼weapon()
+fire()=0:string
The class variables are as follows:
• ammo: The amount of ammo stored in the weapon. As it is fired, this will deplete. • type: The type of the weapon as a string which relates to its class.
The class methods are as follows:
weapon: The default class constructor.
weapon(a:int, t:string, n:string): The constructor. It will take three arguments and instantiate the class variables accordingly with name being the last variable set.
getAmmo/setAmmo: The getter and setter for the ammo.
getType/setType: The getter and setter for the type.
getName/setName: The getter and setter for the name.
∼weapon: The destructor for the class. It is virtual.
fire: This is the method that will fire each of the weapons and produce a string of the outcome. It is virtual here.
ventWeapon: This is a template function. It will receive a generic parameter rep- resenting some amount of heat. When called the function should determine the number of cooling cycles needed for the weapon to cool based on the amount of heat that is passed in. For every 10 units of heat, 1 cycle will be needed. You need to display a number of lines of output (with new lines at the end) to represent this. For example, if there’s 50.83 heat passed or 50 heat passed in, the output should be:
Heat Cycle 1
Heat Cycle 2
Heat Cycle 3
Heat Cycle 4
Heat Cycle 5
Pay attention to the format of the output messages. If the heat is less than 10, then display with a newline at the end:
Insufficient heat to vent
2.3.5 laser
The ionCannon is defined as follows:
laser -strength:int ------------------------------ +laser(s:int) +~laser() +setStrength(s:int):void +getStrength():int +fire():string
The class variables are as follows:
• strength: The strength of the laser. Lasers get stronger the
longer they are fired.
The class methods are as follows:
laser: The class constructor. This receives an initial strength for the laser.
∼laser: This is the destructor for the laser. It prints out ”X Uninstalled!” without the quotation marks and a new line at the end when the class is deallocated. X refers to the name of the weapon. For example:
Tri Laser Cannon Uninstalled!
fire: If the laser still has ammo, it must decrease the ammo by 1. It will also increase the strength by 1. It will return the following string: ”X fired at strength: Y” where Y represents the strength before firing and X, the name of the weapon. Do not add quotation marks. If ammo is not available, instead throw the ammoOut exception.
getStrength/setStrength: The getter and setter for the strength variable. 2.3.6 missile
The missile is defined as follows:
missile ------------------------------ +missile() +~missile() +fire():string
The class methods are as follows:
missile: This is the constructor for the class.
∼missile: This is the destructor for the missile. It prints out ”X Uninstalled!” without the quotation marks and a new line at the end when the class is deallocated. X refers to the name of the weapon. For example:
Missile Rack Uninstalled!
fire: If the rifle still has ammo, it must decrease the ammo by 1. It will return the following string: ”X fired!”. X refers to the name of the weapon. Do not add quotation marks. If ammo is not available, instead throw the ammoOut exception.
You should use the following libraries for each of the
classes:
• fireControl: iostream, string, sstream, algorithm, cstring,
exception • weapon: string, iostream, exception, sstream
Your submission must contain fire- Control.h, fireControl.cpp, laser.h, laser.cpp, missile.h, missile.cpp, weapon.h, weapon.cpp,main.cpp.
In: Computer Science
In: Computer Science
This is an assignment done using the terminal of linux.
In this assignment, you will
• use make to modify a c++ program and
• gdb a debugging tool.
Part 1
From the course website (or the departmental dropbox) download the program source files for the project myname.
Part 2: myname program (5 points)
1. Using your favorite text editor, modify the source code to print out your name instead of mine when the binary file is executed. Hint: YOU ARE NOT ”THOMAS THE TANK ENGINE”
2. Modify the makefile to include a rule that creates a backup of the source files, makefile, and readme in an archive directory in your home directory structure.
Submit a compressed, archived tar file [yourUserID].assignment4_1.tar.[Z,gz] with your modified source code.
3. Use the gdb debugger to step through the program. Check to ensure the Makefile is modified to allow for debugging. Submit a text file [yourUserID].assignment4_2.txt containing the gdb output for the following sequence of commands:
gdb myname
start
step [issue this command until you get the “program exited normally” message]
quit
Submission This time, there should be two files that you are uploading
[yourUserID].assingment4_1.tar.[Z,gz] and [yourUserID].assingment4_2.txt
• When you have finished, submit the files using the
departmental dropbox.
Here are the contents of CSCE215 directory that contains the program and files associated with it:
main.cpp
#include <iostream>
#include <string>
using namespace std;
#include "name.h"
int main () {
name myName;
myName.SetLast(LAST);
myName.SetMiddle(MI);
myName.SetFirst(FIRST);
cout <<"My name
is: ";
myName.PrintFirst();
myName.PrintMiddle();
myName.PrintLast();
return 0;
}
Makefile
# makefile to build a program
# program depends on components: name and main
myname: main.o name.o
g++ -g main.o name.o -o myname
# name.cpp has it's own header file
name.o: name.cpp
name.h
g++ -c -g name.cpp
# main.cpp also uses the header file name.h
main.o:
main.cpp name.h
g++ -c -g main.cpp
clean:
/bin/rm -f myname *.o
name.cpp
#include <iostream>
#include <string>
using namespace std;
#include "name.h"
void name::GetFirst(string str) {
str=first;
}
void name::SetFirst(string str) {
first=str;
}
void name::GetMiddle(string str) {
str=middle;
}
void name::SetMiddle(string str) {
middle=str;
}
void name::GetLast(string str) {
str=last;
}
void name::SetLast(string str) {
last=str;
}
void name::PrintLast() {
cout << last << "\n";
}
void name::PrintMiddle() {
cout <<
middle;
}
void name::PrintFirst() {
cout <<
first;
}
name.h
#define LAST "tankengine"
#define MI "the "
#define FIRST "thomas "
class name {
private:
string first;
string middle;
string last;
public:
void SetFirst(string str);
void GetFirst(string str);
void SetMiddle(string str);
void GetMiddle(string str);
void SetLast(string str);
void GetLast(string str);
void PrintLast();
void PrintMiddle();
void PrintFirst();
};
readme
/*
Copyright: 2005, All rights reserved.
Program: myname
Version: 1.1
Created: 9/6/05
Revised: 1/22/09
Files: name.cpp, name.h, main.cpp, Makefile
Programmer: Patrick O'Keefe who gratefully acknowledges Dr. Jason
Bakos's kind assistance.
Course: CSCE-215
Assignment: Class Project
Compiler: GNU Gcc version 4.2.3
Target: Linux
Description:
This program attempts string assigment. and other stuff....
Revisions:
There have been no major revisions of this program.
Constants and Variables:
See code for constant and variable descriptions.
or
you could put that kind of info here. Like:
FIRST -> your first name
MIDDLE -> ditto
LAST -> and ditto.
ok here is a change.
ALL OF THOSE FILES ARE LOCATED IN A DIRECTORY /CSCE215
In: Computer Science
a. What construct did you use? Insert the snip of your SQL code here:
b. Display the contents of the score table for event 5. Be sure student 12 is displayed. Insert your snip here:
*************************************************************
DATABASE
************************************************************
#---Create and open the database
drop database if exists Class;
CREATE DATABASE Class;
#-- Using the database
USE Class;
# create student table
DROP TABLE IF EXISTS student;
CREATE TABLE student
(
name VARCHAR(20) NOT NULL,
gender ENUM('F','M') NOT NULL,
student_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (student_id)
);
# create grade event table
DROP TABLE IF EXISTS grade_event;
CREATE TABLE grade_event
(
date DATE NOT NULL,
category ENUM('T','Q') NOT NULL,
event_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
PRIMARY KEY (event_id)
);
# create score table
# The PRIMARY KEY comprises two columns to prevent any
combination
# of event_id/student_id from appearing more than once.
DROP TABLE IF EXISTS score;
CREATE TABLE score
(
student_id INT UNSIGNED NOT NULL,
event_id INT UNSIGNED NOT NULL,
score INT NOT NULL,
PRIMARY KEY (event_id, student_id),
INDEX (student_id),
FOREIGN KEY (event_id) REFERENCES grade_event (event_id),
FOREIGN KEY (student_id) REFERENCES student (student_id)
);
# create absence table
DROP TABLE IF EXISTS absence;
CREATE TABLE absence
(
student_id INT UNSIGNED NOT NULL,
date DATE NOT NULL,
PRIMARY KEY (student_id, date),
FOREIGN KEY (student_id) REFERENCES student (student_id)
);
#--Populate the student table
INSERT INTO student VALUES ('Megan','F',NULL);
INSERT INTO student VALUES ('Joseph','M',NULL);
INSERT INTO student VALUES ('Kyle','M',NULL);
INSERT INTO student VALUES ('Katie','F',NULL);
INSERT INTO student VALUES ('Abby','F',NULL);
INSERT INTO student VALUES ('Nathan','M',NULL);
INSERT INTO student VALUES ('Liesl','F',NULL);
INSERT INTO student VALUES ('Ian','M',NULL);
INSERT INTO student VALUES ('Colin','M',NULL);
INSERT INTO student VALUES ('Peter','M',NULL);
INSERT INTO student VALUES ('Michael','M',NULL);
INSERT INTO student VALUES ('Thomas','M',NULL);
INSERT INTO student VALUES ('Devri','F',NULL);
INSERT INTO student VALUES ('Ben','M',NULL);
INSERT INTO student VALUES ('Aubrey','F',NULL);
INSERT INTO student VALUES ('Rebecca','F',NULL);
INSERT INTO student VALUES ('Will','M',NULL);
INSERT INTO student VALUES ('Max','M',NULL);
INSERT INTO student VALUES ('Rianne','F',NULL);
INSERT INTO student VALUES ('Avery','F',NULL);
INSERT INTO student VALUES ('Lauren','F',NULL);
INSERT INTO student VALUES ('Becca','F',NULL);
INSERT INTO student VALUES ('Gregory','M',NULL);
INSERT INTO student VALUES ('Sarah','F',NULL);
INSERT INTO student VALUES ('Robbie','M',NULL);
INSERT INTO student VALUES ('Keaton','M',NULL);
INSERT INTO student VALUES ('Carter','M',NULL);
INSERT INTO student VALUES ('Teddy','M',NULL);
INSERT INTO student VALUES ('Gabrielle','F',NULL);
INSERT INTO student VALUES ('Grace','F',NULL);
INSERT INTO student VALUES ('Emily','F',NULL);
INSERT INTO student VALUES ('Rachel','F',NULL);
#--Populate grade event table
INSERT INTO grade_event VALUES('2015-09-03', 'Q', NULL);
INSERT INTO grade_event VALUES('
2015-09-06', 'Q', NULL);
INSERT INTO grade_event VALUES('
2015-09-09', 'T', NULL);
INSERT INTO grade_event VALUES('
2015-09-16', 'Q', NULL);
INSERT INTO grade_event VALUES(
'2015-09-23', 'Q', NULL);
INSERT INTO grade_event VALUES('
2015-10-01', 'T', NULL);
#--Populate the score table
INSERT INTO score VALUES (1,1,20);
INSERT INTO score VALUES (3,1,20);
INSERT INTO score VALUES (4,1,18);
INSERT INTO score VALUES (5,1,13);
INSERT INTO score VALUES (6,1,18);
INSERT INTO score VALUES (7,1,14);
INSERT INTO score VALUES (8,1,14);
INSERT INTO score VALUES (9,1,11);
INSERT INTO score VALUES (10,1,19);
INSERT INTO score VALUES (11,1,18);
INSERT INTO score VALUES (12,1,19);
INSERT INTO score VALUES (14,1,11);
INSERT INTO score VALUES (15,1,20);
INSERT INTO score VALUES (16,1,18);
INSERT INTO score VALUES (17,1,9);
INSERT INTO score VALUES (18,1,20);
INSERT INTO score VALUES (19,1,9);
INSERT INTO score VALUES (20,1,9);
INSERT INTO score VALUES (21,1,13);
INSERT INTO score VALUES (22,1,13);
INSERT INTO score VALUES (23,1,16);
INSERT INTO score VALUES (24,1,11);
INSERT INTO score VALUES (25,1,19);
INSERT INTO score VALUES (26,1,10);
INSERT INTO score VALUES (27,1,15);
INSERT INTO score VALUES (28,1,15);
INSERT INTO score VALUES (29,1,19);
INSERT INTO score VALUES (30,1,17);
INSERT INTO score VALUES (31,1,11);
INSERT INTO score VALUES (1,2,17);
INSERT INTO score VALUES (2,2,8);
INSERT INTO score VALUES (3,2,13);
INSERT INTO score VALUES (4,2,13);
INSERT INTO score VALUES (5,2,17);
INSERT INTO score VALUES (6,2,13);
INSERT INTO score VALUES (7,2,17);
INSERT INTO score VALUES (8,2,8);
INSERT INTO score VALUES (9,2,19);
INSERT INTO score VALUES (10,2,18);
INSERT INTO score VALUES (11,2,15);
INSERT INTO score VALUES (12,2,19);
INSERT INTO score VALUES (13,2,18);
INSERT INTO score VALUES (14,2,18);
INSERT INTO score VALUES (15,2,16);
INSERT INTO score VALUES (16,2,9);
INSERT INTO score VALUES (17,2,13);
INSERT INTO score VALUES (18,2,9);
INSERT INTO score VALUES (19,2,11);
INSERT INTO score VALUES (21,2,12);
INSERT INTO score VALUES (22,2,10);
INSERT INTO score VALUES (23,2,17);
INSERT INTO score VALUES (24,2,19);
INSERT INTO score VALUES (25,2,10);
INSERT INTO score VALUES (26,2,18);
INSERT INTO score VALUES (27,2,8);
INSERT INTO score VALUES (28,2,13);
INSERT INTO score VALUES (29,2,16);
INSERT INTO score VALUES (30,2,12);
INSERT INTO score VALUES (31,2,19);
INSERT INTO score VALUES (1,3,88);
INSERT INTO score VALUES (2,3,84);
INSERT INTO score VALUES (3,3,69);
INSERT INTO score VALUES (4,3,71);
INSERT INTO score VALUES (5,3,97);
INSERT INTO score VALUES (6,3,83);
INSERT INTO score VALUES (7,3,88);
INSERT INTO score VALUES (8,3,75);
INSERT INTO score VALUES (9,3,83);
INSERT INTO score VALUES (10,3,72);
INSERT INTO score VALUES (11,3,74);
INSERT INTO score VALUES (12,3,77);
INSERT INTO score VALUES (13,3,67);
INSERT INTO score VALUES (14,3,68);
INSERT INTO score VALUES (15,3,75);
INSERT INTO score VALUES (16,3,60);
INSERT INTO score VALUES (17,3,79);
INSERT INTO score VALUES (18,3,96);
INSERT INTO score VALUES (19,3,79);
INSERT INTO score VALUES (20,3,76);
INSERT INTO score VALUES (21,3,91);
INSERT INTO score VALUES (22,3,81);
INSERT INTO score VALUES (23,3,81);
INSERT INTO score VALUES (24,3,62);
INSERT INTO score VALUES (25,3,79);
INSERT INTO score VALUES (26,3,86);
INSERT INTO score VALUES (27,3,90);
INSERT INTO score VALUES (28,3,68);
INSERT INTO score VALUES (29,3,66);
INSERT INTO score VALUES (30,3,79);
INSERT INTO score VALUES (31,3,81);
INSERT INTO score VALUES (2,4,7);
INSERT INTO score VALUES (3,4,17);
INSERT INTO score VALUES (4,4,16);
INSERT INTO score VALUES (5,4,20);
INSERT INTO score VALUES (6,4,9);
INSERT INTO score VALUES (7,4,19);
INSERT INTO score VALUES (8,4,12);
INSERT INTO score VALUES (9,4,17);
INSERT INTO score VALUES (10,4,12);
INSERT INTO score VALUES (11,4,16);
INSERT INTO score VALUES (12,4,13);
INSERT INTO score VALUES (13,4,8);
INSERT INTO score VALUES (14,4,11);
INSERT INTO score VALUES (15,4,10);
INSERT INTO score VALUES (16,4,20);
INSERT INTO score VALUES (18,4,11);
INSERT INTO score VALUES (19,4,15);
INSERT INTO score VALUES (20,4,17);
INSERT INTO score VALUES (21,4,13);
INSERT INTO score VALUES (22,4,20);
INSERT INTO score VALUES (23,4,13);
INSERT INTO score VALUES (24,4,12);
INSERT INTO score VALUES (25,4,10);
INSERT INTO score VALUES (26,4,15);
INSERT INTO score VALUES (28,4,17);
INSERT INTO score VALUES (30,4,11);
INSERT INTO score VALUES (31,4,19);
INSERT INTO score VALUES (1,5,15);
INSERT INTO score VALUES (2,5,12);
INSERT INTO score VALUES (3,5,11);
INSERT INTO score VALUES (5,5,13);
INSERT INTO score VALUES (6,5,18);
INSERT INTO score VALUES (7,5,14);
INSERT INTO score VALUES (8,5,18);
INSERT INTO score VALUES (9,5,13);
INSERT INTO score VALUES (10,5,14);
INSERT INTO score VALUES (11,5,18);
INSERT INTO score VALUES (12,5,8);
INSERT INTO score VALUES (13,5,8);
INSERT INTO score VALUES (14,5,16);
INSERT INTO score VALUES (15,5,13);
INSERT INTO score VALUES (16,5,15);
INSERT INTO score VALUES (17,5,11);
INSERT INTO score VALUES (18,5,18);
INSERT INTO score VALUES (19,5,18);
INSERT INTO score VALUES (20,5,14);
INSERT INTO score VALUES (21,5,17);
INSERT INTO score VALUES (22,5,17);
INSERT INTO score VALUES (23,5,15);
INSERT INTO score VALUES (25,5,14);
INSERT INTO score VALUES (26,5,8);
INSERT INTO score VALUES (28,5,20);
INSERT INTO score VALUES (29,5,16);
INSERT INTO score VALUES (31,5,9);
INSERT INTO score VALUES (1,6,100);
INSERT INTO score VALUES (2,6,91);
INSERT INTO score VALUES (3,6,94);
INSERT INTO score VALUES (4,6,74);
INSERT INTO score VALUES (5,6,97);
INSERT INTO score VALUES (6,6,89);
INSERT INTO score VALUES (7,6,76);
INSERT INTO score VALUES (8,6,65);
INSERT INTO score VALUES (9,6,73);
INSERT INTO score VALUES (10,6,63);
INSERT INTO score VALUES (11,6,98);
INSERT INTO score VALUES (12,6,75);
INSERT INTO score VALUES (14,6,77);
INSERT INTO score VALUES (15,6,62);
INSERT INTO score VALUES (16,6,98);
INSERT INTO score VALUES (17,6,94);
INSERT INTO score VALUES (18,6,94);
INSERT INTO score VALUES (19,6,74);
INSERT INTO score VALUES (20,6,62);
INSERT INTO score VALUES (21,6,73);
INSERT INTO score VALUES (22,6,95);
INSERT INTO score VALUES (24,6,68);
INSERT INTO score VALUES (25,6,85);
INSERT INTO score VALUES (26,6,91);
INSERT INTO score VALUES (27,6,70);
INSERT INTO score VALUES (28,6,77);
INSERT INTO score VALUES (29,6,66);
INSERT INTO score VALUES (30,6,68);
INSERT INTO score VALUES (31,6,76);
#--Populate the absence table
INSERT INTO `absence` VALUES (3,'2015-09-03');
INSERT INTO `absence` VALUES (5,'2015-09-03');
INSERT INTO `absence` VALUES (10,'2015-09-06');
INSERT INTO `absence` VALUES (10,'2015-09-09');
INSERT INTO `absence` VALUES (17,'2015-09-07');
INSERT INTO `absence` VALUES (20,'2015-09-07');
INSERT INTO `absence` VALUES (22,'2015-09-15');
In: Computer Science
Suppose that an initially empty queue performs the following operations. enqueue(7), enqueue(3), dequeue(), front(), enqueue(8), enqueue(5), front(), enqueue(4), dequeue(), enqueue(0), dequeue(), dequeue() List, in order, the values that are returned. Give your answer as a single multi-digit number, where each digit represents a single returned value. For example, if the operations returned 3, 1, 4, 1, 5, 9, and 2, in that order, then the answer would be 3141592. (The format 3,141,592 would also be fine.)
In: Computer Science
Write a program
that manages a list of patients for a medical office. Patients should be
represented as objects with the following data members:
•
name (string)
•
patient id # (string)
•
address (string)
•
height (integer; measured in inches)
•
weight (double)
•
date of birth (Date)
•
date of initial visit (Date)
•
date of last visit (Date)
The data member “patient id #” is defined to be a
key
. That is, no two patients can have
the same patient id #. In addition to the standard set of accessors for the above data
members, define the fol
lowing methods for class Patient.
•
standard set of accessors
•
get_age
method: to compute and returns a patient’s age in years (integer)
•
get_time_as_patient
method: to compute the number of years (integer) since
the patient’s initial visit. Note that this va
lue can be 0.
•
get_time_since_last_visit
method:
to compute the number of years (integer)
since the patient’s last visit. This value can be 0, too.
Your program will create a list of patient objects and provide the user with a menu of
choices for accessing
and manipulating the
data on that list. The list must be an object of
the class List that you will define.
Internally, the list object must maintain its list as a
singly linked list with two references, one for head and one for tail.
As usual, your Li
st
class will have the methods “
find,” “
size,” “contains
,” “remove,”
“add,”, “get,”
“getNext,”, “reset,” “toString
,”. At the start, your program should read in patient data
from a text file for an initial set of patients for the list. The name of this file
should be
included on the “command line” when the program is run.
(Don’t hard code
the file name)
Each data item for a patient will appear on a separate line in
the file.
Your program
should be menu-
driven, meaning that it will display a menu of options for the user. The
user will choose one of
these options, and your program will carry out the request. The
program will then display the same menu again and get another
choice from the user.
This interaction will go on until the user chooses QUIT, which should be the last of the
menu’s options. The
menu should look something like the following:
1.
Display list
2.
Add a new patient
3.
Show information for a patient
4.
Delete a patient
5.
Show average patient age
6.
Show information for the youngest patient
7.
Show notification l
ist
8.
Quit
Enter your choice:
Details of each option:
•
Option 1: Display (on the screen) the names and patient id #’s of all patients in
order starting from the first one. Display the
information for one patient per line;
something like: Susan
Smith, 017629
•
Option
2: Add a new patient to the
END
of the list.
All
information about the new
patient (including name, patient id #, etc.)
is to be requested (input) from the user
interactively. That is, you will need to ask for 14 pieces of data from the user.
You’ll, of course, need to create a new patient object to hold this data.
NOTE:
As mentioned above, the patient id # field is a
key
. So, if the user types in
a patient id # that happens to be the same as
an already existing patient’s, then
you should display an error message and cancel the operation. Therefore, it is
probably a
good idea to ask for the patient id # first and test it immediately (by
scanning the objects on the list).
•
Option
3: Display (in a neat format) all the information pertaining to the patien
t
whose patient id # is given by the user. Namely, display the following information:
o
name
o
patient id #
o
address
o
height (shown in feet and inches; for example, 5 ft, 10 in)
o
weight
o
age
o
number of years as a patient (display “less than one year” if 0)
o
number of years since last visit (display “less than one year” if 0)
o
Indication that patient is overdue for a visit
NOTE:
The last item is displayed only if it has been 3 or more years since
the patient’s last visit.
If the user inputs a patient id
# that does
not
exist, then the program should
display an error message and the operation should be canceled (with the menu
immediately being displayed again for another request).
•
Option
4: Delete the patient whose id # is given by the user. If the patient is not
on the
list, display an error message.
•
Option 5: Show the average age (to one decimal place) of the patients.
•
Option
6:
Display (in a neat format) all the information (same as operation 3)
about the youngest patient.
•
Option
7: Display the names (and patient id
#’s) of all patients who are overdue
for a visit. As noted above, “overdue” is
defined as 3 or more years since the last
visit.
•
Option 8: Quit the program.
NOTE:
When the user chooses to quit, you should ask if they would like to save
the patient information to a file. If so, then
you should prompt for the name of an
output (text) file, and then write the data pertaining to
all
patients to that file. The
output for each patient should be in the same format as in the input file. In this
way, your output fil
e can be used as input on
another run of your program. Make
certain to maintain the order of the patients in the output file as they appear on the
list. Be
careful not to overwrite your original input file (or any other file, for that
matter).
Note
:
Try to
implement the various menu options as separate methods (aside
from
“main”)
.
However:
DO NOT DEFINE such “option methods
” as part of the class
List.
Of course, the Java code that implements an option (whether it’s in the “main”
method or not) should def
initely use List’s methods
to help do its job.
In: Computer Science
I am new to python, and i used python 3. i have to make a new program can anyone give tell mw how to do this.
A) Write a function with the name doubler. The function should take an integer parameter and return twice the value of the integer.
Test the function with the following code:
print(“Double of 6 is”,doubler(6))
The printout should be:
Double of 6 is 12
B) Write a function with the name scoreToLetter. The function should take an integer parameter and give out a letter grade according to the following grade table:
|
Score >=90 |
A |
|
80<=score<90 |
B |
|
70<=score< 80 |
C |
Test the function with the following code:
X = 85
Print (“Your grade is”,scoreToLetter(x))
This should print:
Your grade is B
C) Write a function ‘sumOfThrows’ that takes two parameters ‘throws’ and ‘sides’. ‘sides’ should have a default values of 6. The function should return the sum from doing however many random throws specified for a die with ‘sides’ number of sides.
Test the function.
For example sumOfThrows(1,6) should show the outcome of throwing one six-sided die.
sumOfThrows(3,8) should show the outcome of throwing three dice with sides numbered 1 through 8.
sumOfThrows(2) should show the outcome of throwing two six-sided dice.
D) Move all functions to a module with name myFunctions.py. Import the myFunctions module and test all functions.
E) Submit both myFunction.py and the file with your tests named tests.py
In: Computer Science
plot this data into a bar graph: PYTHON
data=pandas.read_csv(r'data/tv_shows.txt', low_memory=False)
print((data))
print((data.columns))
TV Shows : Rating 0 --------------------- 1 A Discovery of Witches : 100% 2 Barry : 100% 3 Unforgotten : 100% 4 Veep : 98% 5 Killing Eve : 97% 6 Billions : 96% 7 Les Misérables : 96% 8 Supergirl : 89% 9 Call the Midwife : 80% 10 Game of Thrones : 77% 11 Now Apocalypse : 77% 12 The Red Line : 69% 13 Lucifer : No Score Yet 14 Chernobyl : 95% 15 Dead to Me : 85% 16 Better Things : 100% 17 Brooklyn Nine-Nine : 100% 18 Tuca & Bertie : 100% 19 State of the Union : 100% 20 The Twilight Zone : 75% 21 Happy! : 100% Index(['TV Shows : Rating'], dtype='object')
In [9]:
display(data)
In: Computer Science
A bug collector collects bugs every day for one week (7 days). Write a program that asks the user for the total number of bugs they collected for each day and stores each number in a list. Use a loop to calculate the total number of bugs and display the result.
In: Computer Science
Design and implement a database for restaurant
At the end you will submit a report that has the following:
1-Describe the scenario of your database, what does it include, and what are the assumptions you have.
2-Draw an Entity-Relationship Diagram (ERD)
3-Write the schemas for 2 entities and 2 relationships
4- Compose two or three possible queries in written English and SQL that you can get from the database.
please l need the answer for this assignment.
In: Computer Science
Objective:
The purpose of this assignment is to:
Directions:
Write a C++ program that will create a menu driven program with the following options:
Menu Options:
A) Text to Morse code
B) Quit
If user selects A or a:
If user selects B or b:
Otherwise:
Make sure your program conforms to the following requirements:
1. This program should be called MorseCode.cpp
2. It must provide the functions defined above. You are required to use and define proper C++ functions, but for this program, you are allowed to define them (80 points).
3. Add comments wherever necessary. (5 points)
4. Run the program in linprog.cs.fsu.edu - select option A - redirect output to a file called OutputA.txt (include OutputA.txt in submission and Unix command executed) (5 points)
Sample Runs:
NOTE: not all possible runs are shown below.
Welcome to the Morse code program Menu Options: A) Text to Morse code B) Quit h Menu Options: A) Text to Morse code B) Quit a Enter a word and I will translate it to Morse code. -> sos ... --- ... Menu Options: A) Text to Morse code B) Quit A Enter a word and I will translate it to Morse code. -> ok --- -.- Menu Options: A) Text to Morse code B) Quit a Enter a word and I will translate it to Morse code. -> ?? Error : word contains symbols Menu Options: A) Text to Morse code B) Quit a Enter a word and I will translate it to Morse code. -> ok --- -.- Menu Options: A) Text to Morse code B) Quit B
General Requirements:
1) Include the header comment with your name and other information on the top of your files.
2. Please make sure that you're conforming to specifications (program name, print statements, expected inputs and outputs, etc.). Not doing so will result in a loss of points. This is especially important for prompts. They should match mine EXACTLY.
3. If we have listed a specification and allocated point for it, you will lose points if that particular item is missing from your code, even if it is trivial.
4. No global variables (variables outside of main()) unless they are constants.
5. All input and output must be done with streams, using the library iostream
6. You may only use the iostream, iomanip, vector, and string libraries. Including unnecessary libraries will result in a loss of points.
7. NO C style printing is permitted. (Aka, don't use printf). Use cout if you need to print to the screen.
8. When you write source code, it should be readable and well-documented (comments).
9. Make sure you either develop with or test with g++ (to be sure it reports no compile errors or warnings) before you submit the program.
In: Computer Science
Write a java program that calculates the total amount of money a person has made over the last year. The program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based on the total made. For this program, the federal tax will be 8.5% and the state tax will be 14.5%.
In: Computer Science
it is required implement 40-Gbps computer network to connect the four building (MB,CB,LB,NHB) in the faculty of engineering given .each building three teaching halls distributed in three floors and it is required to install an independent network with 24 outlet points in each halls six servers will be used to provide the required local storage for each building while a SAN storage and control room will be in communication building(CB).
a) design the required computer network, state the function of each device and specify the typyes of cables you will use and justify your selection
b) explain your solution in terms of network diameter ,bandwidth aggregation and redandant links
In: Computer Science
C language
write a code: Do you want another choice, if yes press (Y or y) then continue , if no press (N or n) then break.
In: Computer Science
Python
Write a script to play two-dimensional Tic-Tac-Toe between two human players who alternate entering their moves on the same computer.
Use a 3-by-3 two-dimensional array. Each player indicates their moves by entering a pair of numbers representing the row and column indices of the square in which they want to place their mark, either an 'X' or an 'O'. When the first player moves, place an 'X' in the specified square. When the second player moves, place an 'O' in the specified square. Each move must be to an empty square. After each move, determine whether the game has been won and whether it’s a draw.
In: Computer Science