JAVA PROGRAMMING
source code using appropriate programming style (e.g., descriptive variable names, indenting, comments, etc.).
1. Using the remainder (%) operator, write a program that inputs an integer and displays if the number is even or odd.
B. Write the same program using some other technique without using the remainder (%) operator.
In: Computer Science
ArrayStack:
package stacks;
public class ArrayStack<E> implements Stack<E>
{
public static final int CAPACITY = 1000; // Default
stack capacity.
private E[] data; //Generic array for stack
storage.
private int top = -1; //Index to top of stack./***
Constructors ***/
public ArrayStack()
{
this(CAPACITY);
}
//Default constructor
public ArrayStack(int capacity)
{
// Constructor that takes
intparameter.
data = (E[]) new
Object[capacity];
}
/*** Required methods from interface ***/
public int size()
{
return (top + 1);
}
public boolean isEmpty()
{
return (top == -1);
}
public void push(E e) throws
IllegalStateException
{
if(size() == data.length)
{
throw new
IllegalStateException("Stack is full!");
}
data[++top] = e;
}
public E top()
{
if(isEmpty())
{
return
null;
}
return data[top];
}
public E pop()
{
if(isEmpty())
{
return
null;
}
E answer = data[top];
data[top] = null;
top--;
return answer; }
}
Recall: In the array based implementation of the stack data type, the stack has a limited capacity due to the fact that the length of the underlying array cannot be changed. In this implementation, when a push operation is called on a full stack then an error is returned and the operation fails. There are certain applications where this is not useful. For example, a stack is often used to implement the \undo" feature of text editors, or the \back" button in a web browser. In these cases, it makes sense to remove the oldest element in the stack to make room for new elements. A similar data structure, called a leaky stack is designed to handle the above type of situation in a dierent manner. A leaky stack is implemented with an array as its underlying storage. When a push operation is performed on a full leaky stack, however, the oldest element in the stack is \leaked" or removed out the bottom to make room for the new element being pushed. In every other case, a leaky stack behaves the same as a normal stack. Write an implementation of the leaky stack data structure. Your class should be generic and implement the following public methods: push, pop, size, and isEmpty. Your class must also contain at least two constructors: one where the user does not specify a capacity and a default capacity of 1000 is used, and one where the user does specify a capacity.
Hint: The following is a skeleton of the class to get started (You will have to fill in the missing implementations of the abstract methods from the Stack interface):
public class LeakyStack implements Stack {
public static final int DEFAULT = 1000;
private E[] stack; private int size = 0;
private int stackTop = -1;
public LeakyStack()
{
this(DEFAULT);
}
public LeakyStack(int c);
public void push(E e);
public E pop();
public boolean isEmpty();
public int size(); }
In: Computer Science
Create a class called Cuboid in a file called
cuboid.py. The constructor should take parameters that sets a
private variable for each side of the cuboid. Overload the
following operators: +, -, <, >, ==, len(), and str(). Return
a cuboid with the appropriate volume for the arithmetic operators.
Use the volume of the cuboid to determine the output of the
overloaded comparison operators. Use the surface area of the cuboid
to calculate the result of len(). For str() return a string that
displays the side lengths, volume, and surface area. Let the user
enter values used to create two Cuboid objects. Then print out all
results of the overloaded operators (using the operator, not
calling the dunder method). Create a file called assn14-task1.py
that contains a main() function to run your program. It is fine for
the program to only run once then end. You DO NOT need to create
loop asking use if they want to "Play Again".
Note: The most complicated part of this is the + and
-. Remember that arithmetic operators should return the same type
as the operands, so a cuboid should be returned. The returned
cuboid is based on the volume, which means you'll need to figure
out what the side lengths should be. They can be anything
valid.
Rubric
5 pts: All operators overloaded
properly
5 pts: Print results using the overloaded
operators
5 pts: Proper output
Note: No software dev plan or UML
required
In: Computer Science
To gain approval for a new network design, upgrade, or
enhancement, you will have to present your network design, project
costs, and project plan to all the stakeholders, which includes
senior leadership. Through the last five weeks, you have created
your network design, and now it is time to promote that design and
get approval for this project.
During the course, you have designed a network to meet
the specific needs of your client. Now, it is time to showcase that
design. When you are dealing with a client, communication plays a
key role in your professional success. You may have a very
effective design, but you may not still be able to achieve maximum
client satisfaction if you cannot communicate your design to your
client properly.
For this part of the Final Project, review this week’s resources.
Give special attention to the resource “Oral Presentation and
PowerPoint.” Remember the following when developing the
presentation:
Keep the presentation short and simple.
Do not load the presentation down with paragraphs of
text. Keep it simple and use images.
Make sure that the presentation is informative and
that it uses facts and figures.
When presenting to a non-technical audience, try to
refrain from making it too technical. Remember that the
presentation would normally be presented to leadership who most
likely will not understand the technical information.
Explain clearly to the leadership the costs and
benefits that the network will offer to the organization.
Presentation (6–10 slides):
Create a PowerPoint presentation with a narrative overlay. The
overall slide show must be in the 8–10 minute range. The
presentation must be engaging, organized, easy to understand,
appropriate for the intended audience, and complete the
following:
Introduce the presentation
Describe the network in layman’s terms
Identify how the network meets each specific client
need
Describe how the network ensures security
Provide technical details with which the client needs
to be familiar
Instruct the client on any technical needs for
supporting the network
Summarize the presentation
Note: To complete this presentation, you must have
Microsoft PowerPoint 2007 or a higher version loaded on your
computer. In addition, you must have a microphone to record your
oral narrative to accompany the presentation.
Once the PowerPoint slides are complete, you have created a written
copy of the narrative, and you have tested the narrative to be sure
it is the proper overall length (time), you will embed the oral
narrative into the file. To embed the narrative, complete the
following steps.
Beginning with the first slide:
Select the Slide Show Tab—Record Narration—Set microphone level.
Talk into your microphone to make sure it is working
properly.
Click OK—Begin your narrative for the first
slide.
Advance to the next slide (left click)—Be sure you are
done speaking before you left click.
Record the narrative for the second slide.
Continue advancing through the slides and recording
your narrative.
After the last slide, you will be asked if you want to
save the slide timings—Select SAVE.
Now start your slide show. The show will progress at
the pace you set while creating the narrative for each
slide.
If you need to redo the recording, simply go back to
the first slide. Then, select the Slide Show Tab and re-record your
narrative, or you may choose to re-record just one slide at a
time.
REPEAT steps 1–8 until you are satisfied with the
presentation and your slide show is completed in 6–10
minutes.
Save the PowerPoint presentation with embedded narrative.
Submit your Final Project Part 5 through uploading your file
(saving it according to the filenaming convention specified in this
Assignment’s submission link) by Day 5.
In: Computer Science
Project Name: AWS: EC2 + EBS + Elastic IP
Technology: Cloud Computing
Market: Delivery for Traditional SME with Scale for Growth
Student:
Directions: Configure infrastructure on AWS as detailed below. Completely document your process as outlined. Your documentation / report should be approximately 2 pages of relevant detail that would allow a user to rebuild your design / configuration from scratch.
___________________________________________________________________
Technologies:
AWS: EC2 (Linux VM Instance) + EBS (Persistent Disk) + Elastic IP ("Static" IP for Instance)
Intended Services to Provision:
Linux Server (alternately a Windows Server)
Web Server (nginx, Apache, or IIS)
Static IP
Design:
Your goal is to document the process of setting up a server (on EC2) running nginx (or Apache, IIS) with a static IP on AWS (using the technologies mentioned above).
Important Note:
At this stage in the course we are beginning to architect, configure, and deploy real services in the public cloud (specifically AWS). When you are beginning designing and deploying services, documentation can be of great help as replicating exact configurations can at times be challenging. Note: When we do not replicate a configuration exactly, we can be creating security issues (assuming we had a “secure” or robust design initially). Another reason to develop good documentation is that it gives a good idea of what should be happening with systems and it can be reviewed and refined over time so that the quality of your designs and configurations increases as you practice.
Questions to Answer:
What is the purpose of EBS?
Does EBS persist after you delete a VM instance?
Can you reuse an EBS in a new VM instance?
What purpose does an Elastic IP serve?
How could an Elastic IP help you cope with upgrades?
As an organization grows, what are some aspects to consider with regard to EC2 Instances, EBS, and Elastic IPs if any (i.e. aspects to consider: architectural, performance, cost, etc.)?
Documentation:
[Include your documentation below]
Deliverable(s):
Use this document as a base and include your ideas here. Submit and upload to Canvas in the assignment area for this project.
Remember that the better the quality of your documentation, the greater the likelihood that you can reproduce a configuration for deploying a production system or rebuilding your production infrastructure after a disaster.
*** Note: Be sure to utilize Free Tier eligible or a low cost option of your choice. After your workload has been designed, deployed, tested, and documented, be sure to delete, decommission instances so as to not be continually charged for services.
In: Computer Science
Consider which layer of the OSI-model is the most appropriate
for the
following functions and devices.
(a) Routing:
(b) SSH-connection for remote use:
(c) Ethernet-media repeater:
(d) Ethernet-switch:
(e) SNMP-based network management agent running in Ethernet
switch:
(f) Error Detection:
(g) Fiber cable:
In: Computer Science
While Base64 is a weak encryption standard it is still used to provide a basic means of encryption for email servers. Answer the following questions and provide a discussion about the Base64 Encryption Standard. Remember the initial posting is 100 words or more, and the replies are 60 words or more.
What is Base64?
Name two Services that use Base64?
Why is Base64 still used?
In: Computer Science
(a) How are rules for lexical analysis written? (b) What are these rules used for?
In: Computer Science
1.Why is important to understand dynamic multi-dimension arrays as “arrays of arrays?”
a.Each dimension requires another “pointer layer” which we have to build as arrays of pointers which in turn possibly point to arrays of pointers which eventually point to an array of the data type. Each array is allocated ‘where it fits’ at the time of creation, each of these arrays can be uniquely sized as well.
b.It just helps us organize the data in our head, in reality all the information is sequential anyway
c.Each dynamically allocated array is placed in memory ‘where it fits’ at the time of creation, meaning each pointer points to a single array of the data type.
d.none of these
.
2.When passing by pointer ... the pointer itself is passed by value. The value in this method is that we can use the pointer to make changes in memory.
a.true
b.false
.
3.Which of the following describes Passing by Reference?
a. The actual variable memory is passed into the function and any activity done to the parameter is reflected outside the function as well.
b.The address is passed through and needs to be de-referenced to work with the value contained within. Activity done to the de-referenced value is reflected outside the function. NULL is a valid value to pass and should be handled.
c.The value is passed in as a copy. Any activity done to the parameter stays local to the function and is not reflected outside. NULL is not valid to be passed.
d.A literal is passed to the function and the parameter is treated as a constant. No activity can be done on the parameter and nothing is reflected outside the function.
In: Computer Science
Consider the word CAT
a) What would the hexadecimal representation of this word be in ASCII?
c) If we rotated the bits that represent this word 8 bits to the right, what would the word become (in letters)?
d) If we rotated the bits that represent CAT 8 places to the left, what would the word become (in letters)?
e) What would the results be (in letters) if we XORed the bits that represent CAT with the hexadecimal value 20 20 20?
f) What would the results be (in letters) if we XORed the bits that represent CAT with the hexadecimal value 13 08 13?
In: Computer Science
relationship=input('Enter the relationship status: ') #taking
input from user
income=int(input('Enter the income of the user: '))
if relationship.lower()=="single":
income>=30000:
rate=0.25
else:
rate=0.1
if relationship.lower()=="married": #function to covert upper case
to lower case,in case user gives the input in caps
if income>=60000:
rate=0.25
else:
rate=0.1
tax=income*rate
print("Status: {}\nIncome: {}\nTax:
{}".format(relationship,income,tax))
Fix this code so it prit out married or single status and the user income
In: Computer Science
This is in C++ Write a program that reads a string consisting of a positive integer or a positive decimal number and converts the number to the numeric format. If the string consists of a decimal number, The program must use a stack to convert the decimal number to the numeric format. I keep getting an error around line 31 stating that there is an undefined function stObj.push(*it - 48); -- any help to fix my error would be helpful, thank you in advance.
Here is my code:
#include <iostream>
#include <string>
#include <stack>
#include <math.h>
using namespace std;
//main method
int main()
{
//Declare local variables
string input;
double number = 0;
int index = 0;
//declare the stack of type integer
stack<int> stObj;
//prompt and read the input number
//of type string
cout << "Enter a decimal number:";
cin >> input;
//declare iterator
string::iterator iterObj = input.begin();
//push the number into the stack
//increment the index of the stack
while (*iterObj != '.' && iterObj !=
input.end())
{
//push into the stack
stObj.push(*it - 48);
iterObj++;
index = index + 1;
}
//compute the integral part of the number
for (int i = 0; i < index; i++)
{
number = number +
(stObj.top()*pow(10, i));
stObj.pop();
}
//consider the fractional part
index = -1;
if (iterObj != input.end())
{
//increment the interator for the
memory address
iterObj++;
}
//compute the fractional part to number
while (iterObj != input.end())
{
number = number + ((*iterObj -
48)*pow(10, index));
index = index - 1;
iterObj++;
}
//Display the decimal number
cout << "The numeric format: " << number
<< endl;
}
In: Computer Science
Consider the language L over alphabets (a, b) that produces strings of the form aa* (a + b) b*a.
a) Construct a nondeterministic finite automata (NFA) for the language L given
b) Construct a deterministic finite automaton (DFA) for the NFA you have constructed
In: Computer Science
What are three incidences in which animations or transitions may be appropriate in a business presentation and then three cases in which you think they'd be too much?
In: Computer Science
Using c++
Im trying to figure out a good user validation for this loop. So that if a valid number is not input, it gives an error message. I have the error message printing but its creates an infinite loop. Need some help.
double get_fahrenheit(double c){
double f;
f = (c * 9.0) / 5.0 + 32;
return f;
}
#include "question2.h"
#include<iostream>
#include<string>
using std::cout; using std::cin; using std::string;
int main()
{
double c;
double f;
double user_exit = 444;
do{
cout<<"Enter Celsius (Enter 444 to exit)\n";
cin>>c;
if(cin.good()){
f = get_fahrenheit(c);
cout<<c<<" degrees celsius is "<<f<<" degrees fahrenheit. \n\n";
break;
}else {
cout<<"Invalid Input! Please input a numerical value. \n";
cin.clear();
}
}while(c != user_exit);
cout<<"Goodbye!";
return 0;
}
In: Computer Science