Questions
Create a C program that will test the following : Theory (0-70): 65 Laboratory (0-30): 25...

Create a C program that will test the following :
Theory (0-70): 65
Laboratory (0-30): 25
Total Marks: 90

In: Computer Science

One student has designed a new transport-layer protocol, NTLP, that is completely different from the TCP...

One student has designed a new transport-layer protocol, NTLP, that is completely different from the TCP or UDP. He then creates a packet that has a physical-layer header, a data-link-layer header, and an IP header. This packet contains the NTLP header and the application data payload. The packet is sent to the destination IP address as indicated in the IP header. Will this packet be delivered to the destination IP address indicated in the IP header? Please justify your answer.

In: Computer Science

Consider the following reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0,...

Consider the following reference string:

7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1

Find the number of Page Faults with FIFO, Optimal Page Replacement, and LRU with four free frames that are initially empty. Which algorithm gives the minimum number of page faults?

In: Computer Science

1.Consider a two-way communication between John and Jane in which both want to exchange messages privately...

1.Consider a two-way communication between John and Jane in which both want to exchange messages privately over a network. A third party, Tom wants also wants to know what messages are being exchanged between John and Jane. Explain what specific type of cybersecurity attack describes Tom’s malicious intentions of intercepting the private exchanges between John and Jane and how it can be carried out without being detected

In: Computer Science

Write a C++ main program that has the following: 9. Display all printable characters of the...

Write a C++ main program that has the following:

9. Display all printable characters of the ASCII table in 3 columns: first column: 32-63, second column: 64-95, third column: 96-127. Each column must include the numeric value and the corresponding character. Following is an example of one of 32 rows in the ASCII table:
33 ! 65 A 97 a

In: Computer Science

1.Explain the security risks of devices with Remote Desktop access enabled

1.Explain the security risks of devices with Remote Desktop access enabled

In: Computer Science

