Questions
**Complete for display digits 0 and 7 only** A combinational circuit is used to control a...

**Complete for display digits 0 and 7 only**

A combinational circuit is used to control a seven-segment display of decimal digits, as shown in Figure 11.35. The circuit has four inputs, which provide the four-bit code used in packed decimal representation (010 = 0000,c, 910 = 1001). The seven outputs define which segments will be activated to display a given decimal digit. Note that some combinations of inputs and outputs are not needed. a. Develop a truth table for this circuit. b. Express the truth table in SOP form. c. Express the truth table in POS form. d. Provide a simplified expression.

In: Computer Science

Code in Java In Chapter 9, we created the CommissionEmployee-BasePlusCommissionEmployee inheritance hierarchy to model the relationship...

Code in Java

In Chapter 9, we created the CommissionEmployee-BasePlusCommissionEmployee inheritance hierarchy to model the relationship between two types of employees and how to calculate the earnings for each. Another way to look at the problem is that CommissionEmployees and BasePlusCommissionEmployees are each Employees and that each has a different CompensationModel object.

A CompensationModel would provide an earnings method. Classes or subclasses of CompensationModel would contain the details of a particular Employee's compensation:

  • CommissionCompensationModel - For Employees who are paid by commission, the CommissionCompensationModel class would contain grossSales and commissionRate instance variables, and would define an earnings method to return grossSales * commissionRate.
  • BasePlusCommissionCompensationModel - For Employees who are paid a base salary and commission, this subclass of CommissionCompensationModel would contain an instance variable of baseSalary and would define the earnings method to return super.earnings() + baseSalary.

Each of these classes would contain a toString() method that displays the Compensation Model information as illustrated in the sample output.

This approach is more flexible than our original hierarchy. For example, consider an Employee who gets promoted. With the approach described here, you can simply change that Employee's CompensationModel by assigning the composed CompensationModel reference an appropriate subclass object. With the CommissionEmployee - BasePlusCommissionEmployee hierarchy, you'd need to change the Employee's type by creating a new object of the appropriate class and moving data from the old object to the new one.

Implement the Employee class and CompensationModel hierarchy discussed in this exercise. In addition to the firstName, lastName, socialSecurityNumber and CommisionCompensationModel instance variables, class Employee should provide:

  • A constructor that receives three Strings and a CommissionCompensationModel to initialize the instance variables.
  • A set method that allows the client code to change an Employee's CompensationModel.
  • An earnings method that calls the CompensationModel's earning method and returns the result.
  • A toString() method that displays all the information about the Employee as illustrated in the sample output.

Your code in the subclasses should call methods in the super classes whenever possible to reduce the amount of code in the subclasses and utilize the code already developed in the super classes as in the code demonstrated in Figures 9.10 and 9.11 in the book.

Use the following code in your main function to test your classes, just copy and paste it into your main method:

        // Create the two employees with their compensation models.
       
        CommissionCompensationModel commissionModel = new CommissionCompensationModel(2000.00, 0.04);
        BasePlusCommissionCompensationModel basePlusCommissionModel = new BasePlusCommissionCompensationModel(2000.00, 0.05, 600.00);
       
        Employee employee1 = new Employee("John", "Smith", "111-11-1111", commissionModel);
        Employee employee2 = new Employee("Sue", "Jones", "222-22-2222", basePlusCommissionModel);
       
        System.out.printf("%s%n%s%n", employee1, employee2);
        System.out.printf("%s%s%s%s%s%8.2f%n%n", "Earnings for ", employee1.getFirstName(), " ", employee1.getLastName(), ": ", employee1.earnings());
       
        // Change the compensation model for the two employees.
       
        CommissionCompensationModel commissionModelNew = new CommissionCompensationModel(5000.00, 0.04);
        BasePlusCommissionCompensationModel basePlusCommissionModelNew = new BasePlusCommissionCompensationModel(4000.00, 0.05, 800.00);
       
        // Set the new compensation models for the employees.
        employee1.setCompensation(basePlusCommissionModelNew);
        employee2.setCompensation(commissionModelNew);
       
        // Print out the new information for the two employees.
        System.out.printf("%s%n%s%n", employee1, employee2);

