In: Computer Science
So currently I am working on some SQL with python which is linked to my database and I am stuck on a split problem. So in the program it connects to the database and then next you input either list, add, update, remove or allocate. So lets say I want to add a new data into the database you just need to write: update -name='Ava - #2' -class=2.
After you type this there is a variable called val which does the strip and split.
So as of right now what I have done is:
val = input('> ').strip().lower()
parts = val.split(' ')
print(parts)
So if I input the following: update -name="Nile Adam" -class=2
I expect the following output: ['update', '-name="Nile Adam"', '-class=2']
However the output I get is: ['update', '-name="Nile', 'Adam"', '-class=2']
In: Computer Science
Draw a flow chart for a program that will get the name and final exam results for all FBTOO15 students (474); and calculate the total scores for all students. After all results were entered, the average results would be calculated and displayed on screen.
In: Computer Science
In: Computer Science
C++ Program : You are working as a programmer designing a space ship weapon system for the newly
forced Space Force. The weapon system is a generic weapon housing that can t a number
of dierent weapons that are all controlled by a ship pilot in the same way. Most im-
portantly, is the emphasis on safety. During combat, the weapon systems cannot become
unreliable or fail lest the pilots be put in unnecessary danger. Therefore you will need to
provide mechanisms to combat this.
2.2.1 weaponMount
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 dened as follows:
weaponMount
-weapons:weapon **
-numWeapons: int
---------------------------
+weaponMount(numWeapons:int, weaponList: string *)
+~weaponMount()
+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 dened in the hierarchy.
numWeapons: The number of weapons that are mounted into the system.
The class methods are as follows:
weaponMount: This is the constructor. It will receive a list of weapons 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. For example ["Doom
Cannon","Ion Cannon"] means create a doomCannon weapon at index 0 and so on.
The default strength for an ion cannon is 5.
weaponMount: 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.2.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 specically 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 weaponMount class as a struct with
public access. You will need to research how to specify exceptions due to the potential
for a "loose throw specier error" and what clashes this might have with a compiler.
Remember that implementations of classes and structs must be done in .cpp les.
2.2.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 specically 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 specier error" and what clashes this might have with a compiler.
Remember that implementations of classes and structs must be done in .cpp les.
2.2.4 Weapon Parent Class
This is the parent class of ionCannon and doomCannon. Both of these classes inherit
publicly from it. It is dened according to the following UML diagram:
weapon
-ammo:int
-type:string
-------------------
+weapon()
+weapon(a:int, t:string)
+getAmmo():int
+getType():string
+setAmmo(s:int):void
+setType(s:string):void
+weapon()
+fire()=0:string
The class variables are as follows:
ammo: The amount of ammo stored in the weapon. As it is red, this will deplete.
type: The type of the weapon as a string. Examples include: "Rail Ri
Cannon","Doom Cannon", "Missile Launcher" and "Ion Cannon".
The class methods are as follows:
weapon: The default class constructor.
weapon(a:int, t:string): The constructor. It will take two arguments and instantiate
the class variables accordingly.
getAmmo,setAmmo: The getter and setter for the ammo.
getType,setType: The getter and setter for the ammo.
weapon: The destructor for the class. It is virtual.
fire: This is the method that will re each of the weapons and produce a string of
the outcome. It is pure virtual here.
2.2.5 ionCannon
The ionCannon is dened as follows:
ionCannon
-strength:int
------------------------------
+ionCannon(s:int)
+~ionCannon()
+setStrength(s:int):void
+getStrength() const:int
+fire():string
The class variables are as follows:
strength: The strength of the ion cannon. Ion cannons get stronger the longer they
are red.
The class methods are as follows:
ionCannon: The class constructor. This receives an initial strength for the ion
cannon.
ionCannon: This is the destructor for the ion cannon. It prints out "Ion Cannon
Uninstalled!" without the quotation marks and a new line at the end when the class
is deallocated.
fire: If the cannon still has ammo, it must decrease the ammo by 1. It will also
increase the strength by 1. It will return the following string: "Ion Cannon red at
strength: X" where X represents the strength before ring. Do not add quotation
marks. If ammo is not available, instead throw the ammoOut exception. No new
lines should be added.
getStrength/setStrength: The getter and setter for the strength variable.
2.2.6 doomCannon
The doomCannon is dened as follows:
doomCannon
-charge:int
------------------------------
+doomCannon()
+~doomCannon()
+getCharge():int
+setCharge(s:int):void
+fire():string
The class methods are as follows:
doomCannon: This is the constructor for the class. It will set the charge to 0.
doomCannon: This is the destructor for the ion cannon. It prints out "Doom
Cannon Uninstalled!" without the quotation marks and a new line at the end when
the class is deallocated.
setCharge/getCharge: The getter and setter for the charge variable.
re: The cannon can only re if it has ammo and only charge if it has ammo as
well. The charging process does not require ammo. Firing it will reduce the ammo
by 1. However the doom cannon requires a charging up period. Since the doom
cannon starts with 0 charge, it will not re until it reaches 5 charge, inclusive of the
5. Therefore every time it is red, it will increase in charge by 1. If the charge is not
at 5, then return the string "DOOM CANNON CHARGING" without quotation
marks. If the cannon starts at 5 charge when red reset the charge back to 0 and
return the following string: "DOOM CANNON FIRED!". Do not add quotation
marks. If ammo is not available, instead throw the ammoOut exception. No new
lines should be added.
You will be allowed to use the following libraries: sstream,exception, cstring,string,
iostream. Your submission must contain weaponMount.h, weaponMount.cpp, ionCannon.h, ionCannon.cpp, doom-
Cannon.h, doomCannon.cpp,weapon.h, weapon.cpp, main.cpp
In: Computer Science
Respond to the following in a minimum of 175 words:
Vulnerabilities can exist in both a business' software and hardware.
Discuss the differences between software and hardware vulnerabilities. How might these vulnerabilities impact a business
In: Computer Science
Recall the Kung and Robinson optimistic concurrency control algorithm. How can you modify that algorithm to ensure that every transaction eventually completes?
In: Computer Science
All program should be in C
Write its pseudocode and draw its flowchart) to prompt the user to input the variables to solve the following problem:
X2 + X×Y/Z - W*V3
Note 1: You should ask the user to input 5 numbers to be able to do this calculation.
Note 2: You can use multiplication instead of power if you do not want to use it (as we have not officially covered it).
Write a program (compile and run), pseudocode, and draw a flowchart for each of the following problems:
a) Obtain three numbers from the keyboard, compute their product, and display the result.
Ans:
b) Obtain two numbers from the keyboard, and determine and display which (if either) is the smaller of the two numbers.
Ans:
c) Obtain a series of positive numbers from the keyboard, and determine and display their average (with 4 decimal points). Assume that the user types the sentinel value -1 to indicate "end of data entry."
Ans:
In: Computer Science
1D Array Function
Write a function in MATLAB to convert miles to feet. This function should work for one number, or an array of numbers to be converted.
In: Computer Science
For the following operations: write the operands as 2's
complement binary numbers then perform the addition or subtraction
operation shown. Show all work in binary operating on 8-bit
numbers.
7 + 3
7 - 3
3 - 7
In: Computer Science
You're a statistics professor and the deadline for submitting your students' grades is tonight at midnight. Each student's grade is determined by their mean score across all of the tests they took this semester.
(The mean is the average of the numbers. It is easy to calculate: add up all the numbers, then divide by how many numbers there are)
You've decided to automate grade calculation by writing a Python program that takes a list of test scores and prints a one character string representing the student's grade calculated as follows:
90% <= mean score <= 100%: "A",
80% <= mean score < 90%: "B",
70% <= mean score < 80%: "C",
60% <= mean score < 70%: "D",
mean score < 60%: "F"
For example, if list1 = [92, 94, 99], it would print "A" since the mean score is 95, and if list1 = [50, 60, 70, 80, 90], it would return "C" since the mean score is 70.
In: Computer Science
Write a java program with 3 recursive methods that reverse the order of a string. The first recursive method should reverse the order starting from the left selecting the leftmost character as the head and the remaining part of the string as its tail., the second starting from the right selecting the rightmost character as the head and the remaining part of the string on its left as the tail, and the last a recursive method starting from the middle by extract two characters simultaneously from both left and right.
In: Computer Science
Show that the multi-version read consistency algorithm ensures serializability. That is, read-only transactions use the multi-version technique whereas read-write transactions use strict two phase locking.
In: Computer Science
Consider a nuclear reactor whose temperature is monitored by three sensors. An alarm should go off if any two of the sensor readings disagree by more than 5°F. Write a program that would print a string ‘ALARM’ if any two temperate readings disagree by strictly more than 5°F and ‘NORMAL’ otherwise
Ask for each temperature input and display the state
Use MATLAB
In: Computer Science
Java Programming Project 6: File I/O
Purpose: To practice reading from as well as writing to text files with the help of Scanner class methods, and PrintStream class methods. You will also learn to implement some simple Exception Handling.
Carefully examine and follow ALL the program specifications.
Take a look at the PPT slides for Chapter 7 File I/O for examples that will help with this program.
Hotel Expense Recording Keeping:
A hotel bookkeeper enters client hotel expenses in a text file. Each line contains the following, separated by semicolons: client name, service sold (i.e., Dinner, Conference, Lodging, etc.), the sales amount, and the date.
Attached (and below) is an example input file that your program will be tested with, so you will need to make sure that you program will run correctly using this file. Since this may be your first experience reading from an input file, you will likely find it easiest if you store the input file in the same folder with your Java program file so that they can easily communicate with one another. The easiest way to store this file is as a plain text file in Notepad (do not use MS word or any other sophisticated word processor or you will be processing embedded text commands, which is not at all recommended). Here is what the input file looks like:
Jason Inouye;Conference;250.00;11/10/2016
Jason Inouye;Lodging;78.95;11/10/2016
Mary Ryan;Dinner;16.95;11/10/2016
Mark Twain;Dinner;25.50;11/10/2016
Mark Twain;Spa;50.00;11/10/2016
Steven Hawking;Conference;250.00;11/10/2016
Steven Hawking;Room Service;45.00;11/11/2016
Steven Hawking;Lodging;78.95;11/11/2016
Ayrton Senna;Room Service;23.20;11/10/2016
Ayton Senna;Dinner;22.50;11/10/2016
Ayton Senna;Lodging;78.95;11/10/2016
One feature of the input file, is that it uses a semicolon (;) to delimit the tokens on each line of input, rather than whitespace. You will need to use a delimiter statement after you construct your line scanner object.
To see how to construct a line scanner object, go to Chapter 7 PowerPoint slide in the Week 13 folder. So for example, if you create an object called lineScan of type Scanner to process tokens on a given line of input, then you could call the useDelimiter method on your lineScan object, as follows:
lineScan.useDelimiter(";");
This will allow you to tokenize each input line based, not on white space delimiters, but using the semicolon as a delimiter instead.
This is what should be in your Output file after you run your program (this file will most likely be located in the same folder as your Java program).
Dinner expenses : 64.95
Lodging expenses : 236.85
Conference expenses : 500.00
Room Service expenses : 68.20
Spa expenses : 50.00
Submission Requirements:
In: Computer Science