In C++ Programming Language:
1a. Declare a class, namely ReverseUniverse, that contains three public member functions. Please see Q2 and Q3 for the name of the second and third function. (5 points)
Write a function string reverseString that reverses a string (first member function). It takes a string parameter and returns its reversed version. (10 points)
1b. In the class ReverseUniverse in Q1. Write a function vector reverseVector that reverses a vector (second member function). It takes a double vector parameter and returns its reversed version.
1b. In the class ReverseUniverse in Q1. Write a function int reverseInt that reverses an integer (third member function). It takes an int parameter and returns its reversed version.
NOTE: 1. You are NOT allowed to: i. convert int to string, ii. use vector or array. 2. Feel free to define helper member functions if needed.
In: Computer Science
QUESTION 3: SYSTEM CONFIGURATION [5+5 = 10 Marks]
a) Be aware of the options available for setting password
requirements under Windows, as well as the options available under
Linux. Discuss good and bad practices for setting passwords and why
administrators may enforce logon hours and logon locations for
Windows users. [5 Marks]
b) Explain what Multi Factor Authentication (MFA) is – a method of
authentication which requires a user to supply two or more types of
authentication drawn from these credential categories:
1. Knowledge – what the user knows, such as a username or
password
2. Possession – what the user has, such as a smart card or
key
3. Inherence – what the user is; a unique biometric trait, such as
a fingerprint [5 Marks]
In: Computer Science
Data Structures and Algorithms Activity
Requirement: Implement a queue using an array as its underline data structure. Your queue should fully implemnted the following methods: first, push_back (enqueue), pop_front (dequeue), size, and isEmpty. Make sure to include a driver to test your newly implemented queue
In: Computer Science
CompSci 251: Assignment 3
Due 2/20, 2017 10:00am
Topics Covered: Instance variables and methods; using a driver class
1 Introduction
This assignment will have you implement your first real Java class using instance variables(state) and meth- ods(behaviour). It will also probably be the first time that you write a program with a driver class.
2 Income tax computation
Most Americans (not just Americans, really!) complain about filing their income taxes. Some people dont think they should pay at all. Others dont like some of things that taxes are used for. Many people find the forms and the concepts confusing (they are). But the basic computation for income tax is not really that complicated. Its really the many special rules that make it hard to understand.
For this assignment, we’ll write a class that does the basic income tax computation for a “typical” household. The steps (for our simplified situation) are:
Compute Adjusted Gross Income (AGI) where AGI = wages + interestIncome.
Compute total deductions, where deductions = stateTax + propertyTax.
Compute taxable income, where taxableIncome = AGI - deductions.
Compute tax using this table. You have to know whether the household is single or married to choose the correct column.
Tax rate |
Single |
Married filing jointl |
10% |
$0 - $9,275 |
$0 to $18,550 |
15% |
$9,276 - $37,650 |
$18,551-$75,300 |
25% |
$37,651 - $91,150 |
$75,301-$151,900 |
28% |
$91,151 - $190,150 |
$151,901-$231,450 |
33% |
$190,151 - $413,350 |
$231,451-$413,350 |
35% |
$413,351 - $415,050 |
$413,351-$466,950 |
39.6% |
≥ $415, 051 |
≥ $466, 951 |
Your class will also compute the overall tax rate, which is just total tax divided by AGI. For most people, this number is much lower than the rate on their bracket.
1
2.1 The IncomeTax and IncomeTaxDriver class
Here is the UML class diagram for the IncomeTax class.
IncomeTax |
- name: String // name of person whose tax is computed - married
: boolean // true if married, false if single - stateTax: integer |
+ getName() : String + getAGI() : integer |
The instance variables were explained above. Each one has a mutator/setter and an accessor/getter. The mutators for the integer variables must check the input value to ensure that it is non-negative. If the value is negative, they should leave the variable unchanged. You may not add additional instance variables. Any values that you need can be computed from the instance variables. The remaining methods compute values used in the tax computation. getIncomeTax() and getOverallRate() are the only ones that return double values and they need to because of the nature of the computation. The income tax computation looks complicated, but it really is not.
First, you figure out which top tax bracket the person falls into. For that tax bracket, the person will pay 10/15/25/28/33/35/39.6 percent of their income above the minimum value for the bracket, plus the total tax they owe from all the lower brackets. The second part of this formula is actually a fixed value for each bracket (once you know whether the person is married or single).
You can do this with a big if-else statement or there is a slick way to put the relevant values in arrays and use a loop to do the computation. The IncomeTaxDriver class is only required to have a main() method, though you can make other methods if you wish. It creates two IncomeTax objects, prompting the user to enter the five values needed to initialize the objects and setting them using the mutators/setters. It prints a summary of the income tax computation for each object and states which person is paying the most tax(Total Income Tax).
2.2 Requirements
• All instance variables must be private
2
In the IncomeTax class, no methods do any input or output.
You must use the class and method names that we specify above.
Your classes must follow the description in the previous section.
You should have two other helper methods in the driver class. One to read in the values for the IncomeTax object (private static IncomeTax initIncomeTax(Scanner stdIn)) and another to print the data about an IncomeTax object (private static void printIncomeTax(IncomeTax it)).
Only the total incomeTax and the overall tax rate values need to be printed with fractional parts. Its a good idea to use printf() to control the number of digits to the right of the decimal place.
2.3 Example how to use the Table
Joe is single and has a Taxable Income of $57,250. However, his income tax is not 25% of $57250, which would be $14312.50.
Instead, there are three steps:
He pays 10% tax on the ”first $9,275” of his income: ( .10 * 9275 )
= $927.50
He pays 15% tax on the additional income, up to $37,650: ( .15 *
(37650 -9275) ) = $4256.25 Finally, he also pays 25% tax on his
income over $37,650: ( .25 * (57650 - 37650) ) = $4900.00 His total
tax is the sum of these three numbers:$927.50 + $4256.25 + $4900.00
= $10083.75
2.4 Sample Output
Welcome to the Income Tax Program! Please enter values for person #1 income tax profile:
Enter person’s name: Alex Is Alex married (true or false):true Enter wages of Alex: 22000 Enter interest income of Alex: 0 Enter state taxes paid by Alex: 1000 Enter property taxes paid by Alex: 300
Please enter values for person #2 income tax profile:
Enter person’s name: Victor Is Victor married (true or false):false Enter wages of Victor: 50000 Enter interest income of Victor: 0 Enter state taxes paid by Victor: 5000 Enter property taxes paid by Victor: 1000
Income Tax Profile for Alex
Marital Status: true Wages: $22000 Interest Income: $0 Adjusted Gross Income: $22000 State Tax Paid: $1000 Property Tax Paid: $300
Total Deductions: $1300 Taxable Income: $20700 Total Income Tax: $2177.50
3
Overall Tax Rate: 9.90%
Income Tax Profile for Victor
Marital Status: false Wages: $50000 Interest Income: $0 Adjusted Gross Income: $50000 State Tax Paid: $5000 Property Tax Paid: $1000 Total Deductions: $6000 Taxable Income: $44000
Total Income Tax: $6771.25 Overall Tax Rate: 13.54%
Victor will pay more income tax than Alex Goodbye!
In: Computer Science
1- How can database systems improve data quality and data integrity?
2- Discuss database constraints: Primary key, check, and referential integrity constraints? Give an example for each.
In: Computer Science
Write Java code for each of the following problem
a. Two players, a and b, try to guess the cost of an item.
Whoever gets closest to the price without going over is the winner.
Return the value of the best bid. If both players guessed too high,
return -1.
example:
closestGuess(97, 91, 100) → 97
closestGuess(3, 51, 50) → 3
closestGuess(12, 11, 10) → -1
b. Given a non-empty string, return true if at least half of the
characters in the string are the lowercase letter z.
example:
zMajority("az") → true
zMajority("zabzc") → false
zMajority("w") → false
c. Given 4 numbers, return the value of the second largest
number. Note that if two or more numbers are tied for largest, then
the second largest value is also the largest value.
example:
secondLargest(1, 2, 3, 4) → 3
secondLargest(3, 2, 1, 4) → 3
secondLargest(5, 7, 5, 9) → 7
In: Computer Science
1- Use LinkList. Write removeLast(n). Delete the last occurrence of an item from a linked list. So if the item is 7 and the list is [1,3,7,4,7,3,7,2], the result is [1,3,7,4,7,3,2]
2- Use LinkList. Write removeAll(int
n). Deletes all occurrences of an item n from a linked
list. So if the item is 7 and the list1 is [1,3,7,4,7,3,2] , then
list1.removeAll(7) then list1 becomes [1,3,4,3,2].
Demonstrate by displaying the list contents before
and after calling the above methods. Eg:
lst1
[1,3,7,4,7,3,7,2]
lst1.removelast(7)
[1,3,7,4,7,3,2]
lst1.removeall(7)
[1,3,4,3,2]
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// linkList.java
// demonstrates linked list
// to run this program: C>java LinkListApp
////////////////////////////////////////////////////////////////
class Link
{
public int iData; // data item
public double dData; // data item
public Link next; // next link in list
//
-------------------------------------------------------------
public Link(int id, double dd) // constructor
{
iData = id; // initialize data
dData = dd; // ('next' is automatically
} // set to null)
//
-------------------------------------------------------------
public void displayLink() // display ourself
{
System.out.print("{" + iData + ", " + dData + "} ");
}
} // end class Link
////////////////////////////////////////////////////////////////
class LinkList
{
private Link first; // ref to first link on list
//
-------------------------------------------------------------
public LinkList() // constructor
{
first = null; // no links on list yet
}
//
-------------------------------------------------------------
public boolean isEmpty() // true if list is empty
{
return (first==null);
}
//
-------------------------------------------------------------
// insert at start of list
public void insertFirst(int id, double dd)
{ // make new link
Link newLink = new Link(id, dd);
newLink.next = first; // newLink --> old first
first = newLink; // first --> newLink
}
//
-------------------------------------------------------------
public Link deleteFirst() // delete first item
{ // (assumes list not empty)
Link temp = first; // save reference to link
first = first.next; // delete it: first-->old next
return temp; // return deleted link
}
//
-------------------------------------------------------------
public void displayList()
{
System.out.print("List (first-->last): ");
Link current = first; // start at beginning of list
while(current != null) // until end of list,
{
current.displayLink(); // print data
current = current.next; // move to next link
}
System.out.println("");
}
//
-------------------------------------------------------------
} // end class LinkList
////////////////////////////////////////////////////////////////
class LinkListApp
{
public static void main(String[] args)
{
LinkList theList = new LinkList(); // make new list
theList.insertFirst(22, 2.99); // insert four items
theList.insertFirst(44, 4.99);
theList.insertFirst(66, 6.99);
theList.insertFirst(88, 8.99);
theList.displayList(); // display list
while( !theList.isEmpty() ) // until it's empty,
{
Link aLink = theList.deleteFirst(); // delete link
System.out.print("Deleted "); // display it
aLink.displayLink();
System.out.println("");
}
theList.displayList(); // display list
} // end main()
} // end class LinkListApp
////////////////////////////////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Class LinkListAppTest.Java is just for testing. Please do not edit. class LinkListAppTest { public static void main(String[] args) // NEW MAIN { LinkList lst1 = new LinkList(); // Since the available add method is a pre-add to the first we go in reverse order lst1.insertFirst(8,2); // last digit lst1.insertFirst(7,7); // entering next to last lst1.insertFirst(6,3); // until we get to the the beginning lst1.insertFirst(5,7); lst1.insertFirst(4,4); lst1.insertFirst(3,7); lst1.insertFirst(2,3); lst1.insertFirst(1,1); System.out.println("lst1"); // list the name of the linked-list lst1.displayList(); // pre-print the entered list unaltered System.out.println("lst1.removeLast(7)"); // list the action to be taken lst1.removeLast(7); // complete the action to remove the last dData == 7; lst1.displayList(); // print list post removal of the last dData == 7; System.out.println("1st1.removeAll(7)"); // list the action to be taken lst1.removeAll(7); // complete the action to remove all remaining dData == 7; lst1.displayList(); // print list post removal of all remaining dData == 7; } // end main() } // end class
In: Computer Science
In: Computer Science
prove or disprove
In: Computer Science
Code needed in C++
(nOT IN STEP BY STEP EITHER)
Write a recursive function that computes the sum of the digits in an integer. Use the following function header:
int sumDigits(int n)
For example, sumDigits(234) returns 2 + 3 + 4 = 9.
Write a test program that prompts the user to enter an integer and displays its sum.
In: Computer Science
what are Two major computer processor manufacturers are Intel and AMD. Compare characteristics and purposes of Intel and AMD processors used for personal computers.
In: Computer Science
QUESTION : Read from a file that contains a paragraph of words. Put all the words in an array, put the valid words (words that have only letters) in a second array, and put the invalid words in a third array. Sort the array of valid words using Selection Sort. Create a GUI to display the arrays using a GridLayout with one row and three columns.
The input file Each line of the input file will contain a sentence with words separated by one space. Read a line from the file and use a StringTokenizer to extract the words from the line. An example of the input file would be:
Mary had a little lamb Whose fl33ce was white as sn0w.
I need a JAVA CODE for this
Please have comments for the code, im simply trying to understand this question.
In: Computer Science
In: Computer Science
Let's get some practice with maps! Create a public class CountLetters providing a single static method countLetters. countLetters accepts an array of Strings and returns a Map from Strings to Integers. (You can reject null arguments using assert.) The map should contain counts of the passed Strings based on their first letter. For example, provided the array {"test", "me", "testing"} your Map should be {"t": 2, "m": 1}. You should ignore empty Strings and not include any zero counts. As a reminder, you can retrieve the first character of a String as a char using charAt. You may find substring more helpful. You may also want to examine the Map getOrDefault method. You can use any Map implementation in java.util.
In: Computer Science
Firewall and IDS: What’s the difference between IDS and Firewall? What is promiscuous mode in IDS? What is in-line mode in IDS? When is appropriate to use one or the other in your network?
Visit some firewall & IDS vendors’ site such as Palo Alto Networks, Check Point, Cisco, etc., and select product(s) suitable for your project. Justify your selection.
In: Computer Science