The output from your program should look like the following:

run:
John Smith
Social Security Number: 111-11-1111
Commission Compensation with:
Gross Sales of: 2000.00
Commission Rate of: 0.04
Earnings:    80.00

Sue Jones
Social Security Number: 222-22-2222
Base Plus Commission Compensation with:
Gross Sales of: 2000.00
Commission Rate of: 0.05
Base Salary of:   600.00
Earnings:   700.00

Earnings for John Smith:    80.00

John Smith
Social Security Number: 111-11-1111
Base Plus Commission Compensation with:
Gross Sales of: 4000.00
Commission Rate of: 0.05
Base Salary of:   800.00
Earnings: 1000.00

Sue Jones
Social Security Number: 222-22-2222
Commission Compensation with:
Gross Sales of: 5000.00
Commission Rate of: 0.04
Earnings:   200.00

In: Computer Science

In An Introduciton to Programmig Using Visual Basic tenth edition chapter 6 the 4th project program...

In An Introduciton to Programmig Using Visual Basic tenth edition chapter 6 the 4th project program has me using loops. I am having a hard time trying to figure out what the double declining balance methods depreciation value is. It is 2 divided by the items life, but multiplied by the previous years balance. I do not know how to find the previous years balance to use in the depreciation value. Thank you

In: Computer Science

Please discuss and explain PCIS (Payment Card Industry Standards). Please also discuss credit card security and...

Please discuss and explain PCIS (Payment Card Industry Standards). Please also discuss credit card security and give an example of a data/security breach involving an organization. What happened? What was done?

In: Computer Science

At the moment this code only give you results for whatever fraction you put for "x",...

At the moment this code only give you results for whatever fraction you put for "x", and "y" inside the main code. How do I get this existing code to ask the user to enter a fraction, and then ask another questions for another fraction, and then display the results of adding, multiplying, and dividing the fractions?

Something like:

"Please enter the first fraction: " >>> 1/2

"Please enter the second fraction:" >>> 5/3

Result of adding = x/x

Result of multiplying = x/x

Result for dividing = x/x

*** DO NOT CHANGE THE CODE TOO MUCH. MAIN GOAL IS TO ONLY MAKE IT ASK THE USER FOR INPUT ***


def gcd(m,n):
    while m%n != 0:
        oldm = m
        oldn = n

        m = oldn
        n = oldm%oldn

    return n

