Due to some bug in cache control module of ARP package, it increments the time out value instead of decrementing it. How does it affect the performance of the cache tablein following scenarios?a.Number of different destination IP addresses are less than size of cache tableb.Number of different destination IP addresses aresignificantly larger than size of cache table.
In: Computer Science
2. Create a class called Invoice that a store might use to represent an invoice for an item sold at the store. An Invoice should include four data members—the ID for the item sold (type string), name of item (type string), item description (type string) and the price of the item (type int). Your class should have a constructor that initializes the four data members. A constructor that receives multiple arguments. Example: ClassName( TypeName1 parameterName1, TypeName2 parameterName2, ... ) Provide a set and a get function for each data member. SearchbyNameAndAdd(): Ask the user which item he/she wants to purchase, if the item is found in the list then store the price of the item in a temporary array or variable. This function will keep adding the amount of items being selected by the user. Once the user has selected all the item he/she needs exit from this function and display the total amount by using the function below: o A function named getTotalAmount () that displays the total amount/bill as an int value.
write it in C++
In: Computer Science
I am working on exercise 5.48 from Introduction to Computing using python (Author: Perkovic).
Problem Question: Let list1 and list2 be two lists of integers. We say that list1 is a sublist of list2 if the elements in list1 appear in list 2 in the same order as they appear in list1, but not necessarily consecutively. For ex, if list1 is defined as [15,1,100] and list2 is defined as [20,15,30,50,1,100]. Then list 1 is a sublist of list 2 because the numbers in list1 (15,1, and 100) appear in the same order. However, list [15,20,20] is not a sublist of list2. Implement function sublist() that takes as input lists list1 and list2 and returns True if list1 is a sublist of list2 and False otherwise.
I've gotten so far with the below code, but the code is not returning anything when I run it. I'm not sure what I am doing wrong here. Any hints of next steps would be great!
def sublist(lst1, lst2):
i = 0
for n in lst1:
while i < len(lst2):
if lst2[i] == n:
i+=1
return True
return False
print(sublist([15,1,100],[20,15,30,50,1,100]))
print(sublist([15,50,20],[20,15,30,50,1,100]))
In: Computer Science
Exception handling to detect input string vs. int
The given program reads a list of single-word first names and ages (ending with -1), and outputs that list with the age incremented. The program fails and throws an exception if the second input on a line is a string rather than an int. At FIXME in the code, add a try/catch statement to catch ios_base::failure, and output 0 for the age.
Ex: If the input is:
Lee 18 Lua 21 Mary Beth 19 Stu 33 -1
then the output is:
Lee 19 Lua 22 Mary 0 Stu 34
---------------------------------------------------------
#include
#include
using namespace std;
int main(int argc, char* argv[]) {
string inputName;
int age;
// Set exception mask for cin stream
cin.exceptions(ios::failbit);
cin >> inputName;
while(inputName != "-1") {
// FIXME: The following line will throw an ios_base::failure.
// Insert a try/catch statement to catch the exception.
// Clear cin's failbit to put cin in a useable state.
cin >> age;
cout << inputName << " " << (age + 1) <<
endl;
cin >> inputName;
}
return 0;
}
In: Computer Science
Select 3 different sized (order lg lg n, lg n, n, n lg n, n2 , n3 , nk , cn , n!) algorithms to code using a compiler of choice (VB, C++, Java, , etc…). An example would be an algorithm to search for a number in a list of n numbers → (n), and a second algorithm to sort a list of numbers using a bubble sort → (n2 ). You could also choose to just calculate a open form expression like 1 + 2 + 3 + 4 + 5 + 6 + … n for a size n algorithm. Once the algorithms are coded and working (10pts. will be awarded on complexity/substance of algorithms), add a timer to the crucial section of the code that will correspond to the analysis. I have included some sample Java and C++ timer code below that should work. Show me the programs running/working with the time elapsed outputted for a run. 5pts. Run and time the three algorithms for n = 10, 100, 1000, 10000, etc… and chart the different times on a column, bar, or line chart. Turn in a word processed report listing the three algorithms code and the charts displaying the timed results of the runs. 5pts. Use long (16 bit) in Java and long long (16 bit) in C++ for your variables to avoid a memory problem.
In: Computer Science
2. Modify assignment 1 solution code I posted to do the following:
a. Change car class to bankAccount class and TestCar class to TestBank class
b. Change mileage to balance
c. Change car info (make, model, color, year, fuel efficiency) to customer first and last name and account balance
d. Change add gas to deposit (without limit)
e. Change drive to withdraw cash
f. Change test car menu to the following Bank Account Menu choices
1 - Deposit
2 - Withdraw
3 - Display account info
4 - Exit
public class Car {
//Attributes
private double fuelEfficiency, mileage, fuelCapacity,
fuelLevel;
private String make, model, color, year;
/**
* @return the make
*/
public String getMake() {
return make;
}
/**
* @param make the make to set
*/
public void setMake(String make) {
this.make = make;
}
/**
* @return the model
*/
public String getModel() {
return model;
}
/**
* @param model the model to set
*/
public void setModel(String model) {
this.model = model;
}
/**
* @return the color
*/
public String getColor() {
return color;
}
/**
* @param color the color to set
*/
public void setColor(String color) {
this.color = color;
}
/**
* @return the year
*/
public String getYear() {
return year;
}
/**
* @param year the year to set
*/
public void setYear(String year) {
this.year = year;
}
/**
* @return the fuelEfficiency
*/
public double getFuelEfficiency() {
return fuelEfficiency;
}
/**
* @param fuelEfficiency the fuelEfficiency to
set
*/
public void setFuelEfficiency(double fuelEfficiency)
{
this.fuelEfficiency =
fuelEfficiency;
}
/**
* @return the mileage
*/
public double getMileage() {
return mileage;
}
/**
* @param mileage the mileage to set
*/
public void setMileage(double mileage) {
this.mileage = mileage;
}
/**
* @return the fuelCapacity
*/
public double getFuelCapacity() {
return fuelCapacity;
}
/**
* @param fuelCapacity the fuelCapacity to set
*/
public void setFuelCapacity(double fuelCapacity)
{
this.fuelCapacity =
fuelCapacity;
}
/**
* @return the fuelLevel
*/
public double getFuelLevel() {
return fuelLevel;
}
/**
* @param fuelLevel the fuelLevel to set
*/
public void setFuelLevel(double fuelLevel) {
this.fuelLevel = fuelLevel;
}
public Car() {
fuelLevel = 0;
fuelCapacity = 0;
mileage = 0;
fuelEfficiency = 0;
}
public Car (double fuelEfficiency, double mileage,
double fuelCapacity) {
this.fuelEfficiency =
fuelEfficiency;
this.mileage = mileage;
this.fuelCapacity =
fuelCapacity;
}
public void drive(double distance) {
double gallons =
distance/fuelEfficiency;
if(fuelLevel <gallons){
System.out.println("Not enough gas!");
}
else {
mileage =
mileage + distance;
fuelLevel =
fuelLevel - gallons;
System.out.println("You have driven " +distance+ "
mile(s).");
System.out.println();
return;
}
}
public void addGas(double fuel) {
if (fuel + fuelLevel <
fuelCapacity){
fuelLevel =
fuelLevel + fuel;
System.out.println("You have added " +fuel+ " gallon(s) of
fuel.");
System.out.println();
return;
}
else {
System.out.println("Please enter an amount of fuel less than it's
capacity.");
}
}
public void displayCar(){
System.out.println();
System.out.println("Make: " +
getMake());
System.out.println("Model: " +
getModel());
System.out.println("Color: " +
getColor());
System.out.println("Year: " +
getYear());
System.out.println("You have driven
" + getMileage() + " miles.");
System.out.println("Your fuel level
is: " + getFuelLevel() + " gallon(s)");
System.out.println("Your fuel
efficiency is " + getFuelEfficiency() + " mpg.");
System.out.println("Your fuel tank
capacity is " + getFuelCapacity() + " gallons.");
System.out.println();
}
}
In: Computer Science
Usually, Djikstra’s shortest-path algorithm is not used on
graphs with negative-weight edges because it may fail and give us
an incorrect answer. However, sometimes Djikstra’s will give us the
correct answer even if the graph has negative edges.
You are given graph G with at least one negative edge, and a source
s. Write an algorithm that tests whether Djikstra’s algorithm will
give the correct shortest paths from s. If it does, return the
shortest paths. If not, return ‘no.’ The time complexity should not
be longer than that of Djiksta’s algorithm itself, which is Θ(|E| +
|V | log |V |).
(Hint: First, use Djikstra’s algorithm to come up with candidate
paths. Then, write an algorithm to verify whether they are in fact
the shortest paths from s.)
In: Computer Science
Write a C++ program using produces Huffman code for a string of text entered by the user. The string given by the user can be either 1 word or 1000 words.
Must accept all ASCII characters.
Please do not copy from the internet. This is my 3rd time
posting the same question and I have not received a correct
answer.
In: Computer Science
Perform all of these questions using MATLAB software.
5. The relative error in computation of
x-y for = 12.05 and y = 8.02 having absolute errors x=0.005 and y=-0.001.
6. Find the relative error in computation of x-y for x=9.05 and y= 6.56 having absolute errors x = 0.001
and y 0.003 respectively.
7.Find the relative error in computation of x+y for x= 11.75 and y= 7.23 having absolute errors x = 0.002
and y=0.005.
8. If y=4x^6-5x, find the percentage error in y at x=1, if the error is x=0.04.
In: Computer Science
Compare and contrast SEMMA and CRISP-DM. Discuss when application of SEMMA or CRISP-DM might be most appropriate by providing a specific example related to each of the two processes.
In: Computer Science
What is the C programming code to find the inverse of a 2*2 matrix?
In: Computer Science
Program: Java
Write a Java program using good programming principles that will
aggregate the values from several input files to calculate relevant
percentages and write the values to an output file.
You have been tasked with reading in values from multiple files
that contains different pieces of information by semester. The
Department of Education (DOE) would like the aggregate values of
performance and demographic information by academic year. A school
year begins at the fall semester and concludes at the end of the
summer semester the following year. Fall 2019 - Summer 2020 is
considered one academic year.
Input Files
These input files contain the data for three programs on
campus:
Program code 3624
Program code 5651
Program code 6635
Input file layout (all integer values) by semester:
Notes
Calculations
The following values must be calculated:
For each semester:
- the percentage of students completers (total number
of student completers / total number of students
enrolled)
For each individual program code:
- grand totals for each category (enrolled,
completers, gender, and ethnicity)
Aggregate for all semesters:
- the total number of students enrolled
- the total number of student completers
- the total number by gender
- the total number by each ethnicity
- the percentage of student completers (total
completers / total enrolled)
- the percentage of female completers (total number of
female completers / total number of female enrolled)
- the percentage of male completers
- the percentage of each ethnicity
Output
The output for this project will be two-fold. The
output will be displayed in a Message dialog box and an output
file.
The Message Dialog boxes:
Each percentage calculated should be displayed in percentage format
with one decimal place.
A sample format (the values are not accurate, this is only for formatting purposes):
Santa Fe College Academic Year 2019 - 2020 Program codes: 3624, 5651, and 6635 Aggregate total number of student enrolled: 5555 Aggregate total number of student completers: 4444 Aggregate percentage of students completing for the academic year: 81.2% Percentage of students completing Fall 2019: 76.9% Percentage of students completing Spring 2020: 85.3% Percentage of students completing Summer 2020: 84.1% |
On the next dialog screen, display the following:
Santa Fe College Academic Year 2019 - 2020 Program codes: 3624, 5651, and 6635 Aggregate values for: Female student completers: 88.8% Male student completers: 88.7% Unknown/not reported completers: 89.1% Asian completers: 90.1% Black completers: 90.2% Hispanic completers: 90.3% Multiracial completers: 90.4% Native American completers: 90.5% Native Hawaiian completers: 90.6% Unknown/Not Reported completers: 90.7% White completers: 90.8% |
Fall2019Analytics.txt: 3624 3729 2946 1774 1445 510 1442 1087 417 627 1021 939 216 47 15 122 742 572 977 735 181 39 11 84 3475651 4074 3585 1956 1977 141 1782 1731 72 413 927 893 314 56 37 395 1039 387 912 803 273 49 30 327 8046635 2116 1837 609 1058 449 582 1031 224 341 402 363 146 89 74 297 404 303 377 321 113 76 57 270 320
Spring2020Analytics.txt: 3624 3496 3102 1579 1238 679 1486 1017 599 703 1137 842 224 32 21 103 434 688 1007 774 221 30 21 101 2605651 3942 3711 1421 2213 308 2148 1349 214 443 739 804 310 46 37 173 1390 439 727 799 216 46 36 162 12866635 2101 1979 797 1273 31 752 1039 188 601 739 426 173 21 15 3 123 592 701 399 162 18 13 2 92
Summer2020Analytics.txt: 3624 2021 1983 771 1137 113 717 1083 183 307 526 601 211 27 4 13 332 297 506 600 208 26 4 13 3295651 3013 2883 1267 1393 353 1240 1297 346 226 402 373 102 16 13 17 1864 214 401 369 96 15 13 17 17586635 1731 1546 663 817 251 612 799 135 107 392 649 81 30 21 71 380 103 384 621 80 30 20 70 238
In: Computer Science
Program: Java
Write a Java program using good programming principles that will
aggregate the values from several input files to calculate relevant
percentages and write the values to an output file.
You have been tasked with reading in values from multiple files
that contains different pieces of information by semester. The
Department of Education (DOE) would like the aggregate values of
performance and demographic information by academic year. A school
year begins at the fall semester and concludes at the end of the
summer semester the following year. Fall 2019 - Summer 2020 is
considered one academic year.
Input Files
These input files contain the data for three programs on
campus:
Program code 3624
Program code 5651
Program code 6635
Input file layout (all integer values) by semester:
Notes
Calculations
The following values must be calculated:
For each semester:
- the percentage of students completers (total number
of student completers / total number of students
enrolled)
For each individual program code:
- grand totals for each category (enrolled,
completers, gender, and ethnicity)
Aggregate for all semesters:
- the total number of students enrolled
- the total number of student completers
- the total number by gender
- the total number by each ethnicity
- the percentage of student completers (total
completers / total enrolled)
- the percentage of female completers (total number of
female completers / total number of female enrolled)
- the percentage of male completers
- the percentage of each ethnicity
Output
The output for this project will be two-fold. The
output will be displayed in a Message dialog box and an output
file.
The Message Dialog boxes:
Each percentage calculated should be displayed in percentage format
with one decimal place.
A sample format (the values are not accurate, this is only for formatting purposes):
Santa Fe College Academic Year 2019 - 2020 Program codes: 3624, 5651, and 6635 Aggregate total number of student enrolled: 5555 Aggregate total number of student completers: 4444 Aggregate percentage of students completing for the academic year: 81.2% Percentage of students completing Fall 2019: 76.9% Percentage of students completing Spring 2020: 85.3% Percentage of students completing Summer 2020: 84.1% |
On the next dialog screen, display the following:
Santa Fe College Academic Year 2019 - 2020 Program codes: 3624, 5651, and 6635 Aggregate values for: Female student completers: 88.8% Male student completers: 88.7% Unknown/not reported completers: 89.1% Asian completers: 90.1% Black completers: 90.2% Hispanic completers: 90.3% Multiracial completers: 90.4% Native American completers: 90.5% Native Hawaiian completers: 90.6% Unknown/Not Reported completers: 90.7% White completers: 90.8% |
Fall2019Analytics.txt: 3624 3729 2946 1774 1445 510 1442 1087 417 627 1021 939 216 47 15 122 742 572 977 735 181 39 11 84 3475651 4074 3585 1956 1977 141 1782 1731 72 413 927 893 314 56 37 395 1039 387 912 803 273 49 30 327 8046635 2116 1837 609 1058 449 582 1031 224 341 402 363 146 89 74 297 404 303 377 321 113 76 57 270 320
Spring2020Analytics.txt: 3624 3496 3102 1579 1238 679 1486 1017 599 703 1137 842 224 32 21 103 434 688 1007 774 221 30 21 101 2605651 3942 3711 1421 2213 308 2148 1349 214 443 739 804 310 46 37 173 1390 439 727 799 216 46 36 162 12866635 2101 1979 797 1273 31 752 1039 188 601 739 426 173 21 15 3 123 592 701 399 162 18 13 2 92
Summer2020Analytics.txt: 3624 2021 1983 771 1137 113 717 1083 183 307 526 601 211 27 4 13 332 297 506 600 208 26 4 13 3295651 3013 2883 1267 1393 353 1240 1297 346 226 402 373 102 16 13 17 1864 214 401 369 96 15 13 17 17586635 1731 1546 663 817 251 612 799 135 107 392 649 81 30 21 71 380 103 384 621 80 30 20 70 238
In: Computer Science
JAVA
What is the output? Explain how you obtain this answer by hand, not using a computer. String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for(int i = 1; i <= 26; i *= 2) { System.out.print(alphabet.charAt(i - 1)); }
What is the output? Explain how you obtain this answer by hand, not using a computer. int n = 500; int count = 0; while (n > 1) { if (n % 2 == 0) { n /= 3; } else { n /= 2; } count++; } System.out.println(count);
A Java Swing application contains this paintComponent method for a panel. Sketch what is drawn by this method. public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.black); g.fillRect(100, 100, 200, 100); g.fillRect(300, 200, 200, 100); g.fillRect(500, 100, 200, 100); }
In: Computer Science
QUESTION ONE
Huawei believes that, with the advent of 5G, Harmony OS will be
able to resolve the next biggest challenge which is to provide
seamless interoperability between the cloud, Artificial
intelligence (AI) and IoT. Discuss ways in which this
interoperability could help resolve today’s real-world challenges.
Motivate your answers with examples.
QUESTION TWO
E-commerce has the potential of increasing the sales of devices
running the Harmony operating system. What web-marketing strategies
have Huawei adopted to advertise their products and services and
promote their reputation?
QUESTION THREE
Using theory and practical examples, discuss how businesses have
adopted the Internet of things (IoT) to create value for their
customers.
QUESTION FOUR
The implementation of 5G does more harm than good? Discuss reasons
why you agree or disagree with this statement.
In: Computer Science