Questions
1. Enhance Binary System Conversion program with Lab05.2 Addition Function Write a program that accepts two...

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)...

Use the substitution method to prove the solutions for the following recurrences:

Recurrence

Solution

1

T(n) = T(n-1) + n

O(n­2)

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(n­2)

6

T(n) = 4T(n/2 + 2) + n

O(n­2)

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.  

ϴ(n­2)

In: Computer Science

Write a C++ program that declares three one-dimensional arrays named miles, gallons and mpg. Each array...

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

Research starting an online business selling goods. What are at least 5 things you need to...

  1. Research starting an online business selling goods. What are at least 5 things you need to make sure you understand before selling your first item online to be compliant with regulations? Explain each one of these and why they are important; including examples/scenarios.

In: Computer Science

Suppose you request a webpage that contains 10 images. Suppose the transmission time for a webpage...

  1. Suppose you request a webpage that contains 10 images. Suppose the transmission time for a webpage is 10ms, and the transmission time for an image is 5ms. Suppose that 10 images are located on 3 different servers: 5 of them are saved on marist.edu with the webpage, 2 are saved on nyu.edu, and 3 are saved on albany.edu.

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

list 5 history fact about professional conduct in computer science ( ex: stealing data, copyright, leaking...

list 5 history fact about professional conduct in computer science ( ex: stealing data, copyright, leaking data,....) and give a reason why you picked this for each fact.

In: Computer Science

In java. Determine the value of each of the following expressions. (Format your answer with two...

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...

  1. [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

    1. accepts user input. User inputs can be under the following forms:

      1. one or more words, separated by white space.

      2. User can provide multiple inputs (each input is completed after user hits Enter)

      3. To stop inputting data, user will enter END then hit Enter.

    2. 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)

    3. 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.  

    4. 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...

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:

  • It was hard-coded to only convert a single number.
  • The conversion algorithm only works for positive number.

Modify the existing source code of i2b.c such that:

  • i2b.c can now accept a single command line argument. This command line argument is assumed to be a valid signed integer.
  • i2b.c will convert the command line argument into its corresponding binary representation with the following condition:
    • The representation is an array of integers.
    • This array has a length of 32.
    • This array contains the binary representations of the integer argument.
    • Index 0 contains the most significant bit, and index 31 contains the least significant bit.
  • i2b.c will print out the final binary representation on a single line without any space between the bits.

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...

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...

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...

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

VISUAL BASICS Determine if each of the following statements is true or false. (1 point each,...

VISUAL BASICS

Determine if each of the following statements is true or false. (1 point each, 13 total)

True/False Question           

True or False

Several variables with different data types can be declared in a single Visual Basic statement.

Several variables with the same data types can be declared in a single Visual Basic statement.

Run-time errors are always detected by the compiler.

A logic error results in the abrupt termination of program execution.

The Visual Basic IDE informs the programmer of a syntax error.

The Visual Basic IDE informs the programmer of a logic error.

Errors that violate the rules of Visual Basic are called semantic errors.

If not initialized at declaration, Boolean variables are initialized to False.

Modulus division returns the remainder resulting from division.

Constant declarations must be placed in the beginning of a program.

Visual Basic sees no difference between the variables intDefects and intDEFECTS.

Keywords make good variable identifiers.

Private is a keyword.

In: Computer Science

A checksum is a value that is computed based upon some information. It is functional in...

A checksum is a value that is computed based upon some information. It is functional in the sense that given the same information, the exact same value will be computed. Checksums are often used when information is being transmitted over a network.

This lets the receiving end know if the information was transmitted accurately. All published books have a unique 10 and 13 digit ISBN number. This stands for International Standard Book Number.

Your textbook in this class has an ISBN-10 number. The first 9 digits (which may include leading zeros) are the information part of the ISBN-10 number. The 10th digit is a checksum which is calculated from the other 9 digits using the following formula where d1 is the first digit beginning on the left, d2 is the second digit, etc.: ( (1* d1) + (2 * d2) + (3 * d3) + (4 * d4) + (5 * d5) + (6 * d6) + (7 * d7) + (8 * d8) + (9 * d9) ) % 11 Because the large sum then uses modulus 11 arithmetic, the possible values for the checksum are the numbers 0 through 10.

According to the ISBN-10 convention, the checksum can only be a single character (digit) so if the checksum is 10 the last character is denoted as X (Roman numeral for 10) . Write a program that loops, prompting the user to enter the first 9 digits into an input dialog box. You must parse the input value as a single integer. Compute the checksum digit and output the complete 10 digit ISBN number using a Confirm Dialog asking if the user wants to enter another 9 digit number. If the user selects the YES button, then loop. If NO is selected, the program will end. An example of this program in action (without dialog boxes) is: Enter the first 9 digits of an ISBN number: 013601267 The ISBN-10 number is: 0136012671 Do you want to enter another? Enter the first 9 digits of an ISBN number: 013031997 The ISBN-10 number is: 013031997X Do you want to enter another? Extracting the Digits from the Integer The algorithm to compute the checksum is relatively simple, so the interesting part of this program is figuring out how to extract each of the 9 digits from the integer. Hint: Section 3.13 (9th Edition) Case Study: Lottery shows you how to extract the digits from a 2-digit number. Remember, I am forcing you to turn the String from the dialog box into an integer. I will not accept a solution that doesn't do this. When the ISBN number has leading zeros, it makes the problem more complex because you must go from a String to an int and back to a String again.

java code please

In: Computer Science

In PYTHON A non-governmental organization needs a program to calculate the amount of financial assistance for...

In PYTHON

A non-governmental organization needs a program to calculate the amount of financial assistance for needy families. The formula is as follows:

•If the annual household income is between $30,000 and $40,000 and the household has at least three children, the amount is $1,000 per child.

•If the annual household income is between $20,000 and $30,000 and the household has at least two children, the amount is $1,500 per child.

•If the annual household income is less than $20,000, the amount is $2,000 per child. Implement a function for this computation. Write a program that asks for the household income and number of children for each applicant, printing the amount returned by your function. Use –1 as a sentinel value for the input.

In: Computer Science