Pythpn
#Exercise 1
#Ask the user for a three letter word using the prompt: three
letter word? (include a space after the ?)
#Display the entire word
#Display the word vertically, one letter at a time using print
statements and the string index
#For example, if the user enters baa, the output should be (ignore
# signs):
#baa
#b
#a
#a
#Exercise 2
#Ask the user for a number using the prompt: first number? (include
a space after the ?)
#Ask the user for a number using the prompt: second number?
(include a space after the ?)
#Convert both numbers to integers
#Calculate the product of the two numbers
#Convert the two numbers and the product to strings using the str()
function
#Display the following on screen using a print statement and the +
concatenator.(note the spacing esp no space before the .)
#The product of [first number] times [second number] is
[product].
#For example, if the user entered 2 and 3, the final output should
be:
#The product of 2 times 3 is 6.
#Exercise 3
#Ask the user for a first name using the prompt: first name?
(include a space after the ?)
#Ask the user for a last name using the prompt: last name? (include
a space after the ?)
#Ask the user for a middle inital using the prompt: middle initial?
(include a space after the ?)
#Display the user entered full name in the following format [first
name] {middle inital]. [last nmae] (note the .)
#For example, if the user entered Malu Roldan H in response to the
input statements, the output should be:
#Malu H. Roldan
#Next, display the user's initials one letter at a time vertically.
For example, for Malu H. Roldan,
#the output should be (ignore # signs):
#M
#H
#R
#Exercise 4
#Ask the user for a six letter cheer using the prompt: six letter
cheer? (include a space after the ?)
#Display the entire cheer with an exclamation point after it (e.g.
if user enters boohoo, display boohoo!)
#Display the cheer vertically, one letter at a time ending with an
exclamation point in the last line
#For example, for user entry boohoo, display (ignore #
signs):
#b
#o
#o
#h
#o
#o
#!
#Exercise 5
#a Ask the user for a birth year using the prompt: birthyear?
(include a space after the ?)
#b Convert the user input to an integer
#c Subtract the user entered birthyear from 2019
#d Convert the result of the previous line and the user entry to
strings using the str() function
#e Display the following using the + concatenator in a print
statement (note the punctuation and spacing):
#f It has been [converted result of line 5c]! years since your
birthyear in [converted user entry]!
#g Hence, if user entered 2010, display:
#h It has been 9! years since your birthyear in 2010
#i Next, display the words: You were born in the year:
#j Display the converted user entered birthyear vertically, one
digit at a time.
#k For example, for 2010 display (ignore the # signs):
#2
#0
#1
#0
In: Computer Science
In: Computer Science
3) Write the awk command that would show the user wmorales (or yourself) that is online (you have to use a pipe) Output, depending on the system that you are using or the command to find the users online, but it would be similar to:
wmorales pts/37 10.32.9.93 13:58 1.00s 0.15s 0.10s w
or
wmorales pts/8 2020-04-25 12:22 (c-71-59-237-122.hsd1.or.comcast.net)
YOUR AWK COMMAND:
(10 points hard one) -
4) use who to show the the users on our system that have the letter r in their first name, OR last name, but nowhere else. Note also that the r can be r or R. Note that your output will be a bit different as well, but note that the uses listed do have r either on their first or last name
output would be similar to:
Outcyrus.rice pts/21 2017-10-23 12:38 (jamess-iphone-2.wifi.pcc.edu)
tina.olsgaard pts/29 2017-10-23 12:41 (174-25-110-78.ptld.qwest.net)
rachel.benes pts/30 2017-10-23 12:54 (laptop-2j35sntl.wifi.pcc.edu)
rachel.benes pts/33 2017-10-23 13:43 (laptop-2j35sntl.wifi.pcc.edu)
jarod.morrow pts/35 2017-10-23 12:54 (sytc310-08.ad.pcc.edu)
wmorales pts/37 2017-10-23 13:58 (10.32.9.93)
----------------------- cut ------------------
note: the letter r or R has to appear either in their first name or last name only, not on the name of the machine that they are using if it happen to have r in it.
YOUR AWK COMMAND:
5) (3 points - easy) from the file called winelist extract a list of wines that cost less than $7.00 output (
it may be different depending the time you do it):
1977 6.99 Franciscan
1977 6.75 Alexander Valley
1977 5.99 Charles Krug
YOUR AWK COMMAND:
In: Computer Science
In: Computer Science
Here we will be taking data in as a file. Note that the sample file provided here is not the file that I will use to grade your assignment but the formatting will be the same.
The file you will be imputing to your program is a grade sheet. You will be taking in the grade sheet of 5 students with an unknown amount of grades (the number of possible grades is from 2 to 8). The number of grades will be provided at the top of the file. Your job is to take in the grades average them for each of the 5 students and output the grades in order from greatest to least.
Example input:
Grades 4
Bob 90 89 72 89
Tim 65 60 78 88
Kelly 99 67 75 81
Wesley 44 76 58 67
Anel 100 91 90 96
Example output:
Anel 94.25
Bob 85
Kelly 80.5
Tim 72.75
Wesley 61.25
Final submission should be your .cpp file only
In: Computer Science
In java what is the best algorithm and data structure choice to search for all instances where a pattern is found some larger texts. Also please provide the worst-case complexity big o notation of this and why it is best.
Assuming the texts are all stored in a class instance that has a field contents. Which is then stored as a array list value in a linked hash map with the key being the username of the poster.
In: Computer Science
In login-based catalog restriction, the ___________________ allows customers to be able to see the products and prices in your store but it will not be able to make any purchases.
Not required |
||
Must login to browse |
||
Showroom Only |
||
May browse but no prices unless logged in |
What is the difference between a standard product and variant product?
A variant product doesn't offer product customization while a standard product does |
||
All of the above |
||
None of the above |
||
A standard product doesn't offer product customization while a variant product does |
> A _________ defines the different properties(fields) that a particular type of product will have for creating a product.
> Product belonging to the "Product-General" product type can be linked to specific ________ whereas products belonging to the "Product-Music" product type can be linked to the __________-.
In Zen Cart, what is not a type of catalog restriction?
Authentication-based |
Login-based |
Authorization-based |
Store-wide |
A ____________ defines the properties (options) such as color, size, etc for variant product.
The _______________ allows you to manipulate the products and categories in your store catalog
Product screen |
Categories screen |
Catalog Menu |
Categories/product screen |
The "$" button is shown on Categories/Products screen containing only categories and one that contains only products
True | ||
False |
In: Computer Science
Assume that the int.TryParse static method in .NET DOES NOT EXIST. Write your own TryParse method. Create a class named MyInt (so as not to conflict with existing Int32 class) and write the static TryParse method inside the MyInt class. Your MyInt.TryParse method is to duplicate the functionality of the existing .NET int.TryParse method EXACTLY. I want your MyInt.TryParse method to internally use the existing int.Parse method. Write a test console application that takes in a value from the user and validates it for integer input using your MyInt.TryParse method.
You may use any features of C# and/or any members of the .NET Framework (including int.Parse).
THIS IS TO BE DONE USING C#
In: Computer Science
using java program Stay on the Screen! Animation in video games is just like animation in movies – it’s drawn image by image (called “frames”). Before the game can draw a frame, it needs to update the position of the objects based on their velocities (among other things). To do that is relatively simple: add the velocity to the position of the object each frame.
For this program, imagine we want to track an object and detect if it goes off the left or right side of the screen (that is, it’s X position is less than 0 and greater than the width of the screen, say, 100). Write a program that asks the user for the starting X and Y position of the object as well as the starting X and Y velocity, then prints out its position each frame until the object moves off of the screen. Design (pseudocode) and implement (source code) for this program.
Sample run 1:
Enter the starting X position: 50
Enter the starting Y position: 50
Enter the starting X velocity: 4.7
Enter the starting Y velocity: 2
X:50 Y:50
X:54.7 Y:52
X:59.4 Y:54
X:64.1 Y:56
X:68.8 Y:58
X:73.5 Y:60
X:78.2 Y:62
X:82.9 Y:64
X:87.6 Y:66
X:92.3 Y:68
X:97 Y:70
X:101.7 Y:72
Sample run 2:
Enter the starting X position: 20
Enter the starting Y position: 45
Enter the starting X velocity: -3.7
Enter the starting Y velocity: 11.2
X:20 Y:45
X:16.3 Y:56.2
X:12.6 Y:67.4
X:8.9 Y:78.6
X:5.2 Y:89.8
X:1.5 Y:101
X:-2.2 Y:112.2
In: Computer Science
Hi
I have a java code for my assignment and I have problem with one of my methods(slice).the error is Exception in thread "main" java.lang.StackOverflowError
Slice method spec:
Method Name: slice
Return Type: Tuple (with proper generics)
Method Parameters: Start (inclusive) and stop (exclusive) indexes.
Both of these parameters are "Integer" types
(not "int" types). Like "get" above, indexes may
be positive or negative. Indexes may be null.
Description:
Given this Tuple:
[10, 20, 30, 40]
Example slice results
Start | Stop | Result (New Tuple) |
---|---|---|
0 | 1 | [10] |
0 | 2 | [10, 20] |
0 | 3 | [10, 20, 30] |
0 | 4 | [10, 20, 30, 40] |
null | 1 | [10] |
null | 3 | [10, 20, 30] |
-2 | -1 | [30] |
-2 | null | [30, 40] |
-1 | null | [40] |
null | null | [10, 20, 30, 40] |
Note: Each result is a new tuple
Example usage:
tuple2 = tuple1.slice(0, 1);
tuple2 = tuple1.slice(-1, null);
My code is the following:
import java.util.*;
public class Tuple1 <T>{
private List<T> elements;
public Tuple1(List<T> newElements){
this.elements=newElements;
}
@SafeVarargs
public Tuple1(T...newElements){
List<T> elementsss=new
ArrayList<T>();
for(T i:newElements){
elementsss.add(i);
}
this.elements=elementsss;
}
public Tuple1(Tuple1<T> tuple){
elements=tuple.elements;
}
public List<T> getElements(){
return
this.elements;
}
public T get(Integer index){
if(index<0){
return
this.getElements().get(size()+index);
}
else{
return
this.getElements().get(index);
}
}
public int size(){
return getElements().size();
}
public T getFirst(){
return this.get(0);
}
public T getLast(){
return this.get(-1);
}
public List toList(){
List<T> copy=new
ArrayList<>(this.getElements());
return
copy;
}
public Integer confirmStart(Integer start){
Integer
star=0;
if
(start==null){
star=0;
}
else if
(start<0){
star=this.size()+start;
}
else {
star=start;
}
return
star;
}
public Integer confirmStop(Integer stop){
Integer
sto=0;
if(stop==null){
sto=this.size();
}
else
if(stop<0){
sto=this.size()+stop-1;
}
else{
sto=stop-1;
}
return
sto;
}
public Tuple1 <T> slice(Integer start,Integer
stop){
List<T>
list= new ArrayList<T>();
Integer
star=this.confirmStart(start);
Integer
sto=this.confirmStop(stop);
list=this.getElements().subList(star,sto);
Tuple1 <T>
t;
t= new Tuple1
<T>(list);
return t;
}
@Override
public String toString(){
String output="Tuple Elementst: "+"
"+this.getElements()+
"\n Get Element:
"+this.get(0)+
"\nSize:
"+this.size()+
"\nFirst
Element:"+" "+this.getFirst()+
"\nLast Element
:"+" "+this.getLast()+
"\nconfirmStart:
"+" "+this.confirmStart(1)+
"\nConfirm
Stop:"+" "+this.confirmStop(-1)+
"\ntoList:"+"
"+this.toList()+
"\nSlice:"+"
"+this.slice(0,2);
return
output;
}
public static void main (String[]args){
List<String>elementss=new
ArrayList<String>();
elementss.add("Haitham");
elementss.add("Lindsey");
elementss.add("Lamar");
elementss.add("Narmin");
Tuple1 <String> elm;
elm=new
Tuple1<String>(elementss);
System.out.println(elm.toString());
System.out.println("================================");
Tuple1 <Integer> elms;
elms=new
Tuple1<Integer>(1,2,3,4,5);
System.out.println(elms.toString());
}
}
In: Computer Science
In java what is the full code of a BoyerMoore search algorithm when nested in another class, using only JCF and no non standard packages. The text searching through can only contain printable ASCII characters, and capitalization matters. Also please provide the worst-case time complexity of the search algorithm.
The pattern is a String, and the contents searching is a String.
In: Computer Science
In: Computer Science
Java Project
Tasks:
Create a Coin.java class that includes the following:
Takes in a coin name as part of the constructor and stores it in a private string
Has a method that returns the coins name
Has an abstract getvalue method
Create four children classes of Coin.java with the names Penny, Nickle, Dime, and Quarter that includes the following:
A constructor that passes the coins name to the parent
A private variable that defines the value of the coin
A method that returns the coins name via the parent class
And any other methods that should be required.
Create a Pocket class that includes the following:
An ArrayList of type coin to manage coins.(You MUST use an ARRAYLIST)
A method that allows a coin to be added
A method that allows a coin to be removed
A method that returns a count of the coins in your arraylist by coin type.
A method that returns a total value of all the coins in your arraylist
Create a NoSuchCoin class that will act as your custom exception (see pg.551 in book).
Create a PocketMain class that includes the following :
Creates an object of type pocket to be used below
A main method that prompts the user with a menu of options to include:
Add a coin (must specify type)
Remove a coin (must specify type)
Display a coin count
Display a total value in the pocket
An ability to exit the program
This method must handle poor user input somehow using your custom exception
YOU MUST COMMENT YOUR CODE SO I KNOW WHAT IS HAPPENING!!!
Deliverables:
Pocket.java
Coin.java
Nickle.java
Penny.java
Dime.java
Quarter.java
PocketMain.Java
NoSuchCoin.java
In: Computer Science
I need assistance on what I am doing wrong, I've been trying to declare "getRandomLetter" as a scope, but haven't found how to all day. It's been about 3+ hours and I still have nothing. Please help fix these and let me know what I am doing wrong (There may be more simple ways of coding all this, but I just need help fixing the errors with current code, thank you). I am trying to have buildAcronym() hold the position of going from A-Z , & as well as getRandomLetter() choose a letter from A-Z using the ASCII character set. This is a bit of the prompt where it asks to set these up. If I am off, I do apologize.
Define and overload two void-typed functions named buildAcronym that assign a (pseudo)-random uppercase letter to two (2) or three (3) character parameters, depending on the version called. Each character in an acronym must be a unique uppercase letter. Two arguments (or three, depending on the version called) will be assigned a random character literal, which can then be printed out in main.
These are my errors.
Acronyms.cpp: In function 'void buildAcronym(char, char,
char)':
Acronyms.cpp:13:35: error: 'getRandomLetter' was not declared in
this scope
getRandomLetter(a , b , c)
^
Acronyms.cpp: In function 'void buildAcronym(char, char)':
Acronyms.cpp:25:24: error: 'getRandomLetter' was not declared in
this scope
getRandomLetter(a,b)
^
Acronyms.cpp: In function 'int main()':
Acronyms.cpp:50:39: error: 'getRandomLetter' was not declared in
this scope
cout << getRandomLetter(a,b) ;
^
Acronyms.cpp:56:42: error: 'getRandomletter' was not declared in
this scope
cout << getRandomletter(a,b,c);
^
Acronyms.cpp:60:9: error: expected ';' before '{' token
{
^
Acronyms.cpp:67:1: error: expected 'while' at end of input
}
^
Acronyms.cpp:67:1: error: expected '(' at end of input
Acronyms.cpp:67:1: error: expected primary-expression at end of
input
Acronyms.cpp:67:1: error: expected ')' at end of input
Acronyms.cpp:67:1: error: expected ';' at end of input
Acronyms.cpp:67:1: error: expected '}' at end of input
------------------------------------------------------------------------------------------------------------------------------------
--
--------------------------------------
(there are 3 lines above include Name: Date: Filename: apologies that it is missing)
#include
using namespace std;
void buildAcronym(char a ,char b , char c)
{
if('A'<= b && 'A' <= b && 'A' <= c
&& a <= 'Z' && b <= 'Z' && c <=
'Z')
{
getRandomLetter(a , b , c)
{
cout << a + rand() % 65 + 90 << "." ;
cout << b + rand() % 65 + 90 << "." ;
cout << c + rand() % 65 + 90 << "." ;
}
}
return ;
}
void buildAcronym(char a , char b)
{
getRandomLetter(a,b)
{
cout << a + rand() % 65 + 90 << "." ;
cout << b + rand() % 65 + 90 << "." ;
}
return ;
}
int main()
{
char a , b , c ;
int choice ;
do
{
cout << "Press 1 for a two letter acronym, and 2 for a three
letter acronym. " ;
cin >> choice ;
switch(choice)
{
case 1 :
if (choice == 1)
{
cout << getRandomLetter(a,b) ;
break ;
}
case 2 :
if (choice == 2)
{
cout << getRandomletter(a,b,c);
break;
}
else (choice != 1 && choice != 2)
{
cout << "Press 1 for a two letter acronym, and 2 for a three
letter acronym. ";
}
}while(choice!=1 && choice != 2);
return 0;
}
In: Computer Science
1) Explain the process of port mirroring
2) difference between network media and networking device vulnerabilities
In: Computer Science