DO NOT ANSWER THIS[1. Write a program named filemaker.py that will be used to store the...

DO NOT ANSWER THIS[1. Write a program named filemaker.py that will be used to store the first name and age of some friends in a text file named friends.txt. The program must use a while loop that prompts the user to enter the first name and age of each friend. Each of these entries should be written to its own line in the text file (2 lines of data per friend). The while loop should repeat until the user presses Enter (Return on a Mac) for the name. Then, the file should be closed and a message should be displayed. See Sample Output. SAMPLE OUTPUT Enter first name of friend or Enter to quit Denny Enter age (integer) of this friend 24 Enter first name of friend or Enter to quit Penny Enter age (integer) of this friend 28 Enter first name of friend or Enter to quit Lenny Enter age (integer) of this friend 20 Enter first name of friend or Enter to quit Jenny Enter age (integer) of this friend 24 Enter first name of friend or Enter to quit File was created] DO NOT ANSWER THIS

Code for the above program

fp = open("friends.txt", "w")

firstname = input("Enter first name of friend or Enter to quit ")

while firstname!="":

age = int(input("Enter age (integer) of this friend "))

print(firstname, file=fp)

print(age, file=fp)

firstname = input("Enter first name of friend or Enter to quit ")

fp.close()

print("File was Created")

the QUESTION IN PYTHON

Now write a program named filereader.py that reads and displays the data in friends.txt. This program should also determine and print the average age of the friends on file. That will require an accumulator and a counter. Use a while loop to process the file, print the data, and modify the accumulator and counter. Then close the file and display the average age accurate to one decimal place. See the Sample Output..
SAMPLE OUTPUT

My friend Denny is 24
My friend Penny is 28
My friend Lenny is 20
My friend Jenny is 24
Average age of friends is 24.0

In: Computer Science

Struct PERSON Assignment Outcomes: Demonstrate the ability to create structs using typedef Demonstrate the ability to...

Struct PERSON Assignment

Outcomes:

  • Demonstrate the ability to create structs using typedef
  • Demonstrate the ability to create an array of structs

Program Specifications:

DESIGN and IMPLEMENT a program that will CREATE and use three different variables of type PERSON.

Create a struct using the typedef command for a DATE.

Create a struct for a PERSON with the following fields.

  • name [this will be a string]
  • birthdate [this will be a DATE]
  • gender [this will be a char]
  • annualIncome [this will be either float or double, your choice]

Create three variables of type PERSON. Create a function that populates the data for each person (all 3 of them). Create a function that outputs all data about each of the people in a nice formatted manner.

Data Validation:

All dates entered must be validated. Make sure you account for the number of days in each month, the fact that there are exactly 12 months and every four years there is a leap year.

The name for each PERSON will be stored in sentence case.

The gender will either be M, F, or O.

The annual income will between 0 dollars and 1 million dollars.

Submission Requirements:

Requirements will be same as the first assignment which will be the same for all future assignments except that you do NOT NEED a design tool for this assignment.

DO NOT:

  • Use global variables, in this or any program ever.
  • Use goto statement(s), in this or any program ever.

In: Computer Science

Shapes2D Write the following four classes to practice using an abstract class and polymorphism. Submit all...

Shapes2D

Write the following four classes to practice using an abstract class and polymorphism. Submit all four classes.


Shape2D class

For this class, include just an abstract method name get2DArea() that returns a double.


Rectangle2D class

Make this class inherit from the Shape2D class. Have it store a length and a width as fields. Provide a constructor that takes two double arguments and uses them to set the fields. Note, the area of a rectangle is the length times the width.


Circle2D class

Also make this class inherit from the Shape2D class. Have it store a radius as a field. Provide a constructor that takes a double argument and uses it to set the field. Note, the area of a circle is PI times it's radius times it's radius.


Shape2DDriver class

Have this class provide a method named displayArea() that takes an object from just any of the above three classes (you can't use an Object type parameter). Have the method display the area of the object, rounded to one decimal place.


Also the code should Enforce an abstract get2DArea() method and the right parameter type for displayArea()


Executes the following code:


Shape2DDriver tester = new Shape2DDriver();


Rectangle2D r = new Rectangle2D( 2, 3 );

Circle2D c = new Circle2D( 4 );


tester.displayArea( r );

tester.displayArea( c );

In: Computer Science

1.Create full program in Java that will simulate a Rock Paper Scissors Game You will create...

1.Create full program in Java that will simulate a Rock Paper Scissors Game You will create the code so that when the program is run the user will see in the console the following: We are going to play rock paper scissors. Please choose 1 for Rock 2 for Paper or 3 for scissors. The program will have your choice which is the integer-valued typed in by the user and compChoice which will be the randomly generated value of either 1 2 or 3. You will test all the ways the user wins if he or she beats the computer using || with if and then you will check all the ways that computer could win using else if with || and lastly the only other thing that can happen would be a tie if both choices are the same for the default else. Display what was chosen and what was randomly chosen by the computer and who wins or if there is a tie. For extra credit, you can use dialog boxes and show images.

In: Computer Science

Java program Create two classes based on the java code below. One class for the main...

Java program

Create two classes based on the java code below. One class for the main method (named InvestmentTest) and the other is an Investment class. The InvestmentTest class has a main method and the Investment class consists of the necessary methods and fields for each investment as described below.

1.The Investment class has the following members:

a. At least six private fields (instance variables) to store an Investment name, number of shares, buying price, selling price, and buying commission and sales commission.

b. Write set and get methods to access each of the private fields

c. “InvestmentSummary” method to print Investment Information including the result of

3. Create two different objects of the investment class

4. Create an object of java.util.Scanner to input the information about each investment, one at a time form the keyboard, and track the information in the proper Investment objects by placing calls to the proper set methods for each of the two objects.

5. When invoking the InvestmentSummary method, use the get method found in the Investment class to access the private members.

    a. Print the investment information including gain or loss using the string %s specifier.

StockProfit.java

import java.text.DecimalFormat;
import java.util.Scanner;

public class StockProfit {

   public static void main(String[] args) {
  
       DecimalFormat df=new DecimalFormat("#.##");
       //Scanner class object is used to read the inouts entered by the user
       Scanner kb=new Scanner(System.in);
      
       int ns; // Number of shares
double sp; // Sale price per share
double sc; // Sale commission
double pp; // Purchase price per share
double pc; // Purchase commission
double prof; // Profit from a sale
  
// Get the number of shares.
System.out.print("How many shares did you buy and then sell? ");
ns=kb.nextInt();
  
// Get the purchase price per share.
System.out.print("What price did you pay for the stock per share? ");
pp=kb.nextDouble();

// Get the purchase commission.
System.out.print("What was the purchase commission? ");
pc=kb.nextDouble();

// Get the sale price per share.
System.out.print("What was the sale price per share? ");
sp=kb.nextDouble();

// Get the sales commission.
System.out.print("What was the sales commission? ");
sc=kb.nextDouble();

// Get the profit or loss.
prof = profit(ns, pp, pc, sp, sc);

// Display the result.
System.out.print("The profit from this sale of stock is $"+df.format(prof));

   }
   // ********************************************************
   // The profit function accepts as arguments the number of *
   // shares, the purchase price per share, the purchase *
   // commission paid, the sale price per share, and the *
   // sale commission paid. The function returns the profit *
   // (or loss) from the sale of stock as a double. *
   // ********************************************************
   private static double profit(int ns, double pp, double pc, double sp,
           double sc) {
       return ((ns * sp) - sc) - ((ns * pp) + pc);
   }

}

In: Computer Science

How to write this Python You are a small business owner and you have six employees....

How to write this Python
You are a small business owner and you have six employees. All the employees have the same pay rate, that is $12 per hour. Write a program that will ask the user to enter the number of hours worked by each employee, then display the amounts of gross pay for each employee.

1.    Get the number of worked hours for each employee and store it in a list.
2.    Use the stored value in each element to calculate the gross pay for each employee and display the amount. 
3.    Match your output format to the below sample output.

Answer should look like this

Enter the hours worked by employee 1: 20
Enter the hours worked by employee 2: 25
Enter the hours worked by employee 3: 29
Enter the hours worked by employee 4: 30
Enter the hours worked by employee 5: 20
Enter the hours worked by employee 6: 19

Enter the hourly pay rate: 12

Gross pay for employee 1: $240.00
Gross pay for employee 2: $300.00
Gross pay for employee 3: $348.00
Gross pay for employee 4: $360.00
Gross pay for employee 5: $240.00
Gross pay for employee 6: $228.00

In: Computer Science

What decimal value does the 8-bit binary number 10011110 have if: a) it is interpreted as...

What decimal value does the 8-bit binary number 10011110 have if:

a) it is interpreted as an unsigned number?

