Design a complete JAVA program with the following methods:-
In the main method : 3 variables are declared :- employee id, salary and status.
A method that will allow user to input employee id and salary.
A method that will assign status to “Taxable’ if employee’s salary is more than 2500RM or “Not Taxable” if salary is less and equal to 2500RM.
A method that will display the employee’s id , salary and its status.
Write the above Using Java.
In: Computer Science
Computer Networks
Hi guys. Please can you assist me in answering these questions. I will greatly appreciate it.
1. Packets with sequence numbers 0, 1, 2, 3, 4 and 5 have all
been sent to the receiver. The receiver has received packets with
sequence numbers 0,1,3 and 4. In which protocol will packets with
sequence numbers 2, 3 and 4 be resent?
a. Stop and wait
b. RDT3.0
c. Go-Back-N
d. Selective repeat
e. None of the above
2. A web server runs in Host A on port 80. The web server uses
persistent connections. The web server receives requests form Host
B and Host C. Which of the following is true regarding the socket
or sockets through which data is received at Host A?
a. The segments will be directed to a socket that is identified by
4 properties or tuples
b. The segments from Host A and Host B will be directed to
different sockets
c. Segments are directed to connection sockets which differ from
the original socket used for TCP handshaking
d. A, B and C
e. None of the above
3. The TCP congestion protocol always attempts to use the most
bandwidth, increases the amount of data transmitted until packet
loss occurs. What term is used to describe this?
a. Congestion avoidance
b. Bandwidth probing
c. Available bit rate
d. Self-clocking
e. None of the above
4. Comparing the Go-Back-N (GBN) and Selective Repeat (SR) protocols. Assume a window size of 15. How many timers are needed for GBN?
5. With reference to explicit congestion notification congestion
control, which bit notifies the sender that there is congestion on
the network?
a. ECN
b. ECE
c. ACK
d. SEQ
e. None of the above
6. In which reliable data transfer protocol is the sequence
number sent with the ACK as part of the arguments
a. RDT2.0
b. RDT2.1
c. RDT2.2
d. A, B & C
e. None of the above
7. Which of the following do the Go-Back-N and Selective Repeat
protocols both make use of?
a. Sliding scale
b. Sliding window
c. Sliding sequences
d. Sliding packet
e. None of the above
In: Computer Science
How would you correct this function in C to prevent buffer overflow using the fgets() function and strncat() function
void nameBuilder()
{
char fname[10];
char lname[10];
char fullname[20];
printf("Enter your first name: ");
scanf("%s", fname);
printf("Enter your last name: ");
scanf("%s", lname);
strcat(fullname, fname);
strcat(fullname, " ");
strcat(fullname, lname);
printf("Welcome. %s\n", fullname);
return;
}
In: Computer Science
In C++, write a function to fill an array of size 13 with values
13 11 9 7 5 3 1 2 4 6 8 10 12
recursively, starting with the value 1 in the middle.
In: Computer Science
1. In c++, Class D is derived from class B. The class D does not contain any data members of its own . Does the class D require constructor? If yes, why? Explain with the help of a code example.
2. State true or false, giving proper reasons[3,5]
(a) Virtual functions are used to create pointer to base
class.
(b) A pointer to base class cannot be made to point to objects of
derived class.
(c) Defining a derived class requires some changes in base
class.
(d) Inheritance helps in making a general class into a more
specific class.
3. When do we make a virtual function pure? What are the implications of making a pure virtual function?
In: Computer Science
PYTHON CODE
- Write the body of a function second_instance(s, c) which consumes a string s and a length 1 string c that is contained at least twice in s and returns the index of the second location of c.
second_instance: Str Str -> Nat
Requires:
len(c) == 1
c occurs at least twice in s
Examples:
second_instance("banana", "a") => 3
second_instance("bb", "b") => 1
- Write the body of a function make_list(n) which consumes a natural number n and returns a list of strings where in position , the number is repeated as a string times. You must use loops in your solution. Do not use recursion or abstract list functions.
Returns the list of strings formed by in position i,
repeating i a total of i times
make_list: Nat -> (listof Str)
Examples:
make_list(0) => ['']
make_list(3) => ['', '1', '22', '333']
- Write the body of a function niven(n) using recursion that consumes a natural number n and returns True if and only if n is a Niven number and False otherwise. A Niven number is a number which is divisible by the sum of its digits.
Returns True if and only if n is a Niven number.
niven: Nat -> Bool
Examples:
niven(0) => False
niven(1) => True
niven(132) => True
niven(143) => False
- Write the body of a function find_max(L) using loops that returns the maximum of a non-empty list of integers L. Do not use recursion, abstract list functions, or the command max.
Returns the maximum in a non-empty list of integers L
find_max: (listof Int) -> Int
Examples:
find_max([1]) => 1
find_max([-10,-1,-5]) => -1
In: Computer Science
In: Computer Science
The main function creates 5 pixels with random red, green, and blue values. Complete the id_color function to return “red” if the red value is greater than the green and blue, “green” if the green value is greater than the red and blue, and “blue” if the blue value is greater than the red and green. If there is no clear maximum value (for example, if the red and green values are the same) return None. Do not change the main function.
import image
import random
def id_color(p):
'''Returns the dominant color of pixel p'''
pass
#Your code here to determine the dominant color and return a string
identifying it
#Hint: get the red, green & blue values and use an if statement
to determine which has the highest value
def main():
'''Controls the program'''
for i in range(5): #Loop 5 times
r = random.randrange(0, 256)
g = random.randrange(0, 256)
b = random.randrange(0, 256)
print(r, g, b) #Show the pixel red, green & blue values
new_pixel = image.Pixel(r, g, b)
print(id_color(new_pixel))
main() #Run the program
In: Computer Science
First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects).
Then create a new Java application called "BackwardsStrings" (without the quotation marks) that:
So, for example, if the first string is 'usr' and the second string is 'bin', your program would output something like the following:
The two strings you entered are: usr bin. The two strings in reverse are: nib rsu.
Note that the reversed SECOND string comes FIRST when printing the strings in reverse.
This program must be completed without using loops and without using StringBuilder.
See Horstmann pp. 62-63 for some ideas. Make sure your program includes the command line prompts for the user and that it formats the output appropriately.
Be sure both input strings are three characters in length. If this data validation isn't passed, output "Invalid string length for one or both inputs." and do not proceed with further processing of the strings.
In: Computer Science
Write a program 'Rectangle-Area.c' that inputs the length and width of a rectangle and outputs its area. The program consists of two functions: the main function and a function that computes and returns the area of a rectangle. The output of the program should be in the main program, not in the function.
Sample Input: 5 8 Sample Output: The area of a 5 by 8 rectangle is 40.
In: Computer Science
What is a network access point?
I am trying to draw a network model for the company "Slack". What would be considered an access point to a big company like that. I have an example that says small businesses use LAN
In: Computer Science
In bash
Write a script which receives a list of parameters. If no parameters are received, output an error message. Otherwise, iterate through the list and, using a case statement, test each item in the list to see if it starts with a capital letter, lower case letter, digit or other. Count each type and output at the end the total for each category (capital, lower case, digit, other).
In: Computer Science
I need an infix to postfix function that accounts for all (, ), {, }, [, ].. For example.
8-{{(1-[0+4]+8)}}
In c++ please.
In: Computer Science
In: Computer Science
First, launch NetBeans and close any previous projects that may be open (at the top menu go to File ==> Close All Projects). Then create a new Java application called "PasswordChecker" (without the quotation marks) that gets a String of a single word from the user at the command line and checks whether the String, called inputPassword, conforms to the following password policy. The password must: Be exactly three characters in length Include at least one uppercase character Include at least one digit If the password conforms to the policy, output "The provided password is valid." Otherwise, output "The provided password is invalid because it must be three characters in length and include at least one digit and at least one uppercase character. Please try again." Some other points to remember... Do not use a loop in this program.
The Character class offers various methods to assist us in finding a digit or cased letter. Remember to press "." to locate these methods and to leverage the online resources shown in our course thus far." For this PA, do not use pattern matching (aka "regular expressions").
In: Computer Science