The Sum and The Average
In C++,
Write a program that reads in 10 integer numbers. Your program should do the following things:
Use a Do statement
Determine the number positive or negative
Count the numbers of positive numbers, and negative
Outputs the sum of:
all the numbers greater than zero
all the numbers less than zero (which will be a negative number or zero)
all the numbers
Calculate the average of all the numbers.
The user enters the ten numbers just once each and the user can
enter them in any order. Your program should not ask the user to
enter the positive numbers and the negative numbers separately
In: Computer Science
Try to make it as simple as you can and explain as much as it needed.
Ans:
Ans:
Ans:
Ans:
Ans:
In: Computer Science
Try to make it as simple as you can and explain as much as it needed.
Ans:
Ans:
Ans:
Ans:
Ans:
In: Computer Science
package edu.depaul.triangle;
import java.util.Scanner;
/**
* A class to classify a set of side lengths as one of the 3 types
* of triangle: equilateral, isosceles, or scalene.
* If classification is not possible it emits an error message
*/
public class Triangle {
/**
* Define as private so that it is not a valid
* choice.
*/
private Triangle() {}
public Triangle(String[] args) {
//
// TODO: keep this simple. Constructors should not do a lot of work
//
}
// TODO: Add methods to validate input, and classify the triangle (if possible) here
private static String[] getArgs(Scanner s) {
System.out.println("press Enter by itself to quit");
System.out.println("enter 3 integers separated by space.");
String args = s.nextLine();
return args.split(" ");
}
public static void main(String[] a) {
try (Scanner scanner = new Scanner(System.in)) {
String[] args = getArgs(scanner);
// Loop until the user enters an empty line
while(args[0].length() !=0) {
//
// TODO: create a new Triangle here and call it
//
args = getArgs(scanner);
}
System.out.println("Done");
}
}
Write a Java program to determine types of triangles. The program reads 3 values from the standard input. The values represent the lengths of the sides of a triangle. The program prints a message to the standard output that indicates whether the triangle represented by the input is • an equilateral (all 3 sides are equal), or • an isosceles (exactly 2 of the 3 sides are equal), or • a scalene (all 3 sides are of different lengths) Expected behavior: a. The user enters 3 values at a prompt and presses return b. The values must be converted to integers. If they cannot be converted, the system displays an error. c. The valid values for these integers are values from 1 to and including 300. Any other integers should cause an error to be shown to the user. d. The values are delimited with spaces e. The system evaluates the results, shows either a triangle type or an error, then prompts for input again. f. When the user enters a blank line followed by return, the program ends. g. An error is shown whenever the user’s input cannot be interpreted as a triangle or when the handling of the input results in exception.
In: Computer Science
Write a C++ program to ask the user to enter the shape type: square, sphere or circle and the appropriate dimensions of the shape.. The program should output the following information about the shape:
a.for a square. it output the area and perimeter.
b. for a sphere, it outputs the area.
c. fir a circle, it outputs the volume.
if the user input anything else, your program should output: "the program does not recognize this shape". Use const whenever it is appropriate (use the nested if)
area of sphere is 4*PI*r^2
area of circle is Pi*r^2 (Pi=3.1416)
In: Computer Science
Write a C program to create a series of processes, as shown below in the diagram.
P |------ ---- > c1 |------------>c2
|------- ------>c3 ---------->c4
In other words, the parent process p creates process c1, c1 creates c2 and c3, and c3 creates c4.
A sample run of the program shows
Your program should output something similar to what is shown above. You could optionally use wait/waitpid/sleep/exit in your program.
Comment your code to show where you created p, c1, c2, c3, c4, etc.
In: Computer Science
1.For Python Which statement(s) are true regarding private class variables?
private variables can be accessible inside the class.
private variables can be accessible outside the class.
private variable values can be changed directly outside of the class
private variables can be changed outside the class through set methods.
2.
In the following code,
def A:
def __init__(self):
__a = 1
self.__b = 1
self.c = 1
__d__ = 1
# Other methods omitted
Which of the following is a private data field?
Group of answer choices
__a
__b
c
__d__
3.
Analyze the following code and choose the more accurate
statement.
class A:
def __init__(self, s):
self.s =
s
def print(self):
print(s)
a = A("Welcome")
a.print()
Group of answer choices
The program has an error because class A does not have a constructor.
The program has an error because class A should have a print method with signature print(self, s).
The program has an error because class A should have a print method with signature print(s).
The program would run if you change print(s) to print(self.s).
4.
Which of the following statement is most accurate?
Group of answer choices
A reference variable is an object.
An object is a reference type variable
An object may contain other objects.
An object may contain the references of other objects.
5.
Which special method returns a string representation of the object?
Group of answer choices
__init__ method
print method
__str__ method
constructor
6.
Class design should include ________
Group of answer choices
fields
constructor
accessor and mutator methods
other useful methods
All of the above
7.
What is max("Programming is fun")?
Group of answer choices
P
r
blank space character
u
8.
What is "Programming is fun"[1:3]?
Group of answer choices
Pr
Pro
ro
rog
In: Computer Science
Replace <missing value> and <missing code> with your answers. Your code should compute the factorial of n. For example, if n = 5, your code should compute the following 5 * 4 * 3 * 2 * 1 (which is 120).
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int factorial = <missing value>;
<missing code>
System.out.println("factorial = " + factorial);
In: Computer Science
What is the minimum and maximum number of zeros in a 4-bit string? Use roster notation and find the range of f. (The first elements in the range is f(0,0,0,0) = 0)
In: Computer Science
The measured values of the eight performance metrics listed in Example 10.2 for a system are 70, 10, 60, 20, 80, 30, 50, and 20%. Draw the Kiviat graph and compute its figure of merit. I just need the figure of merit. I have done the rest.
In: Computer Science
HOW TO:
1. Write the SQL statement to show workers with names that have
the letter ? before the last character.
2. Write the SQL statement to show all staff where the 2nd letter
of their last names is ′?′
3. Write the SQL statement to show all staff where the 1stletter of
their first names is ′?′ and 3rd letter ′ℎ'
DROP TABLE IF EXISTS staff;
CREATE TABLE staff (
staffNo VARCHAR(4) UNIQUE,
fName VARCHAR(16),
lName VARCHAR(16),
position VARCHAR(16),
sex VARCHAR(1),
dob DATETIME,
salary DOUBLE DEFAULT 0,
branchNo VARCHAR(4),
CONSTRAINT pk_staff PRIMARY KEY (staffNo)
);
INSERT INTO staff
(staffNo,fName,lName,position,sex,DOB,salary,branchNo)
VALUES
('SL21','John','White','Manager','M','1945-10-01',30000,'B005'),
('SG37','Ann','Beech','Assistant','F','1960-11-10',12000,'B003'),
('SG14','David','Ford','Supervisor','M','1958-03-24',18000,'B003'),
('SA9','Mary','Howe','Assistant','F','1970-02-19',9000,'B007'),
('SGS','Susan','Brand','Manager','F','1940-06-03',24000,'B003'),
('SL41','Julie','Lee','Assistant','F','1965-06-13',9000,'B005'),
('SB0', NULL, 'LN0', 'Manager', 'M', '2000-01-01 00:00:00',
9999,
'B000'),
('SB1', 'FN1', NULL, 'Manager', 'M', NULL, 9999, 'B000'),
('SB2', 'FN2', 'LN2', NULL, NULL, NULL, 9999, 'B000'),
('SB3', 'FN3', 'LN3', NULL, NULL, NULL, 9999, NULL),
('SB4', 'FN4', NULL, 'Manager', NULL, NULL, 9999, NULL),
('SB5', 'FN5', NULL, 'Supervisor', NULL, NULL, NULL, 'B001'),
('SB6', 'FN6', NULL, 'Assistant', NULL, NULL, 9999, 'B002'),
('SB7', 'FN7', NULL, 'Manager', NULL, NULL, NULL, 'B003'),
('SB8', 'FN8', NULL, 'Manager', NULL, NULL, 9999, 'B005'),
('SB9', 'FN9', NULL, 'Assistant', NULL, NULL, NULL, NULL);
In: Computer Science
1. Which of the following statements are true of snort? (select all that apply)
Snort rules are free through community distribution
Snort rules can be written by users/administrators.
Snort rules allow the software to understand all unwanted traffic
Snort rules are free through subscription
In: Computer Science
For this assignment, you will develop working examples
of a graphical user interface (GUI) and event handling and that
demonstrate the following:
Working code with screenshots of a Python GUI
application that includes 5 design widgets of your
choosing
Working code with screenshots of event handling in
Python based on 3 events of your choosing
Be sure to include a brief narrative of your code
where you explain what the code is doing.
Documentation Guidelines:
Use good programming style (e.g., indentation for readability) and document each of your program parts with the following items (the items shown between the '<' and '>' angle brackets are only placeholders. You should replace the placeholders and the comments between them with your specific information). Your cover sheet should have some of the same information, but what follows should be at the top of each program's sheet of source code. Some lines of code should have an explanation of what is to be accomplished, this will allow someone supporting your code years later to comprehend your purpose. Be brief and to the point. Start your design by writing comment lines of pseudocode. Once that is complete, begin adding executable lines. Finally run and test your program.
written in python code.
In: Computer Science
Assume that Employee class has method boolean isHighEarner() that returns true if employee's salary is above average and false otherwise. Write an iterative method highEarners that returns the ArrayList<Employee> of all high earners in the given list.
public ArrayList<Employee> highEarners( ArrayList<Employee> list) { } |
In: Computer Science
Define the URL and why analyst should care about its importance.
Explain the URL Parameters.
Explain cookies and why these matter.
In: Computer Science