b) It is on a computer using signed-magnitude representation?

c) It is on a computer using one’s complement representation?

d) It is on a computer using two’s complement representation?

In: Computer Science

when the user entered a negative number, you output a message that it was not possible...

when the user entered a negative number, you output a message that it was not possible to take the square root of a negative number. This time you will write a Python program that asks the user to enter a non-negative number (float). If the user does enter a negative number, you will use a while loop to continue prompting the user until you get a valid number (i.e. a number >= 0). Once the user enters a valid number, you calculate and print the square root. Test your program twice, once using a negative number and once using a non-negative number.

In: Computer Science

Write a python function called HackCaesar with the following requirements: def hack_caesar(cyphertext): ‘’’ cyphertext is a...

Write a python function called HackCaesar with the following requirements:

def hack_caesar(cyphertext): ‘’’ cyphertext is a text encoded using Caesars encryption. The encryption key is unknown. The function returns the correct encryption key. Hint: Use the function we wrote was called caesar(c, key) and could encode a single character.

# YOUR CODE GOES HERE


def is_odd(n):
return n%2 == 1


def caesar(c, key):
""" Encrypts a lower case character c using key
Example: if c = "a" and key=3 then the function should return d
"""
return chr((ord(c)-97+key) % 26 + 97)


n = input("enter a number:")
n = int(n)
if n > 10:
print("hello")
print("your number if more than 10")
else:
print("else block")



for i in range(5):
print(i)
print(i*i)
print(is_odd(i))
print(caesar("a", 3))

In: Computer Science