The code must work on PEP/9, it shouldn't be too complicated and long
Take the following C++ program and translate it into Pep/9 assembly language
#include
using namespace std;
int age;
char first, last;
int main() {
cin >> age;
cin >> first >> last;
cout << "Your age " << age << endl;
cout << "Initials " << first << last << endl;
if (age >= 30)
cout << “Cannot trust\n”;
return 0;
}
In: Computer Science
write a program in python that insert a number in the middle of an array. Assume that the length of an array is even. For instance, is a=(1,4,7,9) and num=100, then really=(1,4,100,7,9)
In: Computer Science
Principles of Information Security
Using nothing less than 1000 words Identify and explain in details the six components of an information system. Which are most directly affected by the study of computer security? Which are most associated with its study?
In: Computer Science
1 TB = x MB, where x is:
Select one:
a. 1024
b. 1,000,000
c. 1024 * 1024
d. 1024 * 1024 * 1024
In: Computer Science
0. Introduction.
In this lab assignment, you will extend some simple Java classes that represent plane figures from elementary geometry. The object of this assignment is not to do anything useful, but rather to demonstrate how methods can be inherited by extending classes.
1. Theory.
A polygon is a closed plane figure with three or more
sides, all of which are line segments. The perimeter of a
polygon is the sum of the lengths of its sides. A
rectangle is a polygon with exactly four sides that meet
at 90° angles. Like a polygon, it has a perimeter. It also has an
area, the product of its base and height. A
square is a rectangle whose sides are all the same length.
Like a rectangle, it has a perimeter and an area.
Polygons, rectangles, and squares
make up an is-a hierarchy. The hierarchy gets its name
because a square is-a rectangle, and a rectangle
is-a polygon. Is-a hierarchies can be easily modeled by
Java classes using the extends keyword.
2. Implementation.
The following is the source code for a Java class whose instances represent polygons. The file Polygon.java on Canvas contains a copy of this source code. You will need it to complete the laboratory assignment.
class Polygon
{
private int[] sideLengths;
public Polygon(int sides, int ... lengths)
{
int index = 0;
sideLengths = new int[sides];
for (int length: lengths)
{
sideLengths[index] =
length;
index += 1;
}
}
public int side(int number)
{
return sideLengths[number];
}
public int perimeter()
{
int total = 0;
for (int index = 0; index <
sideLengths.length; index += 1)
{
total += side(index);
}
return total;
}
}
The class Polygon uses a private array called sideLengths to
store the lengths of a polygon’s sides. The array’s length,
sideLengths.length, is the number of sides that the polygon has.
The class Polygon also has a has a public constructor and two
public methods. To keep things simple, they do not check their
arguments for correctness, as they would if Polygon was part of a
real program.
The constructor takes four or more
arguments and returns an instance of Polygon that represents a
polygon. The first argument is the number of sides that the polygon
has. The remaining arguments are the lengths of those sides. For
example, the Java statement:
Polygon triangle = new Polygon(3, 3, 4, 5);
declares the variable triangle and sets it to an instance of
Polygon that represents a triangle (because the first argument says
it has 3 sides). The lengths of the triangle’s sides are 3, 4, and
5.
The three dots ‘...’ in the
constructor mean that it can take zero or more extra integer
arguments after its first argument. The for-loop with the colon
visits the extra arguments one at a time. Don’t worry if those
parts of Java are unfamiliar. You don’t have to know how the
constructor works, only how to call it.
The method side returns the length
of a polygon’s side. Sides are numbered starting from 0. For
example, the expression triangle.side(0) returns 3, the expression
triangle.side(1) returns 4, and the expression triangle.side(2)
returns 5.
The method perimeter returns a
polygon’s perimeter, the sum of the lengths of its sides. For
example, the expression triangle.perimeter() returns 3 + 4 + 5 =
12.
For this assignment, you must write
a class called Rectangle. As its name suggests, each instance of
Rectangle must represent a rectangle. Along with a constructor,
Rectangle must provide two methods, called area and perimeter. The
method area must return the integer area of the rectangle, and the
method perimeter must return the integer perimeter of the
rectangle.
You must also write another class,
called Square. As its name suggests, each instance of Square must
represent a square. Along with a constructor, Square must provide
two methods, called area and perimeter. The method area must return
the integer area of the square, and the method perimeter must
return the integer perimeter of the square.
The following driver program shows
examples of how the constructors and methods of Rectangle and
Square must work.
class Shapes
{
public static void main(String[] args)
{
Rectangle wreck = new Rectangle(3,
5); // Make a 3 × 5 rectangle.
System.out.println(wreck.area()); // Print
its area, 15.
System.out.println(wreck.perimeter()); // Print
its perimeter, 16.
Square nerd = new
Square(7); // Make
a 7 × 7 square.
System.out.println(nerd.area()); // Print
its area, 49.
System.out.println(nerd.perimeter() // Print
its perimeter, 28.
}
}
Your classes Rectangle and Square must use the extends keyword,
so they will inherit methods from other classes. Also, each class
must inherit as many of its methods as possible from those other
classes. YOU WILL LOSE POINTS FOR DEFINING A METHOD INSIDE
A CLASS, IF IT COULD HAVE BEEN INHERITED FROM ANOTHER
CLASS!
Here’s a hint about how to write the
constructors for Rectangle and Square. Suppose that a class
Triangle extends the class Polygon. Then Polygon is the
superclass of Triangle. The keyword super can be used to
call the constructor that belongs to a superclass. For example,
Triangle’s constructor, which takes the lengths of a triangle’s
three sides, might look like this.
public Triangle(int a, int b, int c)
{
super(3, a, b, c);
}
It uses Polygon’s constructor to make a polygon with 3 sides, whose lengths are a, b, and c. If super is used in this way, then it must be the first statement in the constructor. You don’t have to write Triangle—this was only an example!
3. Deliverables.
The file tests6.java contains a driver class whose a main method
performs 12 public tests, worth 1 point each. Each public
test is a call to println, along with a comment that shows what it
must print. To grade your work, the TA’s will run the public tests
using your Rectangle and Square classes. If a public test behaves
exactly as it should, then you will receive 1 point for it.
In addition, the TA’s will do 5
private tests on your Rectangle and Square classes. You
will not be told what the private tests are, but they are worth 2
points each, and they determine if Rectangle and Square have
inherited as many methods as possible. The TA’s will do the same
private tests for all students, and these tests will be made public
only after all the work for this lab has been graded.
Your score for this lab is the sum
of the points you get for the public tests, and the points you get
for the private tests, for a maximum of 22 points. Here is what you
must turn in.
Source code for the class Rectangle. Its instances must provide the methods side, area and perimeter. These methods are not necessarily defined in Rectangle: some or all may be inherited.
Source code for the class Square. Its instances must provide the methods side, area and perimeter. These methods are not necessarily defined in Square: some or all may be inherited.
In: Computer Science
Prompt the user to enter a string of their choosing. Store the
text in a string. Output the string. (1 pt)
Ex:
Enter a sample text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue! You entered: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
(2) Implement a print_menu() function, which has a string as a
parameter, outputs a menu of user options for analyzing/editing the
string, and returns the user's entered menu option and the sample
text string (which can be edited inside the print_menu() function).
Each option is represented by a single character.
If an invalid character is entered, continue to prompt for a
valid choice. Hint: Implement the Quit menu option before
implementing other options. Call print_menu() in the main
section of your code. Continue to call print_menu() until the user
enters q to Quit. (3 pts)
Ex:
MENU c - Number of non-whitespace characters w - Number of words f - Fix capitalization r - Replace punctuation s - Shorten spaces q - Quit Choose an option:
(3) Implement the get_num_of_non_WS_characters() function.
get_num_of_non_WS_characters() has a string parameter and returns
the number of characters in the string, excluding all whitespace.
Call get_num_of_non_WS_characters() in the print_menu() function.
(4 pts)
Ex:
Number of non-whitespace characters: 181
(4) Implement the get_num_of_words() function. get_num_of_words()
has a string parameter and returns the number of words in the
string. Hint: Words end when a space is reached except for the
last word in a sentence. Call get_num_of_words() in the
print_menu() function. (3 pts)
Ex:
Number of words: 35
(5) Implement the fix_capitalization() function.
fix_capitalization() has a string parameter and returns an updated
string, where lowercase letters at the beginning of sentences are
replaced with uppercase letters. fix_capitalization() also returns
the number of letters that have been capitalized. Call
fix_capitalization() in the print_menu() function, and then output
the the edited string followed by the number of letters
capitalized. Hint 1: Look up and use Python functions
.islower() and .upper() to complete this task. Hint 2: Create an
empty string and use string concatenation to make edits to the
string. (3 pts)
Ex:
Number of letters capitalized: 3 Edited text: We'll continue our quest in space. There will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. Nothing ends here; our hopes and our journeys continue!
(6) Implement the replace_punctuation() function.
replace_punctuation() has a string parameter and two keyword
argument parameters exclamation_count and
semicolon_count. replace_punctuation() updates the
string by replacing each exclamation point (!) character with a
period (.) and each semicolon (;) character with a comma (,).
replace_punctuation() also counts the number of times each
character is replaced and outputs those counts. Lastly,
replace_punctuation() returns the updated string. Call
replace_punctuation() in the print_menu() function, and then output
the edited string. (3 pts)
Ex:
Punctuation replaced exclamation_count: 1 semicolon_count: 2 Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here, our hopes and our journeys continue.
(7) Implement the shorten_space() function. shorten_space() has a
string parameter and updates the string by replacing all sequences
of 2 or more spaces with a single space. shorten_space() returns
the string. Call shorten_space() in the print_menu() function, and
then output the edited string. Hint: Look up and use Python
function .isspace(). (3 pt)
Ex:
Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes, more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!
In: Computer Science
Identifying appropriate data mining technique(s) for reaching goals on : innovation of intelligence transportation system nowadays .
In: Computer Science
How to separate 2000H of external RAM? Sent the high 4
bits to the low 4 bits of 2001H, and the low 4 bits are sent to the
low 4 bits of 2002H. Clear the high 4 bits of 2001H and
2002H.
the answer in C program please
In: Computer Science
Summary In this lab, you write a while loop that uses a sentinel value to control a loop in a C++ program that has been provided. You also write the statements that make up the body of the loop. The source code file already contains the necessary variable declarations and output statements. Each theater patron enters a value from 0 to 4 indicating the number of stars the patron awards to the Guide’s featured movie of the week. The program executes continuously until the theater manager enters a negative number to quit. At the end of the program, you should display the average star rating for the movie. Instructions Ensure the source code file named MovieGuide.cpp is open in your code editor. Write the while loop using a sentinel value to control the loop, and write the statements that make up the body of the loop. The output statements within the loop have already been written for you. Ensure you include the calculations to compute the average rating. Execute the program by clicking the Run button. Input the following: 0, 3, 4, 4, 1, 1, 2, -1 Ensure the average output is correct.
this is the prewritten code:
// MovieGuide.cpp - This program allows each theater patron to enter a value from 0 to 4
// indicating the number of stars that the patron awards to the Guide's featured movie of the
// week. The program executes continuously until the theater manager enters a negative number to
// quit. At the end of the program, the average star rating for the movie is displayed.
#include <iostream>
#include <string>
using namespace std;
int main()
{
// Declare and initialize variables.
double numStars; // star rating.
double averageStars; // average star rating.
double totalStars = 0; // total of star ratings.
int numPatrons = 0; // keep track of number of patrons
// This is the work done in the housekeeping() function
// Get input.
cout << "Enter rating for featured movie: ";
cin >> numStars;
// This is the work done in the detailLoop() function
// Write while loop here
// This is the work done in the endOfJob() function
cout << "Average Star Value: " << averageStars << endl;
return 0;
} // End of main()
In: Computer Science
Please, write this code in c++. Using iostream and cstring library.
Write a function that will delete all words in the given text that meets more that one time. Also note than WORD is sequence of letters sepereated by whitespace.
Note. The program have to use pointer.
Input: First line contains one line that is not longer than 1000 symbols with whitespaces. Each word is not longer than 30 symbols.
Output: Formatted text.
example:
input: Can you can the can with can ?
output: Can you can the with ?
In: Computer Science
Please, write code in c++. Using iostream and cstring library.
You given a text.Your task is to write a function that will find
the longest sequence of digits inside.
Note that the output have to be presened just like in sample.
Note. The program have to use pointer.
Input:
First line contains one line that is not longer than 1000.
Output:
The longest sequence of numbers.All numbers are positive and
integers.
example:
input: 101 fdvnjfkv njfkvn fjkvn jffdvfdvfd2010
output: 2010
In: Computer Science
review of related literature about development of fire response system
In: Computer Science
Please, write code in c++. Using iostream library.
Most modern text editors are able to give some statistics about
the text they are editing. One nice statistic is the average word
length in the text. A word is a maximal continuous sequence of
letters ('a'-'z', 'A'-'Z'). Words can be separated by spaces,
digits, and punctuation marks. The average word length is the sum
of all the words' lengths divided by the total number of
words.
For example, in the text "This is div2 easy problem". There are 5 words: "This"is"div"easy" and "problem". The sum of the word lengths is 4+2+3+4+7 = 20, so the average word length is 20/5 = 4.
Given a text, return the average word length in it. If there are no words in the text, return 0.0.
Input
The first line will contain the text of length between 0 and 50
characters inclusive. Text will contain only letters ('a'-'z',
'A'-'Z'), digits ('0'-'9'), spaces, and the following punctuation
marks: ',', '.', '?', '!', '-'. The end of text will be marked with
symbol '#' (see examples for clarification).
Output
Output should contain one number - the average length. The returned
value must be accurate to within a relative or absolute value of
10-9.
example:
input:
This is div2 easy problem.#
output:
4.0
In: Computer Science
package questions;
public class File {
public String base; //for example, "log" in
"log.txt"
public String extension; //for example, "txt" in
"log.txt"
public int size; //in bytes
public int permissions; //explanation in toString
//DO NOT MODIFY
public String getBase() {
return base;
}
/**
*
* @param b
* if b is null or if empty (""), base should become
"default",
* for all other values of b, base should become
b
*/
public void setBase(String b) {
//to be completed
}
//DO NOT MODIFY
public String getExtension() {
return extension;
}
/**
*
* @param e
* if e is null or if empty (""), extension should
become "txt",
* for all other values of e, extension should become
e
*/
public void setExtension(String e) {
//to be completed
}
//DO NOT MODIFY
public int getSize() {
return size;
}
/**
*
* @param s
* if s is less than 0, size should become 0
* if s is more than or equal to 0, size should become
s
*/
public void setSize(int s) {
//to be completed
}
//DO NOT MODIFY
public int getPermissions() {
return permissions;
}
/**
*
* @param p
* if p is less than 0, permissioons should become
0
* if p is more than 7, permissions should become
7
* if p is between 0 and 7 (inclusive on both sides),
permissions should become p
*/
public void setPermissions(int p) {
//to be completed
}
//DO NOT MODIFY
public File() {
setBase("default");
setExtension(".txt");
setSize(0);
setPermissions(0);
}
/**
*
* @param b: value for base
* @param e: value for extension
* @param s: value for size
* @param p: value for permissions
*/
public File(String b, String e, int s, int p) {
//to be completed
}
//DO NOT MODIFY
public String getName() {
return base + "." +
extension;
}
/**
*
* This method should set the size to 0, permission to
0, extension to null and base to null.
*
* Note that your File constructor and setters must be
correct to pass the JUnit tests.
*
*/
public void wipe() {
//to be completed
}
/**
*
* @param other
* @return
* 1 if calling object is bigger in size than the
parameter object
* -1 if calling object is smaller in size than the
parameter object
* 0 if calling object has the same size as the
parameter object
*/
public int compareTo(File other) {
return 0; //to be completed
}
/**
*
* @param other
* @return true if calling object and parameter object
are identical
* in every aspect (base, extension, size,
permissions)
*
* NOTE: file name should be checked in case
INsensitive manner
*
* HINT: Strings are NOT compared using == (s1 == s2 is
WRONG)
* Google "String comparison java" and "String case
insensitive comparison java" to
* see the right way!
*/
public boolean equals(File other) {
if(other instanceof File) {
return (new String("size1").equals(other.size)&&new String("base1").equalsIgnoreCase(other.base)&&new String("permission1").equals(other.permissions) && new String("extension1").equalsIgnoreCase(other.extension));
}
return false;
}
/**
* @return a new folder object with the same
permission, size, base and extension as the calling object.
* (In other words, return a deep copy of the calling
object.
*/
public File clone() {
return null; //to be
completed
}
/**
* HD
* return String representation of the calling
object.
*
* Size:
*
* 1024 bytes = 1 kilobyte (KB)
* 1024 kilobytes = 1 megabyte (MB)
* 1024 megabytes = 1 gigabyte (GB
*
* for files below 1024 bytes, you should represent
size in bytes (B)
* for files 1024 bytes or more but less than 1024
kilobytes, you should represent size in kilobytes (KB)
* for files 1024 kilobytes or more but less than 1024
megabytes, you should represent size in megabytes (MB)
* for files 1024 megabytes or more, you should
represent size in gigabytes (GB)
*
* only the integer part of size should be
displayed.
*
* Permissions:
*
* Permissions is a number between 0 and 7.
* 1st bit represents read permission,
* 2nd bit represents write permission,
* 3rd bit represents execute permissiono
*
* 0: 000 (---)
* 1: 001 (--x)
* 2: 010 (-w-)
* 3: 011 (-wx)
* 4: 100 (r--)
* 5: 101 (r-x)
* 6: 110 (rw-)
* 7: 111 (rwx)
*
*
https://www.tutorialspoint.com/unix/unix-file-permission.htm
*
* Syntax of toString:
* <permissions in (r/-)(w/-)(x/-) format>
<file name> <integer size in correct magnitude>
*
* Some examples:
* if base = "log", extension = "txt", size = 1056,
permissions = 4,
* the String returned should return
*
*
"r--
log.txt 1KB"
*
* if base = "data", extension = "csv", size = 4500000,
permissions = 7,
* the String returned should return:
*
*
"rwx
data.csv 4MB"
*/
public String toString() {
return ""; //to be completed
}
}
In: Computer Science
Please, write code in c++. Using iostream library
A chessboard pattern is a pattern that satisfies the
following conditions:
• The pattern has a rectangular shape.
• The pattern contains only the characters '.' (a dot) and 'X' (an
uppercase letter X).
• No two symbols that are horizontally or vertically adjacent are
the same.
• The symbol in the lower left corner of the pattern is '.' (a
dot).
You are given two numbers. N is a number of rows and
M is a number of columns. Write a program that generates
the chessboard pattern with these dimensions, and outputs
it.
Input
The first line contains two numbers N and M (1 ≤
N ≤ 50, 1 ≤ M ≤ 50) separated by a
whitespace.
Output
Output should contain N lines each containing M
symbols that correspond to the generated pattern. Specifically, the
first character of the last row of the output represents the lower
left corner (see example 1).
example:
input:
8 8
output:
X.X.X.X.
.X.X.X.X
X.X.X.X.
.X.X.X.X
X.X.X.X.
.X.X.X.X
X.X.X.X.
.X.X.X.X
In: Computer Science