Car Class
Write a class named Car that has the following member
variables:
• year. An int that holds the car’s model year.
• make. A string object that holds the make of the car.
• speed. An int that holds the car’s current speed. In addition,
the class should have the following member functions.
• Constructor. The constructor should accept the car’s year and
make as arguments and assign these values to the object’s year and
make member variables. The constructor should initialize the speed
member variable to 0.
• Accessors. Appropriate accessor functions should be created to
allow values to be retrieved from an object’s year, make, and speed
member variables.
• accelerate. The accelerate function should add 5 to the speed
member variable each time it is called.
• brake. The brake function should subtract 5 from the speed member
variable each time it is called.
Demonstrate the class in a program that creates a Car object, and then calls the accelerate function five times. After each call to the accelerate function, get the current speed of the car and display it. Then, call the brake function five times. After each call to the brake function, get the current speed of the car and display it.
Mimir Requirement: The file name must be: Homework6A.cpp
Test Case:
1967 Ford Mustang - current speed : 5
1967 Ford Mustang - current speed : 10
1967 Ford Mustang - current speed : 15
1967 Ford Mustang - current speed : 20
1967 Ford Mustang - current speed : 25
1967 Ford Mustang - current speed : 20
1967 Ford Mustang - current speed : 15
1967 Ford Mustang - current speed : 10
1967 Ford Mustang - current speed : 5
1967 Ford Mustang - current speed : 0
In: Computer Science
Write a Java application that prompts the user for an age. If the age entered is greater or equal to 65, display the statement "Age is greater than or equal to 65"; otherwise display the message "Age is less than 65". If the age entered is less than 18; display the statement "This person is a minor"; otherwise display the message "This person can legally vote. Do not create a class for this application. The code can be created in the main driver program.
In: Computer Science
1. What is the structure data type in C?
2. What is the value ranges of data type of unsigned char, unsigned short, respectively?
3. How many regular resisters are in this X-CPU?
4. How does the X-CPU access the memory?
5. What is the maximum memory address?
6. Which statements in the code is to increase the PC value?
7. What is the minimal cycle number that is just needed to print “Hello world!” 4 times?
8. what is the minimal cycles number do that is just needed to print ONE “Hello world!” once?
In: Computer Science
10. We are trying to assign the value of a variable named “FirstNumber” to a variable named “SecondNumber”. They are declared as shown below. Which of the following statements is correct?
double FirstNumber = 25.5;
int SecondNumber;
Group of answer choices
c. SecondNumber = int.Parse (FirstNumber);
b. SecondNumber = (double) FirstNumber;
d. SecondNumber = double.Parse (FirstNumber);
a. SecondNumber = (int)FirstNumber;
In: Computer Science
JAVA please write this method
public static void recursiveMergeSort(int[] arr) {
}
In: Computer Science
Write a C program that prompts the user to enter three sets of five double numbers each. (You may assume the user responds correctly and doesn’t enter non-numeric data.)
The program should accomplish all of the following:
a. Store the information in a 3×5 array.
b. Compute the average of each set of five values.
c. Compute the average of all the values.
d. Determine the largest value of the 15 values.
e. Report the results.
Each major task should be handled by a separate function using the traditional C approach to handling arrays.
Accomplish task “b” by using a function that computes
and returns the average of a one-dimensional array; use a loop to call this function three times.
The other tasks should take the entire array as an argument, and the functions performing tasks “c” and “d” should return the answer to the calling program.
When using for loops, please write them like this because this is the only way my compiler takes them.
int i = 0;
for( i < 6; i++)
I have to declare outside of for loop for some reason
In: Computer Science
1. What are the benefits of writing a change management policy? Why is an understanding of risk and risk management so important to an effective and successful information security program? Support your answer with material from the eText or the academic literature.
In: Computer Science
JAVA please write this method
public static void recursiveSelectionSort(int[] arr) {
}
In: Computer Science
Can you explain in details how this loop works?
int[] someNums = {90, 85, 65, 95, 75} ;
a = 1;
while(a < someNums.length) {
temp = someNums [a ];
b = a - 1 ;
while(b >= 0 && someNums[ b] >temp) {
someNums [b + 1] = someNums [ b];
--b;
}
someNums [b + 1] = temp ;
++a ; }
In: Computer Science
One of the following determines when the variable is created and destroyed and how long it will retain its value.
linkage |
||
storage class |
||
scope |
||
none of the above |
In: Computer Science
In python
Write a program to implement RSA algorithm based on the public key.
def encryptmessage():
def decryptmessage():
encryptmessage ()
decryptmessage ()
No in-built functions and third-party APIs will be allowed.
In: Computer Science
Case Project 13-2. Detecting Hackers in the Alexander Rocco Network
You receive a frantic call from the system administrator of the Alexander Rocco network, JW Tabacchi. He tells you he has identified several intrusion attempts from sources over the Internet. You’re not sure if the hackers have gained access to the internal network. First, based on the tools described in this chapter and some of the techniques you’ve learned in this book, write a TWO PAGE report about the things you might look for to identify an attacker or a compromised host on your network. Second, make some recommendations on how you might instrument the network with network protection systems to better detect and prevent compromises in the future.
NOTE: I WANT TWO PAGE REPORT
In: Computer Science
3. Consider the following recursive algorithm for computing the sum of the
following series: S(n) = 1/1! + 2/2! + . . . + n/n!.
ALGORITHM S (n)
//Input: A positive integer n
// Procedure: fact(n) returns the factorial of the number
passed
as parameter
//Output: The sum of the series: S(n) = 1/1! + 2/2! + . . . + n/n!
if n = 1 return 1
else return S(n − 1) + n/fact(n)
Set up and solve a recurrence relation for the number of times the algo- rithm’s basic operation is executed.
How does this algorithm compare with the straightforward nonrecursive algorithm for computing this sum?
In: Computer Science
Code and document the following functions using NON-RECURSIVE
ITERATION only.
Test the functions by calling them from a simple interactive main()
function using a menu, with different values used to select the
choice of function. Overall, you should have one C program (call it
Lab1.c) containing one main() function and 5 other functions, where
the functions are called based on an interactive user menu. The
program should contain a loop that permits users to enter a new
choice of function for each loop, until exit from the loop
explicitly.
1
Factorial(0) = 1;
Factorial(n) = n * (n-1) * . . . * 2 * 1
Requirement: n >= 0; reject with error message
otherwise
2
Fibonacci(0) = 0;
Fibonacci(1) = 1;
Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2);
Requirement: n >= 0; reject with error message
otherwise
3
gcd (x, y) = x, if y=0
gcd (x, y) = gcd (y, x MOD y), if y > 0
Requirement: x and y both > 0; reject with error message
otherwise
4
Power(a,b) = ??
Requirement: a > 0, b > 0, b is an integer; reject with
error message otherwise
5
digProduct (x) = x if x <9
digProduct (x) = rightDigit * digProduct ( x/10)
Requirement: x is an unsigned integer (> 0); reject with
error message otherwise
Sample Interaction
Lab 1
1 - int Factorial(int n);
2 - int Fibonacci(int n);
3 - int Gcd(int x, int y);
4 - double Power(int a, int b);
5 – int digProduct (int x);
0 - QUIT
Please enter a selection: 6
Invalid Input.
Lab 1
1 - int Factorial(int n);
2 - int Fibonacci(int n);
3 - int Gcd(int x, int y);
4 - double Power(int a, int b);
5 – int digProduct (int x);
0 - QUIT
Please enter a selection: 1
Enter a positive Integer: 5
Answer: 120
Lab 1
1 - int Factorial(int n);
2 - int Fibonacci(int n);
3 - int Gcd(int x, int y);
4 - double Power(int a, int b);
5 – int digProduct (int x);
0 - QUIT
Please enter a selection: 4
Enter the first positive Integer: 2
Enter the second positive Integer: 3
Answer: 8
Lab 1
1 - int Factorial(int n);
2 - int Fibonacci(int n);
3 - int Gcd(int x, int y);
4 - double Power(int a, int b);
5 – int digProduct (int x);
0 - QUIT
Please enter a selection: 0
Goodbye!
In: Computer Science
Show that AES decryption is, in fact, the inverse of AES encryption
In: Computer Science