Use the Internet to research IDS and Vulnerability Management and Assessment Tools. Find at least six (6) tools for each security tool category, with a minimum of three (3) Open Source and three (3) Commercial for each category of tools (6 IDS and 6 Vulnerability Management).
write a paragraph explaining which tool you prefer or will recommend for your company (one statement for each category, open source vs commercial). What is your logic behind your choice?
In: Computer Science
Using Eclipse to answer this Java question
Using the concepts from the Concurrency Basics Tutorial I provided in Modules, write a program that consists of two threads. The first is the main thread that every Java application has. The main thread should create a new thread from the Runnable object, MessageLoop, and wait for it to finish. If the MessageLoop thread takes too long to finish, the main thread should interrupt it. Use a variable named maxWaitTime to store the maximum number of seconds to wait. The main thread should output a message stating that it is still waiting every half second.
The MessageLoop thread should print out a series of 5 messages. It should wait 850 milliseconds between printing messages to create a delay. If it is interrupted before it has printed all its messages, the MessageLoop thread should print "Message loop interrupted" and exit.
Your program must demonstrate that it can both output messages and interrupt the message output. To do this, place your code in main into a for loop using maxWaitTime as the index.
So in main your code will be
for (int maxWaitTime = 1; maxWaitTime <= 5; maxWaitTime++) {
// All of main's processing goes here (All does not mean part of. ALL of main).
}
maxWaitTime means the same as it would in real life. It is how long the main thread waits before interrupting. Think about this. Don't confuse milliseconds and seconds.
Sample output :
maxWaitTime: 1 second(s)
main : Starting MessageLoop thread
main : Waiting for MessageLoop thread to finish
main : Continuing to wait...
main : Continuing to wait...
Thread-0 : 1. All that is gold does not glitter, Not all those who
wander are lost
main : MessageLoop interrupted
maxWaitTime: 2 second(s)
main : Starting MessageLoop thread
main : Waiting for MessageLoop thread to finish
main : Continuing to wait...
main : Continuing to wait...
Thread-1 : 1. All that is gold does not glitter, Not all those who
wander are lost
main : Continuing to wait...
main : Continuing to wait...
Thread-1 : 2. The old that is strong does not wither, Deep roots
are not reached by the frost
main : MessageLoop interrupted
maxWaitTime: 3 second(s)
main : Starting MessageLoop thread
main : Waiting for MessageLoop thread to finish
main : Continuing to wait...
main : Continuing to wait...
Thread-2 : 1. All that is gold does not glitter, Not all those who
wander are lost
main : Continuing to wait...
main : Continuing to wait...
Thread-2 : 2. The old that is strong does not wither, Deep roots
are not reached by the frost
main : Continuing to wait...
main : Continuing to wait...
Thread-2 : 3. From the ashes a fire shall be woken, A light from
the shadows shall spring
main : MessageLoop interrupted
maxWaitTime: 4 second(s)
main : Starting MessageLoop thread
main : Waiting for MessageLoop thread to finish
main : Continuing to wait...
main : Continuing to wait...
Thread-3 : 1. All that is gold does not glitter, Not all those who
wander are lost
main : Continuing to wait...
main : Continuing to wait...
Thread-3 : 2. The old that is strong does not wither, Deep roots
are not reached by the frost
main : Continuing to wait...
main : Continuing to wait...
Thread-3 : 3. From the ashes a fire shall be woken, A light from
the shadows shall spring
main : Continuing to wait...
Thread-3 : 4. Renewed shall be blade that was broken
main : Continuing to wait...
main : MessageLoop interrupted
maxWaitTime: 5 second(s)
main : Starting MessageLoop thread
main : Waiting for MessageLoop thread to finish
main : Continuing to wait...
main : Continuing to wait...
Thread-4 : 1. All that is gold does not glitter, Not all those who
wander are lost
main : Continuing to wait...
main : Continuing to wait...
Thread-4 : 2. The old that is strong does not wither, Deep roots
are not reached by the frost
main : Continuing to wait...
main : Continuing to wait...
Thread-4 : 3. From the ashes a fire shall be woken, A light from
the shadows shall spring
main : Continuing to wait...
Thread-4 : 4. Renewed shall be blade that was broken
main : Continuing to wait...
main : Continuing to wait...
Thread-4 : 5. The crownless again shall be king
main : Done!
In: Computer Science
Write a C or C++ program that uses pthreads to compute the
number of values that are
evenly divisible by 97 between a specified range of values
(INCLUSIVE).
The program should accept 3 command-line arguments:
low value
high value
number of threads to create to perform the computation
-Specifics for program
order of input: 0 9000000000 2 this means 0 to 9 Billion (INCLUSIVE); 2 threads
alarm(90); this should be the first executable line of the program to make sure it does not run for too long
use long ints instead of ints
hard-code the use of 97 in computations, instead of into a variable (const may be ok)
time1 please copy function below to get the time
sample output from the above run:
THREAD 0: 46391753
THREAD 1: 46391753
TOTAL 92783506
TIME 7.425558
time1 function
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <time.h>
#include <sys/time.h>
double time1()
{
struct timeval tv;
gettimeofday( &tv, ( struct timezone * ) 0 );
return ( (double) (tv.tv_sec + (tv.tv_usec / 1000000.0)) );
}
double time2()
{
return ( (double) time(NULL) );
}
void main(int argc,char *argv[])
{
double t1, t2, t3, t4;
t1 = time1();
t2 = time2();
printf("%lf %lf\n",t1,t2);
sleep(2);
t3 = time1();
t4 = time2();
printf("%lf %lf\n",t3,t4);
printf("%lf %lf\n",t3-t1,t4-t2);
}
In: Computer Science
Can you answer these question using python and recursive functions
Write a function that consumes two numbers N1 and N2 and prints out all the even numbers between those numbers, using recursion.
Using any number of list literals of maximum length 2, represent the data from your Survey List. So you cannot simply make a list of 15 values. Make a comment in your code that explicitly describes how you were able to represent this.
Write a recursive function that traverses your list of pairs and calculates their sum.
In: Computer Science
//those who say that "whether the student wants to understand or debug the code, IT IS IN THE COMMENTS, it says solve and that is all that is given for the code and no other instructions
it says //SOLVE
// the code already works you just have to finish the void functions that are given and run it and see if it works or not are those in the main are the test cases to test whether they work or not
#include
#include
using namespace std;
class NodeType {
public:
NodeType(int = 0); // constructor with default value for
// info field
int info; // data
NodeType *nextPtr; // pointer to next node in the list
};
// Constructor
NodeType::NodeType(int data) {
info = data;
nextPtr = 0;
}
void printmenu(void) {
cout << "N: new item" << endl;
cout << "P: print list" << endl;
cout << "F: find item" << endl;
cout << "D: delete head item" << endl;
cout << "V: delete value" << endl;
cout << "S: recursively sum values" << endl;
cout << "O: recursively prod values" << endl;
cout << "X: recursively find max" << endl;
cout << "G: recursive negative item on list" << endl;
cout << "Q: quit" << endl;
}
void printList(NodeType *currentPtr) {
//solve
return 0;
int MaxList(NodeType *currentPtr) {
//solve
return 0;
}
int sumList(NodeType *currentPtr) {
return 0;
//solve
}
int prodList(NodeType *currentPtr) {
//solve
return 0;
}
bool negList(NodeType *currentPtr) {
//solve
\ return 0;
}
NodeType *insertHead(NodeType *head, int value) {
//solve
NodeType *newptr;
return (newptr);
}
void findValue(NodeType *head, int value) {
//solve
}
NodeType *deleteFront(NodeType *head) {
// deletes the first item and returns the new head pointer
NodeType *tempPtr;
//solve
return tempPtr;
}
NodeType *deleteValue(NodeType *currentPtr, int value) {
NodeType *tempPtr = NULL;
//solve
return tempPtr;
}
int main(void) {
NodeType *head = NULL;
int value;
char input;
printmenu();
cout << "what is your selection?";
cin >> input;
while (input != 'Q' && input != 'q') {
switch (input) {
case 'n':
case 'N':
cout << "N" << endl;
break;
case 'p':
case 'P':
cout << "P" << endl;
break;
case 'o':
case 'O':
cout << "O" << endl;
break;
case 's':
case 'S':
cout << "S" << endl;
break;
case 'x':
case 'X':
cout << "X" << endl;
break;
case 'g':
case 'G':
cout << "G" << endl;
break;
case 'f':
case 'F':
cout << "What value would you like to find?" << endl;
cin >> value;
cout << endl << "You are finding: " << value << endl;
break;
case 'd':
case 'D':
cout << "Deleting head entry if present" << endl;
break;
case 'v':
case 'V':
cout << "What value would you like to delete?" << endl;
cin >> value;
cout << "You are deleting " << value << endl;
break;
default:
cout << "What happened?" << endl;
}
printmenu();
cout << "what is your selection?";
cin >> input;
}
system("pause");
}
In: Computer Science
To evaluate the predictive performance of a model constructed from a two-class data set, k-fold cross-validations are frequently applied. Describe the concept of cross-validation, and two performance measures, sensitivity and specificity, respectively.
In: Computer Science
Use the web or other resources to research at least two criminal or civil cases in which recovered files played a significant role in how the case was resolved.
Need 250 words
In: Computer Science
Beginning an IT project includes a fundamental skill of making the best product decision for your organization. One decision to make at the beginning of your project plan is to consider options available for your deliverable.
IT projects can be based on existing, off-the-shelf software that is customized to meet the needs of the project deliverables. In other cases, IT projects can be built from the ground up, in-house. Imagine you and your colleagues are consultants who have been asked to weigh in on the custom vs. off-the-shelf question at the beginning of an IT project at a Fortune 500 company.
Respond to the following in a minimum of 175 words:
In: Computer Science
#include <chrono.h>
#include <stdlib.h>
#include <iostream.h>
#include<conio.h>
#include <iomanip.h>
//#include <string.h>
#include <fstream.h>
//using namespace std;
int main(int argc, char * argv[])
{
ifstream myfile;
myfile.open("Input.txt");
auto st=high_resolution_clock::now();
float sum = 0;
float a=0;
//myfile >> a;
int i=0;
while (!myfile.eof())
{
myfile >> a;
sum+=a;
}
myfile.close();
auto stp=high_resolution_clock::now();
auto dur=duration_cast<microseconds>(stp-st);
cout<<"Total time taken ="<<dur.count()<<"ms"<<endl;// displaying time taken
cout<<"Sum of integers: "<<sum<<endl; // displaying results
getch();
return 0;
}
can someone please tell me what is wrong with this code. Its C++ programming
In: Computer Science
Use Python to solve: show all code:
2) For the last assignment you had to write a program that calculated and displayed the end of year balances in a savings account if $1,000 is put in the account at 6% interest for five years.
The program output looked like this:
Balance after year 1 is $ 1060.0
Balance after year 2 is $ 1123.6
Balance after year 3 is $ 1191.02
Balance after year 4 is $ 1262.48
Balance after year 5 is $ 1338.23
Modify your code so that it displays the balances for interest rates from three to five percent inclusive, in one percent intervals. (Hint: Use an outer loop that iterates on the interest rate, and an inner one that iterates on the year.)
Output:
Interest rate of 3 %:
Balance after year 1 is $ 1030.0
Balance after year 2 is $ 1060.9
Balance after year 3 is $ 1092.73
Balance after year 4 is $ 1125.51
Balance after year 5 is $ 1159.27
Interest rate of 4 %:
Balance after year 1 is $ 1040.0
Balance after year 2 is $ 1081.6
Balance after year 3 is $ 1124.86
Balance after year 4 is $ 1169.86
Balance after year 5 is $ 1216.65
Interest rate of 5 %:
Balance after year 1 is $ 1050.0
Balance after year 2 is $ 1102.5
Balance after year 3 is $ 1157.62
Balance after year 4 is $ 1215.51
Balance after year 5 is $ 1276.28
In: Computer Science
**only need part c and d answered below. It is in bold. In java, please implement the classes below. Each one needs to be created. Each class must be in separate file. The expected output is also in bold. I have also attached the driver for part 4.
2. The StudentRoster class should be in the assignment package.
a. There should be class variable for storing multiple students (the roster), semester and year. All class variables of the Student class must be private.
b. public StudentRoster(String semester, int year) is the single constructor of the class. All arguments of the constructor should be stored as class variables. There should no getters or setters for semester and year variables.
c. public boolean addStudent(String singleStudentData) takes a single student record as a string and breaks the string (tokenize) into first name, last name, grade1, grade2, grade3. The tokens are separated by comma. These values are used to create a Student object. If the student is already in the roster, then only the grades are updated (an additional student object is not added). If the student is not in the roster, then the Student object is added to the roster. The method returns true if a new student was added, return false otherwise.This method can generate two exceptions, BadGradeException and BadNameException. If first or last names are absent, or an integer is present where first and last names should be, then a BadNameException is generated. The message of this exception should state if it was caused by issues with first or last name. Similarly, a BadGradeException is generated if grades 1, 2 or 3 is absent or is not an integer. The message of this exception should state if it was caused by issues with grades 1, 2 or 3. The exceptions are not handled in this method.
d. public int addAllStudents(Scanner allStudents) takes a scanner object that contains multiple student records. Each student record is separated by a newline. This method must use theaddStudent method by retrieving one student record at a time from the Scanner object and passing that record to the addStudent method. The method returns the number of new students that were successfully added to the roster. This method handles all exceptions generated by the addStudent method. Before returning the count of successful additions to the roster, print to the console the total of each exception handled by the method.
The A4Driver class is attached below for guidance. I have also attached the expected output of the entire program.
package driver;
import java.util.Scanner;
import assignment.Student;
import assignment.StudentRoster;
public class A4Driver {
public static void main(String[] args) {
//test student class
System.out.println("test Student
class\n++++++++++++++++++++++++++++");
Student s = new Student("Bugs", "Bunny");
//same student
Student s3 = new Student("Bugs",
"Bunny");
System.out.println("Are students s
and s3 the same?: "+s.equals(s3)); //true
//not the same student
Student s2 = new Student("Buga",
"Bunny");
System.out.println("Are students s
and s2 the same?: "+s.equals(s2)); //false
//uncomment to check if
exception is thrown
s.equal(new Object());
//compute average 90
s.setGrade1(100);
s.setGrade2(90);
s.setGrade3(80);
System.out.println("Student s
average for the 3 grades is "+s.computeAverage());
System.out.println("\n\ntest
StudentRoster class\n++++++++++++++++++++++++++++");
String text =""
+ "Bugs, Bunny, 100 , 90, 80\n"
+ "Buga, Bunny, 100 , 80, 90\n"
+ "123, Bunny, 100 , 90, 80\n"
+ "Bugs, 1234 , 100 , 90, 80\n"
+ "BUGS, Bunny, 100 , 90, 80\n"
+ "Bugs, BUNNY, 100 , 90, 80\n"
+ "bugs, bunny, 70 , 90, 80\n"
+ "Betty, Davis, 100 , , \n"
+ "Betty, Davis, 100 , 40 , \n"
+ "Betty, Davis, , , \n"
+ "Betty, Davis, xx ,yy ,zz \n"
;
Scanner scan = new Scanner(text);
StudentRoster sr = new StudentRoster("Fall",
2019);
// Add only two students
System.out.println("\nTest addAllStudents, number of new students
added: "+sr.addAllStudents(scan));
//average of the two students should be 85
System.out.println("\nTest computeClassAverage, class
average is: "+sr.computeClassAverage());
//rank by grade1 Buga, Bugs
System.out.println("\nTest rankByGrade1:
"+sr.rankByGrade1());
//rank by grade2 Bugs, Buga
System.out.println("\nTest rankByGrade2:
"+sr.rankByGrade2());
//rank by grade3 Buga, Bugs
System.out.println("\nTest rankByGrade3:
"+sr.rankByGrade3());
//rank by average Buga, Bugs
System.out.println("\nTest rankByAverage:
"+sr.rankByAverage());
}
}
Example output:
__________Example from A4Driver shown below
test Student class ++++++++++++++++++++++++++++ Are students s and s3 the same?: true Are students s and s2 the same?: false Student s average for the 3 grades is 90.0
test StudentRoster class ++++++++++++++++++++++++++++ Exceptions Caught and Handled ========================== First name: 1
Last name: 1 Grade 1: 2 Grade 2: 1 Grade 3: 1
Test addAllStudents, number of new students added:
2
Test computeClassAverage, class average is: 85.0
Test rankByGrade1: [Buga Bunny grade1:100 grade2:80 grade3:90, Bugs
Bunny grade1:70 grade2:90 grade3:80]
Test rankByGrade2: [Bugs Bunny grade1:70 grade2:90 grade3:80, Buga Bunny grade1:100 grade2:80 grade3:90]
Test rankByGrade3: [Buga Bunny grade1:100 grade2:80 grade3:90, Bugs Bunny grade1:70 grade2:90 grade3:80]
Test rankByAverage: [Buga Bunny grade1:100 grade2:80 grade3:90, Bugs Bunny grade1:70 grade2:90 grade3:80]
In: Computer Science
Use Python to solve: show all work
1) Write a program that prints out a deck of cards, in the format specified below. (That is, the following should be the output of your code).
2 of hearts
2 of diamonds
2 of spades
2 of clubs
3 of hearts
3 of diamonds
3 of spades
3 of clubs
4 of hearts
4 of diamonds
4 of spades
4 of clubs
Continue with 5,6,7.. ending with
A of hearts
A of diamonds
A of spades
A of clubs
Start your program by defining the following two lists.
suits = ["hearts", "diamonds", "spades", "clubs"]
ranks = [“2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “10”, “J”, “Q”, “K”, “A”]
Remember you can use the for statement to get elements of a list.
For example if lst = ["A","B","C"] then
for elem in lst:
print (elem)
would print
A
B
C
In: Computer Science
java binary heap operation counts
/*
* Add operation counts to all methods - 4pts
* No other methods/variables should be added/modified
*/
public class A6BH <E extends Comparable<? super E>>
{
private int defaultSize = 4;
private int count = 0;
private E[] heap;
private int opCount = 0;
public int getOpCount()
{
return opCount;
}
public void resetOpCount()
{
opCount = 0;
}
public A6BH()
{
heap = (E[])new
Comparable[defaultSize];
}
public A6BH(int size)
{
heap = (E[])new
Comparable[this.nextSize(size)];
}
public A6BH(E[] items)
{
heap = (E[])new
Comparable[this.nextSize(items.length)];
this.addAll(items);
}
public void addAll(E[] items)
{
//make sure there is room for all
new items
if(count+items.length >=
heap.length)
{
growArray(this.nextSize(count+items.length));
}
for(E item : items)//copy new
items in order
{
count++;
heap[count] =
item;
}
this.buildHeap();//fix heap
order
}
private void buildHeap()
{
for(int i = count >> 1; i
> 0; i--)
{
percolateDown(i);
}
}
public void insert(E val)
{
//make sure we have room for new
item
if(count+1 >= heap.length)
{
growArray();
}
count++;
heap[0] = val;//temporary
storage
percolateUp(count);
}
private void percolateUp(int pos)
{
//pos>>1 = pos/2 - getting to
parent of empty space
for(;heap[pos>>1].compareTo(heap[0]) > 0;pos =
pos>>1)
{
heap[pos] =
heap[pos>>1];//move parent down a level
}
heap[pos] = heap[0];//take value
from initial insert and put in correct pos
}
public E findMin()
{
return (count >
0)?heap[1]:null;
}
public E deleteMin()
{
if(count > 0)
{
E temp =
heap[1];
heap[1] =
heap[count];//moved last value to top
count--;//decrease size
percolateDown(1);//move top value down to final position
return
temp;
}
else
{
return null;//no
items in heap
}
}
private void percolateDown(int pos)
{
int firstChild = pos <<
1;//pos * 2
E temp = heap[pos];
for(;pos<<1 <= count; pos
= firstChild, firstChild = pos<<1)
{
if(firstChild+1
<= count)//there is a second child
{
if(heap[firstChild].compareTo(heap[firstChild+1]) > 0)
{
firstChild++;
}
}
//firstChild is
now the index of the smaller child
if(temp.compareTo(heap[firstChild]) > 0)
{
heap[pos] = heap[firstChild];//move child up to
parent and continue
}
else
{
break;//stop loop because we found correct
position for temp
}
}
heap[pos] = temp;
}
public String toString()
{
String output = "Heap
Size:"+heap.length+"\n";
for(int i = 1; i <= count;
i++)
{
output +=
heap[i]+",";
}
return output;
}
public boolean isEmpty()
{
return count == 0;
}
public void makeEmpty()
{
count = 0;
}
private void growArray()//O(N)
{
growArray(heap.length <<
1);//heap.length * 2
}
private void growArray(int size)
{
//new array that is twice as
big
E[] newArr = (E[])new
Comparable[size];
//Move values to new array
for(int i = 1; i <= count;
i++)//O(N)
{
newArr[i] =
heap[i];
}
//System.out.println(Arrays.toString(newArr));
heap = newArr;//replace small array
with new one
}
private int nextSize(int size)
{
return 1 <<
(Integer.toBinaryString(size).length() + 1);//2^(number of bits to
represent number)
}
}
======================================================================================================
import java.util.Arrays;
import java.util.Random;
public class A6Driver {
public static void main(String[] args) {
Random randGen = new
Random();
randGen.nextInt(10);//better timing
values
long time =
System.nanoTime();//better timing values
A6BH<Integer> heap = new
A6BH<>();
heap.insert(5);//better timing
values
int testCases = 7;
for(int i = 1; i <= testCases;
i++)
{
System.out.println("Test "+i);
int N =
(int)Math.pow(10, i);
Integer[]
randoms = new Integer[N];
time =
System.nanoTime();
for(int j = 0; j
< randoms.length; j++)
{
randoms[j] = randGen.nextInt(N)+1;
}
time =
System.nanoTime() - time;
System.out.println("Generate "+N+" Randoms: "+(time/1000000000.0)+
" seconds");
time =
System.nanoTime();
heap = new
A6BH<>(randoms);
time =
System.nanoTime() - time;
System.out.println("Bulk insert: " + (time/1000000000.0)+"
seconds");
System.out.println("Bulk insert: " + heap.getOpCount()+"
operations");
time =
System.nanoTime();
heap = new
A6BH<>();
for(int j = 0; j
< randoms.length; j++)
{
heap.insert(randoms[j]);
}
time =
System.nanoTime() - time;
System.out.println("Individual insert: " + (time/1000000000.0)+"
seconds");
System.out.println("Individual insert: " + heap.getOpCount()+"
operations");
System.out.println();
}
}
}
In: Computer Science
DNS Query and Web Page Access Time:
Suppose you click on a hyperlink on a webpage you are currently viewing -- this causes a new web page to be loaded and displayed. Suppose the IP address for the host in the new URL is not cached in your local DNS server (AKA local name server), so your Client (browser) makes a DNS query to obtain the IP address before the page can be requested from the web server.
To resolve the DNS (obtain the IP Address for the web server), three separate DNS servers are queried (local DNS Name Server, TLD1 and Authoritative NS). Finally, the local name server returns the IP address of the web server to the Client and the DNS is resolved. The round trip times (RTT) to reach the DNS servers are: RTT0 = 3 msec, RTT1 =40 msec and RTT2 = 20 msec.
The requested Web page contains a base HTML page and no objects. RTTHTTP = 60msec is the time to send an HTTP request to the Web Server hosting the webpage and receive a response is. In other words, it takes 60msecs for the Client to fetch a web page/object from the web server. (Note: RTT = Round Trip Time = the time to send request and receive a response – inclusive, both directions).
Authoritative NS TLD1
With respect to the above information, answer the following questions:
A. DNS
a. Make a list describing in words (not numbers) each step in the DNS resolution:
What does the Client have at the end of this query?
Local Name Server
b. How much time in total is spent on the DNS query (show your numbers)?
B. Accessing the Web Page
c. Now that the client has the IP address of the web server, what
step must the Client do before
sending the HTTP request? How long does this step take?
How long does it take to retrieve the base web page from the web server? (include step c)
How much total time IN TOTAL elapses from the instant the client first clicks on the hyperlink until the web page is displayed? This time includes (b),(c) and (d). (Assume 0 seconds transmission time for the web page – makes the problem easier, but not really true for large files!)
C. New Page / New Objects
Now suppose you request another page on the same web server: a base HTML page and 4 small objects. Neglecting transmission time, how much time elapses from the instant the new link is clicked until the entire page can be displayed? Assume the local DNS server has cached the IP address of the web server. Show your work. Assume persistent connection and pipelining.
In: Computer Science
For this assignment, you will modify existing code to create a single Java™ program named BicycleDemo.java that incorporates the following:
Read through the "Lesson: Object-Oriented Programming Concepts" on The Java™ Tutorials website.
Download the linked Bicycle class, or cut-and-paste it at the top of a new Java™ project named BicycleDemo.
Download the linked BicycleDemo class, or cut-and-paste it beneath the Bicycle class in the BicycleDemo.java file.
Optionally, review this week's Individual "Week One Analyze Assignment," to refresh your understanding of how to code derived classes.
Adapt the Bicycle class by cutting and pasting the class into the NetBeans editor and completing the following:
Using the NetBeans editor, adapt the BicycleDemo class as follows:
Comment each line of code you add to explain what you added and why. Be sure to include a header comment that includes the name of the program, your name, PRG/421, and the date.
Rename your JAVA file to have a .txt file extension.
Submit your TXT file.
*******************CODE**************************
class Bicycle {
int cadence = 0;
int speed = 0;
int gear = 1;
void changeCadence(int newValue) {
cadence = newValue;
}
void changeGear(int newValue) {
gear = newValue;
}
void speedUp(int increment) {
speed = speed + increment;
}
void applyBrakes(int decrement) {
speed = speed - decrement;
}
void printStates() {
System.out.println("cadence:" +
cadence + " speed:" +
speed + " gear:" + gear);
}
}
***********************************SECOND CLASS********************************************
class BicycleDemo {
public static void main(String[] args) {
// Create two different
// Bicycle objects
Bicycle bike1 = new Bicycle();
Bicycle bike2 = new Bicycle();
// Invoke methods on
// those objects
bike1.changeCadence(50);
bike1.speedUp(10);
bike1.changeGear(2);
bike1.printStates();
bike2.changeCadence(50);
bike2.speedUp(10);
bike2.changeGear(2);
bike2.changeCadence(40);
bike2.speedUp(10);
bike2.changeGear(3);
bike2.printStates();
}
}In: Computer Science