JAVA
Write a program that will accept user input for an initial deposit and a total amount the user wants to have, and will output the number of years it will take to reach his/her goal.
For the basic program, the user will deposit the initial amount in a new account, and then the account will receive interest, compounded MONTHLY, at a rate of 0.5%.
In: Computer Science
Anna is a young ambitious programmer working for a small company developing software for web based services in the health area, with a focus on support to remote aboriginal communities. To further her career Anna undertakes additional tertiary study, with support from her manager, Brian. This study includes topics covering computer ethics, and issues relating to the impact of ICT on different communities. On her current project, Anna develops a new user interface, which has a strong focus on accessibility for remote communities, especially considering the type of technology likely to be used. She also pays special attention to the use of cultural images in the interface, to avoid those which may be distressing or offensive to aboriginal users. The new system is a great success and Anna’s contribution is recognised by her company, through an Employee of the Month Award. The company also receives a national business award for its contribution to the positive use of ICT in aboriginal communities. Brian takes all of the credit for this, and Anna receives no acknowledgement for her efforts. Source:
ACS Case Studies 2014 Essay
Questions 1. Assess the major ethical issues in this business case.
2. How may the ACS Code of Professional Conduct assist in resolving such ethical implications? Relate to the key values and clauses of the Code of Professional Conduct.
In: Computer Science
This project is of Java OOP.
Comprehensive UML Diagram of Managing customers for Hotel
Management project Mwith complete labelling of attributes,
subclasses.
In: Computer Science
Use this code to answer the following questions:
Object obj;
String str;
Song sng = new Song("Rockstar", 5);
obj = sng; // #7
sng = str; // #8
str = (String) obj; // #9
sng = obj; // #10
1a) Write the start of the class declaration for a node in a linked list (give the name of the class and the instance variables). The name of the node should be SpecialNode. The data in each SpecialNode will include both a String and a Song object.
b) Using the SpecialNode class you created in question #11, write a constructor forSpecialNode that has three parameters and initializes all the SpecialNode instance variables.
c) Write a line of code to instantiate a SpecialNode object to initialize the SpecialNodeinstance variables. Use the constructor you wrote in the previous question.
Song rockstar = new Song("Rockstar", 5);
SpecialNode sn = ___________________________________ ;
In: Computer Science
1. Write a method called isPalindrome that accepts a string as a parameter and returns true if the string is a palindrome otherwise returns false. This method uses a stack and a Queue to test whether the given string parameter is a palindrome [ that is, whether the characters read the same both forward and backward. For example “race car”, and “Are we not drawn onward, to new era.” are Palindromes] They are palindrome sentences, not just a word. 2. If a string is a palindrome, do not print it out, just print a message that the given string is a Palindrome. If a string is not a palindrome, print the letters of the string in reverse order. 3. Your application prompts the user for the input string. 4. You must use a stack and a queue to do this. (You have to figure out how both can be used.) Any solution that does not use a stack and a queue for the palindrome checking and reversing the letters of the words of the sentence will receive a grade of 0.
In: Computer Science
1. Implement a method called count with the following signature:
public int count();
such that the method returns the number of nodes currently contained in the list. The method must compute this number by traversing the entire list.
2. Implement a method called sndLast with the following signature:
public E sndLast();
such that the method returns the data stored at the second-to-last node of the linked list. If the size of the list is less than 2, then the method should return null. Hint: Recall, the last node of the list has its next eld set to null.
3. Implement a method called reverse with the following signature:
public SinglyLinkedList reverse();
such that the method returns a reference to a new linked list, containing the same elements as the current list, except in the reverse order. Page
// SinglyLinkedList.java
package LinkedLists;
public class SinglyLinkedList<E> {
private static class node<E> {
private node<E> next; //
Pointer to the next node in the list.
private E data; //Contains a
reference to the data stored at this node.
public node(E e, node<E> n)
{
next = n;
data = e;
}
public node<E> getNext() {
return next; }
public E getData() { return data;
}
public void setNext(node<E>
n) { next = n; }
}
private node<E> head = null; //Pointer to the
head of the list.
private node<E> tail = null; //Pointer to the
tail of the list.
private int size = 0; //Track the number of nodes in
the list.
public SinglyLinkedList() { }
//Methods begin here//
public int getSize() { return size; }
public boolean isEmpty() { return size == 0; }
public E first() {
if(isEmpty()) {
return
null;
}
return head.getData();
}
public E last() {
if(isEmpty()) {
return
null;
}
return tail.getData();
}
public void addFirst(E e) {
node<E> n = new
node<>(e,head);
head = n;
if(isEmpty()) {
tail = n;
}
size++}
}
public void addLast(E e) {
node<E> n = new
node<>(e, null);
if(isEmpty()) {
head = n;
} else {
tail.setNext(n);
}
tail = n;
size++;
}
public E removeFirst() {
// Check for the empty list.
if(isEmpty()) {
return
null;
}
E val = head.getData();
head = head.getNext();
size--;
if(size == 0) {
tail =
null;
}
return val;
}
// WARNING: print method is not efficient in
general.
public void print() {
node<E> walk = head;
int counter = 0;
while(walk != null) {
System.out.println("Count = " + (counter+1) + " " +
walk.getData());
walk =
walk.getNext();
counter++;
}
}
// WARNING: find is not efficient in general.
public boolean find(E x) {
node<E> walk = head;
while(walk != null) {
if(walk.getData().equals(x)) {
return true;
}
walk =
walk.getNext();
}
return false;
}
// Equality for linked lists given by
definition.
public boolean equals(Object o) { // accept ANY
parameter value
if( o == null) { return false;
{
if(getClass() != o.getClass()) {
return false; } // Return false if types are not the same
SinglyLinkedList y =
(SinglyLinkedList) o;
if(size != y.getSize()) { return
false; }
node walkA = head; // Start of THIS
list.
node walkB = y.head;
while(walkA != null) {
if(!walkA.getData().equals(walkB.getData())) { return false;
}
walkA =
walkA.getNext();
walkB =
walkB.getNext();
}
return true;
}
public SinglyLinkedList<E> clone() throws
CloneNotSupportedException {
SinglyLinkedList<E> other =
(SinglyLinkedList<E>) super.clone();
if(size > 0) { //Build
independent chain of nodes.
}
}
}
//SinglyLinkedListTest.java
package applications;
import LinkedLists.SinglyLinkedList;
import java.util.Random;
public class SinglyLinkedListTest {
public static class Record {
private int id;
private String name;
private double grade;
public Record(int i, String n,
double g) {
id = i;
name = n;
grade = g;
}
public String getName() { return
name; }
public double getGrade() { return
grade; }
public String toString() {return
name + " " + grade;
}
}
public static void main(String[] args) {
SinglyLinkedList<Record> L4 =
new SinglyLinkedList<>();
L4.addLast(new Record(0, "name",
4.0));
L4.addLast(new Record(1, "name2",
3.6));
//L4.print();
SinglyLinkedList<Integer> L1
= new SinglyLinkedList<>();
L1.addLast(35); // 35 is auto-boxed
to type Integer
L1.addLast(67);
L1.addLast(99);
L1.addLast(202);
L1.addLast(11);
L1.addLast(302);
//L1.print();
SinglyLinkedList<String> L2 =
new SinglyLinkedList<>();
L2.addLast("hello");
L2.addLast("world");
L2.addLast("java");
//L2.print();
SinglyLinkedList<Double> L3 =
new SinglyLinkedList<>();
L3.addLast(3.14);
L3.addLast(3.1415);
L3.addFirst(2.7);
//L3.print();
int size = 100;
SinglyLinkedList<Integer> L5
= new SinglyLinkedList<>();
Random r = new Random();
System.out.println("Starting random
numbers!");
for(int i = 0; i < size; i++)
{
L5.addLast(r.nextInt());
}
System.out.println("End of list
generation!");
//L5.print();
L5.addLast(r.nextInt());
//L5.print();
System.out.println("End of insert
operation!");
L5.addLast(0);
System.out.println(L5.find(0));
System.out.println(L2.equals(L5));
SinglyLinkedList<String> L6 =
new SinglyLinkedList<>();
L6.addLast("hello");
L6.addLast("world");
L6.addLast("java");
System.out.println(L2 == L6);
System.out.println(L2.equals(L6));
}
}
In: Computer Science
An equilateral triangle is a triangle whose sides are equal. You are to write a class called Triangle, using filenames triangle.h and triangle.cpp, that will allow the creation and handling of equilateral triangles, whose sides are integers in the range 1-39.
Details:
1. The single constructor for the Triangle class should have 3
parameters: an integer size (required), which is the length of a
side; a border character (optional, with a default of '#'); and a
fill character (optional, with a default of '*'). If the size
provided is less than 1, set the size to 1. If the size provided is
greater than 39, set the size to 39. The class will need to provide
internal storage for any member data that must be kept track
of.
2. There should be member functions GetSize,
Perimeter, and Area, which will
return the size of a side, the perimeter of the triangle, and the
area of the triangle, respectively. The first 2 should return
integer results. The Area function should return its result as a
double.
3. There should be member functions Grow and
Shrink, which will increase or decrease
(respectively) the size of the triangle's sides by 1, unless this
would cause the size to go out of bounds (out of the 1-39 range);
in the latter case, Grow and Shrink should make no change to the
size
4. There should be member functions SetBorder and SetFill, which each allow a new border or fill character (respectively) to be passed in as a parameter. There is a chart of ASCII characters in an appendix of the textbook. The characters that should be allowed for the border or fill characters are any characters from the '!' (ascii 33) up through the '~' (ascii 126). If an attempt is made to set the border or fill characters to anything outisde the allowable range, the function should set the border or fill back to its original default (the ones listed for the constructor -- the border default is '#' and the fill default is '*').
5. There should be a member function called Draw that will display a picture of the triangle on the screen. You may assume that the cursor is already at the beginning of a line when the function begins, and you should make sure that you leave the cursor on the line following the picture afterwards (i.e. print a newline after the last line of the triangle). Use the border character to draw the border of the triangle, and use the fill character to draw the internal characters. Separate the characters on a line in the picture by a single space to make the triangle look more proportional (to approximate the look of an equilateral triangle). You may not use formatting functions like setw to draw the triangle. This must be handled with loops. (You will only print out the newline, spaces, the border character, and maybe the fill character on any given line).
6. Provide a member function called Summary that displays all information about a triangle: its size, perimeter, area, and a picture of what it looks like. When displaying the area (decimal data), always show exactly 2 decimal places. Your output should be in the exact same format as mine (seen in the linked sample run below)
t1 has size = 1 units.
#
t2 has size = 7 units.
^
^ ^
^ * ^
^ * * ^
^ * * * ^
^ * * * * ^
^ ^ ^ ^ ^ ^ ^
t3 has size = 12 units.
X
X X
X O X
X O O X
X O O O X
X O O O O X
X O O O O O X
X O O O O O O X
X O O O O O O O X
X O O O O O O O O X
X O O O O O O O O O X
X X X X X X X X X X X X
t4 has size = 39 units.
$
$ $
$ o $
$ o o $
$ o o o $
$ o o o o $
$ o o o o o $
$ o o o o o o $
$ o o o o o o o $
$ o o o o o o o o $
$ o o o o o o o o o $
$ o o o o o o o o o o $
$ o o o o o o o o o o o $
$ o o o o o o o o o o o o $
$ o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
t1 now has size = 1 units.
t2 now has size = 6 units.
t3 now has size = 13 units.
t4 now has size = 39 units.
t2 has perimeter = 18 units.
t3 has perimeter = 39 units.
t2 has area = 15.5885 square units.
t3 has area = 73.1791 square units.
#
t1 grows:
#
# #
... and grows:
#
# #
# # #
t1 now has size = 6 units.
^
^ ^
^ * ^
^ * * ^
^ * * * ^
^ ^ ^ ^ ^ ^
t2 now looks like:
@
@ @
@ - @
@ - - @
@ - - - @
@ @ @ @ @ @
t2 now looks like:
#
# #
# * #
# * * #
# * * * #
# # # # # #
Here is a summary on t3:
Size of triangle's side = 13 units.
Perimeter of triangle = 39 units.
Area of triangle = 73.18 units.
Triangle looks like:
X
X X
X O X
X O O X
X O O O X
X O O O O X
X O O O O O X
X O O O O O O X
X O O O O O O O X
X O O O O O O O O X
X O O O O O O O O O X
X O O O O O O O O O O X
X X X X X X X X X X X X X
7. I am providing a sample driver program (called driver.cpp) that uses objects of type Triangle and illustrates sample usage of the member functions.
#include <iostream>
#include <iomanip>
#include "triangle.h"
using namespace std;
int main()
{
// create some Triangles
Triangle t1( -5 ), t2( 7, '^' ), t3( 12, 'X', 'O' ), t4( 50 , '$' , 'o');
// display original Triangles
cout << "t1 has size = " << t1.GetSize() << " units.\n";
t1.Draw();
cout << "\nt2 has size = " << t2.GetSize() << " units.\n";
t2.Draw();
cout << "\nt3 has size = " << t3.GetSize() << " units.\n";
t3.Draw();
cout << "\nt4 has size = " << t4.GetSize() << " units.\n";
t4.Draw();
cout << '\n';
t1.Shrink(); // demonstrate shrink
t2.Shrink();
t3.Grow(); // and grow
t4.Grow();
cout << "t1 now has size = " << t1.GetSize() << " units.\n";
cout << "t2 now has size = " << t2.GetSize() << " units.\n";
cout << "t3 now has size = " << t3.GetSize() << " units.\n";
cout << "t4 now has size = " << t4.GetSize() << " units.\n";
// demonstrate perimeter
cout << "t2 has perimeter = " << t2.Perimeter() << " units.\n";
cout << "t3 has perimeter = " << t3.Perimeter() << " units.\n";
// and area
cout << "t2 has area = " << t2.Area() << " square units.\n\n";
cout << "t3 has area = " << t3.Area() << " square units.\n\n";
t1.Draw();
t1.Grow(); // show that fill character
cout << "t1 grows:\n"; // appears only when size
t1.Draw(); // is at least 3
t1.Grow();
cout << "... and grows:\n";
t1.Draw();
cout << '\n';
t1 = t2; // demonstrate the default overload of the
// assignment operator
cout << "t1 now has size = " << t1.GetSize() << " units.\n";
t1.Draw();
// demonstrate the changing of border and fill characters
t2.SetBorder('@');
t2.SetFill('-');
cout << "t2 now looks like:\n";
t2.Draw();
cout << '\n';
t2.SetBorder('\n'); // illegal border
t2.SetFill('\a'); // illegal fill
cout << "t2 now looks like:\n";
t2.Draw();
cout << '\n';
cout << "\nHere is a summary on t3:\n"; // demonstrate summary
t3.Summary();
return 0;
}
Your class declaration and definition files must work with my
main program, as-is (do not change my program to make your code
work!). You are encouraged to write your own driver routines to
further test the functionality of your class, as well. Most
questions about the required behavior of the class can be
determined by carefully examining my driver program and the sample
execution. Keep in mind, this is just a
sample. Your class must meet the requirements
listed above in the specification -- not just
satisfy this driver program. (For instance, I
haven't tested every illegal fill character in
this driver program -- I've just shown a sample). Your class will
be tested with a larger set of calls than this driver program
represents.
In: Computer Science
How would Hyper-V be installed on a Windows Server Core installation?
In: Computer Science
The chapter metiones acitve-passive clustering configurations. Define what that is, and why would you use it.
In: Computer Science
c++120
Holideals at the Movies!
We have special movie tickets on holidays! Prices are discounted when you buy a pair of tickets.
Create a program for the HoliDeals event that computes the subtotal for a pair of tickets. The program should ask the the ages of the first and second guests to compute the price.
There are different pricing structures based on the guests' age.
Children tickets cost $10 (age below 13)
Young Adult tickets cost $13 (age below 21)
Adult tickets cost $15 (age below 65)
Senior tickets cost $10 (age 65 and over)
To simplify the problem, let's assume that parents/guardians will always accompany pairs of children who will watch a movie.
The pricing structure should be displayed to the user. Please see the sample output below to guide the design of your program.
Welcome to HoliDeals at the Movies! Tickets tonight can only be bought in pairs. Here are our movie ticket deals: Children - $10.00 Young Adults - $13.00 Adults - $15.00 Seniors - $10.00 Please enter the age of the person for the first guest: 15 Please enter the age of the person for the second guest: 16 The Subtotal for the ticket cost is: $26.00.
Q2:
Salary Calculator
Create a program that computes the salary based on an employee's hourly wage and hours worked. Use the following formulas:
Less than or equal to 40 hours worked
hourly wage * hours worked
Over 40, but less than or equal to 65 hours worked
(hourly wage * 40) + (hours worked - 40) * (hourly wage * 1.5)
Over 65 hours worked
(hourly wage * 40) + (hourly wage * 1.5) * 25 + (hours worked - 65) * hourly wage * 2
Please see the sample output below to guide the design of your program.
Hourly wage: 12 Hours worked: 20 Total Salary Owed: $240.00
In: Computer Science
Describe the components of Hyper-V and the process for installing it.
In: Computer Science
Define predicates and prove the following using the appropriate rules of inference:
All action movies are popular. There is an action movie filmed in Iowa. Therefore, some popular movie was filmed in Iowa.
In: Computer Science
In python,
Modify your mapper to count the number of occurrences of each character (including punctuation marks) in the file.
Practice the given tasks in Jupyter notebook first before running them on AWS. If your program fails, check out stderr log file for information about the error.
import sys
sys.path.append('.')
for line in sys.stdin:
line = line.strip() #trim spaces from beginning and
end
keys = line.split() #split line by space
for key in keys:
value = 1
print ("%s\t%d" % (key,value)) #for
each word generate 'word TAB 1' line
In: Computer Science
In python,
1- Modify your mapper to count words after removing punctuation marks during mapping.
Practice the given tasks in Jupyter notebook first before running them on AWS. If your program fails, check out stderr log file for information about the error.
import sys
sys.path.append('.')
for line in sys.stdin:
line = line.strip() #trim spaces from beginning and
end
keys = line.split() #split line by space
for key in keys:
value = 1
print ("%s\t%d" % (key,value)) #for
each word generate 'word TAB 1' line
In: Computer Science
Working with strings can lead to various security flaws and errors in software development using the C++ language. What are the common string manipulation errors that can be encountered? How can these errors be resolved and/or limited? What tips can be utilized to identify security vulnerabilities related to strings in C++? Be sure to provide an appropriate source code example to illustrate your points.
In: Computer Science