class Fraction:
    def __init__(self,top,bottom):
        self.num = top
        self.den = bottom

    def __str__(self): #We cannot print out fractions because python does not know how to convert an object into a string

        return str(self.num)+"/"+str(self.den)

    def __add__(self,otherfraction):
        newnum = self.num*otherfraction.den + \
                     self.den*otherfraction.num
        newden = self.den * otherfraction.den
        common = gcd(newnum,newden)

        return Fraction(newnum//common,newden//common)

    def __eq__(self, other):
        firstnum = self.num * other.den
        secondnum = other.num * self.den
      
        return firstnum == secondnum

    def __mul__(self,other):
        newnum = self.num*other.num
        newden = self.den*other.den
        common=gcd(newnum,newden)

        return Fraction(newnum//common, newden//common)

    def __truediv__ (self, other):
        newnum = self.num*other.den
        newden = self.den*other.num
        common=gcd(newnum,newden)

        return Fraction(newnum//common, newden//common)
                      
def main():


    x = Fraction(10,7)
    y = Fraction(5,9)
    print(x+y)
    print(x*y)
    print(x/y)
  
main()


  

In: Computer Science

NOTE: This is done using Visual Basic. Create an application named You Do It 2. Add...

NOTE: This is done using Visual Basic.

Create an application named You Do It 2. Add a text box, a label, and a button to the form. Enter the following three Option statements above the Public Class clause in the Code Editor window: Option Explicit On, Option Strict Off, and Option Infer Off. In the button’s Click event procedure, declare a Double variable named dblNum. Use an assignment statement to assign the contents of the text box to the Double variable. Then, use an assignment statement to assign the contents of the Double variable to the label. Save the solution and then start and test the application. Stop the application. Finally, change the Option Strict Off statement to Option Strict On and then use what you learned in this Focus lesson to make the necessary modifications to the code. Save the solution and then start and test the application. Close the solution.

In: Computer Science

Learning binary and other numbering systems is an important skill for computer and software engineers. Write...

Learning binary and other numbering systems is an important skill for computer and software engineers. Write the following in decimal (base 10), binary, octal (base 8), and hexadecimal. Show your work by hand (don’t forget to scan your work and put it in your PDF).

Decimal 1, 10, 42, 255

Hexadecimal F, DF, 81, 04

Binary 10010011, 111111

In: Computer Science

NOTE: This is done using Visual Basic. Create an application named You Do It 1. Add...

NOTE: This is done using Visual Basic.

Create an application named You Do It 1. Add a text box, a label, and a button to the form. The button’s Click event procedure should store the contents of the text box in a Double variable named dblCost. It then should display the variable’s contents in the label. Enter the three Option statements above the Public Class clause in the Code Editor window, and then code the procedure. Save the solution and then start and test the application. Close the solution.

In: Computer Science

Write a program in java which has two arrays of size 4 and 5; merge them...

Write a program in java which has two arrays of size 4 and 5; merge them and sort.

In: Computer Science

The CIA triad is widely referenced in today's information security environments as a basic model for...

The CIA triad is widely referenced in today's information security environments as a basic model for information security. There are three distinct legs to the CIA triad: confidentiality, integrity, and availability. Select one of the CIA components and expand on it. Include a baseline review of that specific attribute as well as challenges that might be encountered, including two potential security issues.

Respond to the following in a minimum of 175 words:

In: Computer Science

** Only bold needs to be answered In Java, implement the Athlete, Swimmer, Runner, and AthleteRoster...

** Only bold needs to be answered

In Java, implement the Athlete, Swimmer, Runner, and AthleteRoster classes below. Each class must be in separate file. Draw an UML diagram with the inheritance relationship of the classes.

1. The Athlete class
a. All class variables of the Athlete class must be private.

b.is a class with a single constructor: Athlete(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender). All arguments of the constructor should be stored as class variables. There should only be getter methods for first and last name variables. There should be no getters or setters for birthYear, birthMonth, birthDay.

c. Getter and setter methods for the gender of the athlete. The method setGender accepts a character and store it as a class variable. Characters 'm', 'M' denotes male, 'f' or 'F' denotes male or female. Any other char will be treated as undeclared. The method getGender return either the word "male" or "female" or “undeclared”.

  1. The method computeAge() takes no arguments and returns the athletes computed age (as of today's date) as a string of the form "X years, Y months and Z days". Hint: Use the LocalDate and Period classes.

    i. e.g. "21 years, 2 months and 3 days". ii. e.g. "21 years and 3 days".

    iii. e.g. "21 years and 2 months". iv. e.g. "21 years".

    v. e.g. "2 months and 3 days".

  2. The method public long daysSinceBirth() takes no arguments and returns a long which is the number of days since the athlete’s date of birth to the current day. Hint: Use the LocalDate and ChronoUnit classes.

  3. The toString method returns a string comprised of the results ofgetFname, getLName and computeAge. E.g.

    i. “Bunny Bugs is 19 years and 1 day old”

  4. The equals method returns true if the name and date of birth of this athlete and the compared other athlete are the same, otherwise return false.

2. The Swimmer class
a. All class variables of the Swimmer class must be private.

  1. inherits from the Athlete class and has a single constructor,

    Swimmer(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender, String team). There should be a class variable for team. There should be a getter method for team.

  2. The Swimmer class stores swim events for the swimmer. There should be a class variable for events. A swimmer participates in one or more of these events. The addEvent method is oveloadedand either adds a single event for the swimmer public boolean addEvent(String singleEvent) or adds a group of events for the swimmer public boolean addEvent(ArrayList multiEvents). Each event is of type String. Duplicate events are not stored and return false if duplicate found.

  3. There should be a getter method that returns the class variable events.

  4. The overridden toString method returns a string comprised of the concatenation of the parent’s toString return plus " and is a swimmer for team: XXXXX in the following events: YYYYY; ZZZZZZ." E.g.

    i. “Missy Franklin is 24 years and 4 months old and is a swimmer for team: Colorado Stars. She participates in the following events: [100m freestyle, 100m backstroke, 50m backstroke]”

3. The Runner class
a. All class variables of the Runner class must be private.

  1. inherits from the Athlete class and has a single constructor,

    Runner(String lName, String fName, int birthYear, int birthMonth, int birthDay, char gender, String country). There should be a class variable for country. There should be a getter method for country.

  2. The Runner class stores race events for the runner. There should be a class variable for events. Each event is a Distance. The list of valid events is given below:
    M100, M200, M400, M3000, M5000, M10000. A runner participates inone or more of these events. The addEvent method is oveloadedand either adds a single event for the runner public boolean addEvent(String singleEvent) or adds a group of events for the runner public boolean addEvent(ArrayList multiEvents). Each event is of type String. Duplicate events are not stored and return false if duplicate found.

  1. There should be a getter method that returns the class variable events.

  2. The toString method returns a String in the form: " AAA BBBB is XX years, YY months and ZZ days. He is a citizen of CCCCCCC and is a DDDDDDDD who participates in these events: [MJ00, MK00, ML00]”. If she does not participate in M3000 or M5000 or M10000 then she is a sprinter. If she does not participate in M100 or M200 or M400 then she is a long-distance runner. Otherwise she is a super athlete. E.g.

    i. “Bunny Bugs is 19 years and 1 day old. His is a citizen of USA and is a long-distance runner who participates in these events: [M10000]”

4. The AthleteRoster class
a. All class variables of the AthleteRoster class must be private.

  1. Does not inherits from the Athlete class. The AthleteRoster class has a single constructor, AthleteRoster(String semster, int year). There should be class variables for semester and year. There should be getter methods for semester and year.

  2. The AthleteRoster class has only one method for adding Athlete to the roster, by using the boolean addAthlete(Athlete a)method. The method returns true if the athlete was added successfully, it returns false if the athlete object already exists in the roster and therefore was not added.

  3. Your AthleteRoster class will have only one class level data structure, an ArrayList, for storing athlete objects.

  4. The String allAthletesOrderedByLastName() method returns a string object with of all the names of the athletes (Swimmers, Runners, etc.) in ascending order of last names(a-z).

  5. The String allAthletesOrderedByAge() method returns a string object with of all the names of the athletes (Swimmers, Runners, etc.) in descending order of age(100-0).

  6. The String allRunnersOrderedByNumberOfEvents() method returns a string object with of all the names of the Runners only in ascending order of number of events they participate in (0-100).

Complete the code before the due date. Submission of the completed eclipse project is via github link posted on the class page. Add your UML drawing to the github repo. ________________________________________________________________________ Example output:

__________Example from AthleteDriver shown below

Gender is undeclared
Gender is female
Gender is male
ComputeAge method says 19 years and 4 days
First name is : Duck

DaysSinceBirth method says 6943 days Last name is : Daffy
Output of our toString correct?:
Duck Daffy is 19 years and 4 days old =======================================

Did we add M10000 successfully?: true
Did we unsuccessfully try to add M10000 again?: false
Did we successfully add multiple events?: true
Did we unsuccessfully try to add multiple events?: false
How many events does Bugs participate in?: 3
Gender is male
Output of our toString correct?:
Bunny Bugs is 19 years and 3 days old. His is a citizen of USA and is a super athlete who participates in these events: [M10000, M100, M3000] =======================================

In: Computer Science

Question 1: Suppose we wish to transmit at a rate of 64kbps over a 3 kHz...

Question 1:

Suppose we wish to transmit at a rate of 64kbps over a 3 kHz telephone channel. What is the

minimum SNR required to accomplish this?

Question 2:

a) What is differential encoding?
b) Define biphase encoding and describe two biphase encoding techniques.

In: Computer Science

More Object Concepts (Exercise 4) Part A: Open the file BloodData.java that includes fields that hold...

More Object Concepts (Exercise 4)

Part A:

Open the file BloodData.java that includes fields that hold a blood type (the four blood types are O, A, B, and AB) and an Rh factor (the factors are + and –). Create a default constructor that sets the fields to “O” and “+”, and an overloaded constructor that requires values for both fields. Include get and set methods for each field. Open the file TestBloodData.java and click the Run button to demonstrate that each method works correctly.

Part B:

Open the file Patient.java which includes an ID number, age, and BloodData. Provide a default constructor that sets the ID number to “0”, the age to 0, and the BloodData to “O” and “+”. Create an overloaded constructor that provides values for each field. Also provide get methods for each field. Open TestPatient.java. Click the Run button at the bottom of your screen to demonstrate that each method works correctly.

BloodData.java

public class BloodData
{
public String bType;
public String rh;
public BloodData()
{
bType = "O";
rh = "+";
}
public BloodData(String bType, String rh)
{
this.bType = bType;
this.rh = rh;
}
public void setBloodType(String bType)
{
this.bType = bType;
}
public String getBloodType()
{
return bType;
}
public void setRhFactor(String rh)
{
this.rh = rh;
}
public String getRhFactor()
{
return rh;
}
}

Patient.java

public class Patient
{
// declare private variables here
public Patient()
{
// add default constructor values here
}
public Patient(String id, int age, String bType, String rhFactor)
{
// add constructor logic here
}
public String getId()
{
// write method code here
}
public void setId(String id)
{
// write method code here
}
public int getAge()
{
// write method code here
}
public void setAge(int age)
{
// write method code here
}
public BloodData getBloodData()
{
// write method code here
}
public void setBloodData(BloodData b)
{
// write method code here
}
}

TestBloodData.java

public class TestBloodData
{
public static void main(String[] args)
{
BloodData b1 = new BloodData();
BloodData b2 = new BloodData("A", "-");
display(b1);
display(b2);
b1.setBloodType("AB");
b1.setRhFactor("-");
display(b1);
}
public static void display(BloodData b)
{
System.out.println("The blood is type " + b.getBloodType() + b.getRhFactor());
}
}

TestPatient.java

public class TestPatient
{
public static void main(String[] args)
{
Patient p1 = new Patient();
Patient p2 = new Patient("1234", 35, "B", "+");
BloodData b2 = new BloodData("A", "-");
display(p1);
display(p2);
p1.setId("3456");
p1.setAge(42);
BloodData b = new BloodData("AB", "-");
p1.setBloodData(b);
display(p1);
}
public static void display(Patient p)
{
BloodData bt = p.getBloodData();
System.out.println("Patient #" + p.getId() + " age: " + + p.getAge() +
"\n The blood is type " + bt.getBloodType() + bt.getRhFactor());
}

}

In: Computer Science

Implement a method that does the following: (a) Create a Map data structure to hold the...

Implement a method that does the following:
(a) Create a Map data structure to hold the associations between player name (key) and team affiliation (value)

(b) Add at least 5 mappings to the map

(c) Print out the current roster of mappings

(d) Assuming some time has passed, change some of the mappings to simulate the players changing their affiliations

(e) Again, print out the current roster of mappings
3. Implement a main method that calls the above methods, demonstrating their use with all applicable printed output

In: Computer Science

Python Create a Python script file called hw3.py. Ex. 1. Write a program that inputs numbers...

Python

Create a Python script file called hw3.py.

Ex. 1. Write a program that inputs numbers from the user until they enter a 0 and computes the product of all these numbers and outputs it.

Hint: use the example from the slides where we compute the sum of a list of numbers, but initialize the variable holding the product to 1 instead of 0.

print("Enter n")
n = int(input())
min = n
while  n != 0:
    if n < min:
        min = n
    print("Enter n")
    n = int(input())
print("The minimum of the list is", min)

In: Computer Science