I'm trying to convert between different number representations in C++ , I have the prototype but im not sure what do do from here
bool convertF(double & x, const string & bits);
bits is supposed to be an 8-bit (not 5-bit) value, each char being '0' or '1'; if not, return
false. The first bit of bits represents the sign bit, the next 3 bits represent the exponent,
and the next 4 bits represent the significand.
convertF may assume without checking that the 3 exponent bits are not all the same.
convertF's job is to set x to the floating-point number that bits represents and return
true.
For example, convertF(x, "101011000") should set x to -7/8 == -0.875
In: Computer Science
# ArrayStack # TODO: push and pop using array stack with doubling technique. import numpy as np from future import print_function # Definisi class ArrayStack class ArrayStack(object): def __init__(self): self.data = np.zeros(20, dtype=np.int) self.count = 0 def isEmpty(self): pass # ubah saya def size(self): pass # ubah saya def push(self, obj): pass # ubah saya def pop(self): pass # ubah saya #-------------------------- # End of class if __name__ == "__main__": stack = ArrayStack() randn = np.random.permutation(1000) for i in range(1000): stack.push(randn[i]) #### for i in range(100): print(stack.pop()) ####
In: Computer Science
Java
Create an abstract Product Class
Add the following private attributes:
name
sku (int)
price (double)
Create getter/setter methods for all attributes
Create a constructor that takes in all attributes and sets them
Remove the default constructor
Override the toString() method and return a String that represents
the building object that is formatted
nicely and contains all information (attributes)
Create a FoodProduct Class that extends Product
Add the following private attributes:
expDate (java.util.Date) for expiration date
refrigerationTemp (int) if 70 or above, none necessary, otherwise it will be a lower number
servingSize (int) in grams
caloriesPerServing (int)
allergens (ArrayList<String>)
Create getter/setter methods for all attributes
Create a constructor that takes in all attributes for product and food product. Call the super constructor and then set the expDate, refrigerationTemp, servingSize, caloriesPerServing and allergens.
Remove the default constructor
Override the toString() method and return a String that represents the food product object that is formatted nicely and contains all information (super toString and the private attributes)
Create a CleaningProduct Class that extends Product
Add the following private attributes:
String chemicalName
String hazards
String precautions
String firstAid
ArrayList<String> uses (e.g. kitchen, bath, laundry, etc)
Create getter/setter methods for all attributes
Create a constructor that takes in all attributes for product and food product. Call the super constructor and then set the chemical name, hazard, precautions, firstAid and uses. TIP: try generating the constructor, it will add the super stuff for you. (Also, see Lynda inheritance videos.)
Remove the default constructor
Override the toString() method and return a String that represents the cleaning product object that is formatted nicely and contains all information (super toString() and the private attributes)
Create the interface Edible which contains the following method signatures:
public Date getExpDate();
public void setRefrigerationTemp(Int refrigerationTemp)
public int getRefrigerationTemp();
public void setExpDate(Date expDate) ;
public int getServingSize() ;
public void setServingSize(int servingSize) ;
public int getCaloriesPerServing() ;
public void setCaloriesPerServing(int caloriesPerServing);
public String getAllergens() ;
public void setAllergens(ArrayList<String> allergens) ;
Create the interface Chemical which contains the following method signatures
public String getChemicalName();
public void setChemicalName(String chemicalName) ;
public String getHazards() ;
public void setHazards(String hazards);
public String getPrecautions() ;
public void setPrecautions(String precautions) ;
public ArrayList<String> getUses() ;
public void setUses(ArrayList<String> uses) ;
public String getFirstAid() ;
public void setFirstAid(String firstAid) ;
Modify the FoodProduct Class to implement Edible, be sure to add the @Override before any methods that were there (get/set methods) that are also in the Edible interface.
Modify the CleaningProduct Class to implement Chemical, be sure to add the @Override before any methods that were there (get/set methods) that are also in the Chemical interface.
Create your main/test class to read products from a file, instantiate them, load them into an ArrayList and then print them nicely to the console at the end of your program. See instructor note about reading the file as the lengths of the lines may be different depending on the list of allergens. It is also comma delimited rather than by spaces. You will have to read an entire line, split its contents and then store the information into variables. The last element(s) are the allergens that you will have to store to an ArrayList.
2 note files:
Frosted Mini Wheats,233345667,4.99,10/2020,70,54,190,Wheat Ingredients Activa YoCrunch Yogurt,33445654,2.50,10/2018,35,113,90,Dairy,Peanuts
Lysol,2344454,4.99,Alkyl (50%C14 40%C12 10%C16) dimethyl benzyl
ammonium saccharinate,Hazard to humans and domestic animals.
Contents under pressure,Causes eye irritation,In case of eye
contact immediately flush eyes thoroughly with water, kitchen,
bath
Windex,4456765,3.99,Sodium citrate (Trisodium citrate),To avoid
electrical shock do not spray at or near electric lines,Undiluted
product is an eye irritant, if contact with eye occurs flush
immediately with plenty of water for at least 15 to 20 minutes,
glass, upholstery, clothing
In: Computer Science
#define _CRT_SECURE_NO_WARNINGS
// Put your code below:
#include <stdio.h>
int main(void)
{
int day, hightemp[10], lowtemp[10], numbers, highesttemp,
highestday, lowesttemp, lowestday, numbers2 = 0, hightotal = 0,
lowtotal = 0, averageday = 0, numbers3;
double averagetemp;
printf("---=== IPC Temperature Calculator V2.0 ===---");
printf("\nPlease enter the number of days, between 3 and 10,
inclusive: ");
scanf("%d", &numbers);
if (numbers < 3 || numbers > 10)
{
printf("\nInvalid entry, please enter a number between 3 and 10,
inclusive: ");
scanf("%d", &numbers);
printf("\n");
}
while (numbers < 3 || numbers > 10);
for (day = 1; day <= numbers; day++)
{
printf("Day %d - High: ", day);
scanf("%d", &hightemp[day - 1]);
printf("Day %d - Low: ", day);
scanf("%d", &lowtemp[day - 1]);
if(highesttemp <= highesttemp[day - 1])
{
highesttemp = highesttemp[day - 1];
highesttemp = day;
}
if (lowesttemp >= lowesttemp[day - 1])
{
lowesttemp = lowesttemp[day - 1];
lowesttemp = day;
}
}
printf("\nDay Hi Low\n");
for (day = 1; day <= numbers; day++)
{
printf("%d %d %d\n", day, hightemp[day - 1], lowtemp[day - 1]);
}
printf("\nThe highest temperature was %d, on day %d\n", highesttemp, highestday);
printf("The lowest temperature was %d, on day %d\n", lowesttemp, lowestday);
while (numbers2 == 0)
{
printf("\nEnter a number between 1 and 5 to see average temperature
for the entered number of days, enter a negative number to exit: ",
numbers);
scanf("%d", &numbers3);
if (numbers3 < 0)
{
numbers2 = 1;
}
else
{
while (numbers3 <= 0 || numbers3 > numbers)
{
printf("\nInvalid entry, please enter a number between 1 and %dm
inclusive: ", numbers);
scanf("%d", &numbers3);
}
hightotal = 0;
lowtotal = 0;
for (averageday = 1; averageday <= numbers3;
averageday++)
{
hightotal += hightemp[averageday - 1];
lowtotal += lowtemp[averageday - 1];
}
averagetemp = (double) (hightotal + lowtotal) / (numbers3 * 2);
printf("\nThe average temperature up to day %d is: %.2lf",
numbers3, averagetemp);
}
}
printf("\nGoodbye!");
return 0;
}
/////////////////////////////////////////////////////////////////////////
why is it not working?
In: Computer Science
SYSTEM REQUIREMENTS-
Each dog goes through a six- to ninemonth training regimen before they are put into service. Part of our process is to record and track several data points about the rescue animals.
Dogs are given the status of "intake" before training starts. Once in training, they move through a set of five rigorous phases: Phase I, Phase II, Phase III, Phase IV, and Phase V. While in training, a dog is given the status of its current training phase (e.g., "Phase I"). When a dog graduates from training, it is given the status of "in service" and is eligible for use by clients. If a dog does not successfully make it through training, it is given the status of "farm," indicating that it will live a life of leisure on a Grazioso Salvare farm.
The Animals Through years of experience, we have narrowed the list of dog breeds eligible for rescue training to the following:
• American pit bull terrier • Beagle • Belgian Malinois • Border collie • Bloodhound • Coonhound • English springer spaniel • German shepherd • German shorthaired pointer • Golden retriever • Labrador retriever • Nova Scotia duck tolling retriever • Rough collie • Smooth collie
When we acquire a dog, we record the breed, gender, age, weight, date, and the location where we obtained them. There is usually a short lag time between when we acquire a dog and when they start training, which we document as well. Additionally, we track graduation dates, dates dogs are placed into "service," and details about the dogs' in-service placement (agency, city, country, and name, email address, phone number, and mailing address for the agency's point of contact).
RESCUE ANIMAL CODE
import java.text.SimpleDateFormat;
public class RescueAnimal {
// Class variables
private String name;
private String type;
private String gender;
private int age;
private float weight;
private SimpleDateFormat acquisitionDate;
private SimpleDateFormat statusDate;
private String acquisitionSource;
private Boolean reserved;
private String trainingLocation;
private SimpleDateFormat trainingStart;
private SimpleDateFormat trainingEnd;
private String trainingStatus;
private String inServiceCountry;
private String inServiceCity;
private String inServiceAgency;
private String inServicePOC;
private String inServiceEmail;
private String inServicePhone;
private String inServicePostalAddress;
// Constructor
public RescueAnimal() {
}
// Add Accessor Methods here
// Add Mutator Methods here
}
In: Computer Science
Write a function sublist that takes two lists as arguments, and returns true if the first list appears as a contiguous sublist somewhere within the second list, and false otherwise.
> (sublist ’(c d e) ’(a b c d e f g))
#t
> (sublist ’(a c e) ’(a b c d e f g))
#f
Write a function lgrep that returns the “lines” within a list that contain a given sublist. Use the sublist function implemented in previous exercise to build lgrep.
> (lgrep ’(c d e) ’((a b c d e f g)
(c d c d e)
(a b c d)
(h i c d e k)
(x y z)))
((a b c d e f g) (c d c d e) (h i c d e k))
You may assume that all elements of (all lines of) all argument lists are atoms.
using the programming language scheme
i need the question to be answered using the programming language Scheme
In: Computer Science
Project Part 2: Gap Analysis Plan and Risk Assessment Methodology
Scenario
After the productive team meeting, Fullsoft’s chief technology officer (CTO) wants further analysis performed and a high-level plan created to mitigate future risks, threats, and vulnerabilities. As part of this request, you and your team members will create a plan for performing a gap analysis, and then research and select an appropriate risk assessment methodology to be used for future reviews of the Fullsoft IT environment.
An IT gap analysis may be a formal investigation or an informal survey of an organization's overall IT security. The first step of a gap analysis is to compose clear objectives and goals concerning an organization's IT security. For each objective or goal, the person performing the analysis must gather information about the environment, determine the present status, and identify what must be changed to achieve goals. The analysis most often reveals gaps in security between "where you are" and "where you want to be."
Tasks:
In: Computer Science
Linux Fundamentals part 3 Below are questions related to the command line use of Linux. You can use the videos, man pages, and notes to answer these questions. Remember that Linux is CASE SENSITIVE. Rm and rm are NOT the same command. I will count off totally for a question if you do not take this into account. For each command give me the ENTIRE COMMAND SEQUENCE. If I ask you 'What command would I use to move the file one.txt to the parent directory and rename it to two.txt?", the answer is NOT 'mv'. That is only part of the command. I want the entire command sequence.
10. Find all files under the current directory with an accessed time was more than 2 days ago.
11. I have a file called 'BackupLogs.tar.bz2' in my home
directory (because you made it from Questions 4 and 8, right?
Right!). I want to uncompress and unarchive the files in it. What
single command would I use?
12. I have a file called BackupLogs.tar.bz2 and I want to
uncompress and ONLY uncompress the file (NOT uncompress and
unarchive). What command would I use?
13. I want to search for all files in the directory ~/Documents
which contain the keyword "add", case sensitive, and as the whole
word only. Words like addendum, addition, etc, should not be found
in the results; just 'add'. Additionally, I only want to see the
name(s) of the file(s) that have matches as a result of running the
command. This means your result should show not the keyword hit AND
surrounding text, but rather suppress that output and instead
display just the file name. What command would I use? This may
sound complicated, but break down each step and use the man
page.
14. I have a large file named walloftext.txt and I want to view
only the first 5 lines of the file. What command would I
use?
15. Same as file as Question 14, but I want to view only the
last 7 lines.
In: Computer Science
Add a CountGroups method to the linked list class below (OurList). It returns the number of groups of a value from the list. The value is passed into the method. A group is one or more values.
Examples using strings:
A list contains the following strings: one, one, dog, dog, one,
one, one, dog, dog, dog, dog, one, one, dog, one
CountGroup(“one”) prints 4 groups of one's
CountGroup(“dog”) prints 3 groups of dog's
Do not turn in the code below. Turn in only your method.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LinkListExample { public class OurList<T> { private class Node { public T Data { get; set; } public Node Next { get; set; } public Node(T paramData = default(T), Node paramNext = null) { this.Data = paramData; this.Next = paramNext; } } private Node first; public OurList() { first = null; } public void Clear() // shown in class notes { first = null; } public void AddFirst(T data) // shown in class notes { this.first = new Node(data, this.first); } public void RemoveFirst() // shown in class notes { if (first != null) first = first.Next; } public void AddLast(T data) // shown in class notes { if (first == null) AddFirst(data); else { Node pTmp = first; while (pTmp.Next != null) pTmp = pTmp.Next; pTmp.Next = new Node(data, null); } } public void RemoveLast() // shown in class notes { if (first == null) return; else if (first.Next == null) RemoveFirst(); else { Node pTmp = first; while (pTmp.Next != null && pTmp.Next.Next != null) pTmp = pTmp.Next; pTmp.Next = null; } } public void Display() // shown in class notes { Node pTmp = first; while (pTmp != null) { Console.Write("{0}, ", pTmp.Data); pTmp = pTmp.Next; } Console.WriteLine(); } public bool IsEmpty() // shown in class notes { if (first == null) return true; else return false; } } }
In: Computer Science
In the funcs directory create a file named funcs.py. This section requires that you implement and test multiple functions. You should develop these functions and their tests one at a time. The function implementations must be placed in funcs.py. The test cases will, of course, be placed in the provided funcs_tests.py.
You must provide at least two test cases for each of these functions. In addition, you should separate your testing into multiple functions (the file includes stubs for the first two testing functions to get you started).
This part will be executed with: python funcs_tests.py
f(x) = 7x2 + 2x
Write a function, named f (a poor name, really, but maps from the context), that corresponds to the stated mathematical definition.
g(x, y) = x2 + y2
Write a function, named g (again, a poor name), that corresponds to the stated mathematical definition.
hypotenuse
Write a function, named hypotenuse, that takes two arguments corresponding to the lengths of the sides adjacent to the right angle of a right-triangle and that returns the hypotenuse of the triangle. You will need to use the math.sqrt function from the math library, so be sure to import math at the top of your source file.
is_positive
Write a function, named is_positive, that takes a single number as an argument and that returns True when the argument is positive and False otherwise. You must write this function using a relational operator and without using any sort of conditional (i.e., if); the solution without a conditional is actually much simpler than one with. Your test cases should use assertTrue and assertFalse as appropriate.
NOTE:All of the files said to be provided are just templates for the solution but are not needed to do the problem
In: Computer Science
[JAVA SCRIPT]
Please create an array of student names and another array of student grades.
Create a function that can put a name and a grade to the arrays.
Keep Read student name and grade until student name is “???”. And save the reading by using a function
Create another function to show all the grade in that object.
Create the third function that can display the maximum grade and the student’s name.
Create a sorting function that can sort the arrays based on the student’s grade.
Display all the grades and names sorted by the grade.
In: Computer Science
Python file
def calci(): grade = float(input("Enter your grade:")) while (grade <= 4): if (grade >= 0.00 and grade <= 0.67): print("F") break elif (grade >= 0.67 and grade <= 0.99): print("D-") break elif (grade >= 1.00 and grade <= 1.32): print("D") break elif (grade >= 1.33 and grade <= 1.66): print("D+") break elif (grade >= 1.67 and grade <= 1.99): print("C-") break elif (grade >= 2.00 and grade <= 2.32): print("C") break elif (grade >= 2.33 and grade <= 2.66): print("C+") break elif (grade >= 2.67 and grade <= 2.99): print("B-") break elif (grade >= 3.00 and grade <= 3.32): print("B") break elif (grade >= 3.33 and grade <= 3.66): print("B+") elif (grade >= 3.67 and grade <= 3.99): print("A-") break elif (grade == 4.00): print("A") break elif (grade == 4.00): print("A+") else: print("Invalid input enter FLOAT only") def main2(): question = input("Continue (y/n)") if question == "y" or question == "Y": calci() if question == "n" or question == "N": print("Bye") print("ISQA 4900 quiz") main2() TWO PROBLEM1)it need to ask question everytime 2) it should show an invalid message
In: Computer Science
I need to create a monthly loan Calculator in C++. I know the formula but can't figure out what's wrong with my code. Any clarification would be appreciated!
// Only add code where indicated by the comments.
// Do not modify any other code.
#include <iostream>
#include <cmath>
using namespace std;
int main() {
// ---------------- Add code here
--------------------
// -- Declare necessary variables
here
--
int years = 0; //n
int LoanAmount = 0;
double AnnualRate = 0.0; //r
double payment = 0.0;
// --
cout << "Enter the amount, rate as a
percentage (e.g. 3.25), and number of years\n";
cout << " separated by spaces: " <<
endl;
// ---------------- Add code here
--------------------
// -- Receive input and compute the monthly payment
--
cin >> LoanAmount >> AnnualRate >>
years;
AnnualRate = AnnualRate / 100;
years = years * 12;
payment = ((LoanAmount * AnnualRate) / 1 - (1 +
AnnualRate) * -years);
// ---------------- Add code here
------------------
// Print out the answer as a double, all by
itself
// (no text) followed by a newline
// Ex. cout << payment << endl;
cout << payment << endl;
return 0;
}
In: Computer Science
Develop a C program for matrix multiplication focusing on using malloc and pointers WITHOUT USING BRACKETS [] !!
* DO not use [ ] 'brackets', focus on using malloc, calloc, etc...
Program will ask user for the name of the text file to be
read
Read the datafile with format:
1
2
1
1 2
3
4
So the first three lines will represent m, n, p (Matrix A: m x n
||| Matrix B: n x p), follwing are the two matrices.
Representing:
A = |1 2| B = |3|
|4|
------------------------------------------------
example input and output:
Matrix A contents:
1 2
3 4
5 6
Matrix B contents:
7 8
9 10
11 12 13 14
Matrix A * B is:
29 32 35 38
65 72 79 86
101 112 123 134
The datafile read for this example is:
3
2
4
1 2
3 4
5 6
7 8 9 10
11 12 13 14
In: Computer Science
Specification
This script reads in class data from a file and creates a
dictionary.
It then prints the data from the dictionary.
The script has the following functions
class_tuple_create
This function has the following header
def class_tuple_create(filename):
The function reads in a file with four fields of data about a
class.
The fields are
Course ID Room number Instructor Start time
The function must print an error message if the file cannot be
opened for any reason.
The function should read in each line of the file and split it into
a list of 4 elements.
It should add the information in the line into a dictionary, where
the key is the course number and the value is a tuple consisting of
the room number, the instructor and the start time.
The function should return this dictionary when it has read all the
lines in the file.
print_classes
This function has the following header
def print_classes(class_info):
It should print the following table header
ID Room Instr Start
Then it should print out the data for each class in alphabetical
order by Class ID.
The data for each course should align with the labels.
Test Code
The script must contain the following test code at the bottom of the file
class_information = class_tuple_create('xxxxx') class_information = class_tuple_create('courses.txt') print_classes(class_information)
For the test code to work you must copy into your hw3 directory the file from /home/ghoffman/course_files/it117_files.
cp /home/ghoffman/course_files/it117_files/courses.txt .
Suggestions
Write this script in stages, testing your script at each step
Output
The output should look something like this
Error: Unable to open xxxxx ID Room Instr Start ------------------------------- CM241 1411 Lee 13:00 CS101 3004 Haynes 8:00 CS102 4501 Smith 9:00 CS103 6755 Rich 10:00 NT110 1244 Burke 11:00
In: Computer Science