Write a program in PYTHON which:
*Defines the following 5 functions:
whoamI()
This function prints out your name and PRINTS OUT any programming course you have taken prior to this course.
isEven(number)
This function accepts one parameter, a number, and PRINTS OUT a message telling if the numberer is even or odd. Keep in mind that a number is even if there is no remainder when the number is divided by two.
printEven(number)
This function accepts one parameter, a number, and PRINTS OUT all even values from 2 thru this number.
sumUp(number)
This function accepts one parameter, a number, and RETURNS the sum of ALL values from 1 up to this number
howmanyDigits(number)
This function accepts one parameter, a number, and RETURNS the number of digits contained in the value. (for example, if the value was 475, the function would return a 3. Hint: the simplest way to do this is to convert the number to a string .. then the length is accessible
* follows the function definition with main process statements which:
1.) calls the 'whoamI' function to that the program begins by outputting uses information
2.) prompt the user for a positive int and store it
If the user does not enter a valid number, reprompt. Continue this until a valid value
has been entered.
3.) present the user with 4 choices:
-find out if the number is even or odd
- printout all even values up to the number
-output the sum of all values from one to the number
- output the number of digits in the number
4.) Carry out the user’s choice. Be sure to call one of the functions that you have defined to do this.
If you wish you may put the main statements in a loop that repeats until the user chooses to exit.
In: Computer Science
Discuss several categories of common end-user technology problems.
Provide examples of problem-solving processes applied to typical support problems.
In: Computer Science
This Code Is Supposed To Be Performed In JAVA
1.) Create an abstract class DiscountPolicy. It should have a single abstract method computeDiscount that will return the discount for the purchase of a given number of a single item. The method has two parameters, count and itemCost. Create a driver class that tests this class and provide the UML.
2.) In a separate program, define DiscountPolicy as an interface instead of the abstract class. Create a driver class that tests this class and provide the UML.
Perform The Following
1.) Create an abstract class DiscountPolicy with a single abstract method computeDiscount that will return the discount for the purchase of a given number of a single item.
2.) Create a driver class
3.) Create an interface class DiscountPolicy with a single abstract method computeDiscount that will return the discount for the purchase of a given number of a single item.
4.) Create a driver class or use the same driver class that you created earlier
In: Computer Science
1. Enhance Binary System Conversion program with Lab05.2 Addition Function Write a program that accepts two positive binary number in string and perform the addition with Lab05.2 function enhance in a way can accept binary string in addition to decimal string (use input parameter to control the base2 or base10 addition) and output the as binary string. (Optional: Demonstrate 8 bits and 16 bits in length as inputs.) // the example function prototype for addition function below where accepting two numbers, m, and base as input; output the addition result as string type as return value; base should be 2 or 10 as required. string addFunction(string numberA, string numberB, int m, int base); Requirement: C++ programing; program an addition algorithm function that can both accept binary and decimal addition; convert each other if necessary. ................................................................................................................................................................................................................
Requirement:
1. Write a string addFunction that both can accept two positive binary numbers and decimal numbers in string.
2. The example function prototype for addition function below where accepting two numbers,m, and base as input; output the addition result as string type as return value; base should be 2 or 10 as required.
3. Output needs as binary string.
4. Example for String addFuntion(string numberA, string number B, int m, int base).
Program language: C++
In: Computer Science
Use the substitution method to prove the solutions for the following recurrences:
|
Recurrence |
Solution |
|
|
1 |
T(n) = T(n-1) + n |
O(n2) |
|
2 |
T(n) = T(n/2) + 1 |
O(lgn) |
|
3 |
T(n) = T(n/2) + n |
ϴ(nlgn) |
|
4 |
T(n) = 3T(n/2) + n |
O(nlg(3)). |
|
5 |
T(n) = 2T(n/2) + n2 |
O(n2) |
|
6 |
T(n) = 4T(n/2 + 2) + n |
O(n2) |
|
7 |
T(n) = 2T(n – 1) + 1 |
O(2n) |
|
8 |
T(n) = T(n – 1) + T(n/2) + n |
O(2n) |
|
9 |
T(n) = 4T(n/2) + cn. |
ϴ(n2) |
In: Computer Science
|
Write a C++ program that declares three one-dimensional arrays named miles, gallons and mpg. Each array should be capable of holding 10 elements. In the miles array, store the numbers 240.5, 300.0 189.6, 310.6, 280.7, 216.9, 199.4, 160.3, 177.4 and 192.3. In the gallons array, store the numbers 10.3, 15,6, 8.7, 14, 16.3, 15.7, 14.9, 10.7 , 8.3 and 8.4. Each element of the mpg array should be calculated as the corresponding element of the miles array divided by the equivalent element of the gallons array: for example mpg[0]=miles[0]/gallons[0]. Use pointers when calculating and displaying the elements of the mpg array. |
In: Computer Science
In: Computer Science
Suppose the RTT between your host and marist.edu is 10 ms, between your host and nyu.edu is 20 ms, and between your host and albany.edu is 30 ms.
Assume parallel transmissions are not considered in this problem, that is, objects are obtained one after another.
a) How long does it take to load the entire webpage with HTTP 1.0?
b) How long does it take to load the entire webpage with HTTP 1.1?
In: Computer Science
In: Computer Science
In java. Determine the value of each of the following expressions. (Format your answer with two decimal places.) a. Math.abs(-4) b. Math.abs(10.8) c. Math.abs(-2.5) d. Math.pow(3.2, 2) e. Math.pow(2.5, 3) f. Math.sqrt(25.0) g. Math.sqrt(6.25) h. Math.pow(3.0, 4.0) / Math.abs(-9) i. Math.floor(28.95) j. Math.ceil(35.2)
In: Computer Science
[15] Create a program called StreamingWords.java that modifies the StreamingIntegers.java from Task 1. The program should be able to do the following: JAVA
accepts user input. User inputs can be under the following forms:
one or more words, separated by white space.
User can provide multiple inputs (each input is completed after user hits Enter)
To stop inputting data, user will enter END then hit Enter.
reads inputs from users into a queue data structure. Each data element in the queue contains one sentence (from whence user starts typing until they hit Enter)
Once users finish entering input (END has been read), the program should begin remove the queue from the front, printing out the data elements in the queue.
The data elements should be printed out already sorted based on the number of words each element contains, regardless of the order of arrival or the total length of the characters. Each data element is to be printed on one line, and words within a data element are separated by a single white space.
In: Computer Science
A program called i2b.c was implemented with the intention to provide a binary representation of an integer. Unfortunately, the implementation has the following limitation:
Modify the existing source code of i2b.c such that:
PROGRAM BELOW
#include <stdio.h>
#define N 32
int main(int argc, char *argv[]) {
int n = 12345;
int binRep[N];
int i;
for (i = 0; i < N; i++) {
binRep[i] = 0;
}
i = 0;
while (n > 0) {
binRep[i] = n % 2;
n = n / 2;
i++;
}
for (i = N - 1; i >= 0; i--) {
printf("%d", binRep[i]);
}
printf("\n");
return 0;
}
In: Computer Science
Create a console application named TakeHomePay.cs under your homework directory (please refer to the earlier recorded Zoom sessions if you are not sure how to do it) that calculates the take-home pay for an employee. The two types of employees are salaried and hourly. Allow the user to input the employee’s first and last name, id, and type. If an employee is salaried, allow the user to input the salary amount. If an employee is hourly, allow the user to input the hourly rate and the number of hours clocked for the week. For hourly employees, overtime is paid for hours over 40 at a rate of 1.5 of the base rate. For all employees’ take-home pay, federal tax of 18% is deducted. A retirement contribution of 10% and a Social Security tax rate of 6% should also be deducted. Use appropriate constants and decision making structures.
In: Computer Science
Compare the strengths and weaknesses of SQL and NoSQL Databases.
1. What´s the meaning of each and how they work and store data. 2. In which scenarios is better to use one or the other. 3. What are the different types of SQL and NoSQL Databases. 4. What are the advantages of NoSQL over traditional SQL Databases. 5. When to use a NoSQL database instead of a relational database? 6. Which one is more scalable and flexible and in which scenarios. 7. Explain the use of transactions in SQL and NoSQL Databases. 8. Provide good examples on each. 9. Provide a good conclusion.
In: Computer Science
Working in a technical field can be confusing because of all the acronyms. For example, CPU means Central Processing Unit, HDMI means High-Definition Multimedia Interface, and SMART means Self-Monitoring Analysis and Reporting Technology. Wouldn’t it be nice if there was a way to translate all these acronyms automatically?
Create a new file named Translate.java that contains the following method:
public static String expandAll(String[] acronyms, String[] definitions, String text)
This method should replace every instance of an acronym in the text with its corresponding definition. For example, expandAll({"JMU", "CS"}, {"James Madison University", "Computer Science"}, "JMU CS rocks!") would return the string “James Madison University Computer Science rocks!”.
You may assume that the two arrays will be the same length. You may also assume that the text will be reasonable English with correct grammar. In particular, there will be only one space between each word. Each sentence will either end with a space or a newline character. Punctuation not at the end of the sentence will always be followed by whitespace (i.e., you should be able to handle “Hi, Mom” but you won’t have to handle “Hi,Mom”).
Be careful not to replace acronyms in the middle of a word. For example, the string “CS uses MACS!” should expand to “Computer Science uses MACS!”, not “Computer Science uses MAComputer Science!”. You might find it helpful to use a Scanner to process the string one word at a time.
In: Computer Science