Questions
<!doctype html> <html lang="en">   <head>     <title>Programming 1</title>     <meta charset="utf-8"/>           

<!doctype html>

<html lang="en">

  <head>

    <title>Programming 1</title>

    <meta charset="utf-8"/>                  

  </head>

  

  <body>

    <script type="text/javascript">

    

        function findAnswer() {

          var a = document.getElementById("box1").value;

          var b = document.getElementById("box2").value;

            

          if (typeof(a) == "number" && typeof(b) == "number") {

              var c = (a + b) % 5;

              document.getElementById("ans").innerHTML = c.toString();

            } else {

               document.getElementById("ans").innerHTML = "no Good";

            }

        }

    </script>

      

      <form action="#" method="post" name="form1" id="form1" class="form" >

       <label>Enter Numbers: </label> <br />

          <label> Value 1  : </label><input type="text" name="box1" id="box1"  value="10" /><br/>

          <label> Value 2  : </label><input type="text" name="box2" id="box2"  value="20" /><br/>

          <br/>               <br />

       <input type="button" name="Submit" id="submit" value="Submit" onclick="findAnswer();"/>

         </form>

    <p id ="ans"></p>

  </body>

</html>

    

Will the code from above print anything, if so what printed ? If not, say NONE.

In: Computer Science

####################################################################################################### ###################################################################################### ########################################################### ####

#######################################################################################################
######################################################################################
###########################################################
#############################using python###################
###########################################################
 
#  RQ1
from operator import add, sub
def a_plus_abs_b(a, b):
    """Return a+abs(b), but without calling abs.

    >>> a_plus_abs_b(2, 3)
    5
    >>> a_plus_abs_b(2, -3)
    5
    """
    if b < 0:
        f = _____
    else:
        f = _____
    return f(a, b)


#  RQ2
def two_of_three(a, b, c):
    """Return x*x + y*y, where x and y are the two largest members of the
    positive numbers a, b, and c.

    >>> two_of_three(1, 2, 3)
    13
    >>> two_of_three(5, 3, 1)
    34
    >>> two_of_three(10, 2, 8)
    164
    >>> two_of_three(5, 5, 5)
    50
    """
    return _____

In: Computer Science

# RQ3 def largest_factor(n): """Return the largest factor of n that is smaller than n. >>>...




#  RQ3
def largest_factor(n):
    """Return the largest factor of n that is smaller than n.

    >>> largest_factor(15) # factors are 1, 3, 5
    5
    >>> largest_factor(80) # factors are 1, 2, 4, 5, 8, 10, 16, 20, 40
    40
    """
    "*** YOUR CODE HERE ***"


         
#  RQ4
#  Write functions c, t, and f such that calling the with_if_statement and
#  calling the with_if_function do different things.
#  In particular, write the functions (c,t,f) so that calling  with_if_statement function returns the integer number 1, 
#  but calling the with_if_function function throws a ZeroDivisionError.

def if_function(condition, true_result, false_result):
    """Return true_result if condition is a true value, and
    false_result otherwise.

    >>> if_function(True, 2, 3)
    2
    >>> if_function(False, 2, 3)
    3
    >>> if_function(3==2, 3+2, 3-2)
    1
    >>> if_function(3>2, 3+2, 3-2)
    5
    """
    if condition:
        return true_result
    else:
        return false_result


def with_if_statement():
    """
    >>> with_if_statement()
    1
    """
    if c():
        return t()
    else:
        return f()

def with_if_function():
    return if_function(c(), t(), f())

def c():
    "*** YOUR CODE HERE ***"

def t():
    "*** YOUR CODE HERE ***"

def f():
    "*** YOUR CODE HERE ***"



In: Computer Science

In Java, write the method public static void insertUnique(List l, T e), user of the ADT...

In Java, write the method public static void insertUnique(List l, T e), user of the ADT List. The method takes a list l and an element e and inserts the element at the end of the list only if it is not already there. Example 0.2. If l : A → B → C, then after calling insertUnique(l, "C"), the list does not change. Calling insertUnique(l, "D") will make l be : A → B → C → D.

In: Computer Science

construct the trace table or trace table list for the function call CR (111) where the...

construct the trace table or trace table list for the function call CR (111) where the definition of CR () is
bool CR ( int n )
{
bool w,x,y,z,r;
int c;
c= 3*n;
c + = 16;
c=c%5;
w=c==4;

In: Computer Science

Implement a calculator (not postfix notation) using Swift Programming Language(Swift 3, basic ios app). Please use...

Implement a calculator (not postfix notation) using Swift Programming Language(Swift 3, basic ios app). Please use MVC model(CalculatorBrain.swift can be the model and ViewController.swift can be the view). Also please post the sreenshot of the storyboard that you make.

Requirements:

Implement add subtract, multiply, divide, pi, sqrt, Euler’s natural number (e), co-sine and equals.

Ensure you have the ability to handle multiple operations in sequence

Implement the ability to enter floating point numbers into the display

Add 4 more buttons (ex. sine)

Handle multiple operations in a sequence.

Add a memory function to your calculator that stores and retrieves a number. Implement the following buttons at the top of the keyboard

MC = Memory clear sets memory to 0

MR – Memory recall uses the number in memory acting as it you typed that number in yourself

MS – Memory Store puts the number on display into memory

M+ – Memory takes the number on the display, adds it to the memory, and puts the result into memory.

Implement a clear (C) button. If the clear button is pressed once, it should take whatever was typed before the last enter and put it to 0. If the clear is entered twice, it should clear the stack.

Show the history of every operand and operation input by displaying it.  

In: Computer Science

Problem 2: show all work   A. Find the complement of F = WX + YZ. B....

Problem 2: show all work  

A. Find the complement of F = WX + YZ. B. Show that FF’ = 0 C. Show that F + F’ = 1

In: Computer Science

I need an answer in C++, please TITLE PRIME FACTORIZATION USING AN ARRAY-BASED STACK INTRODUCTION This...

I need an answer in C++, please

TITLE

PRIME FACTORIZATION USING AN ARRAY-BASED STACK

INTRODUCTION

This project revisits one of the problems in Project 2, and it will re-use a function within the solution developed there.

An integer is prime if it is divisible only by itself and 1. Every integer can be written as a product of prime numbers, unique except for their order, called its prime factorization. For example,

1776 = 37 x 3 x 2 x 2 x 2 x 2.

DESCRIPTION

Design, implement, document, and test an interactive program that reads positive integers from the terminal and writes their prime factorizations to the screen. The program should list the factors of each integer in decreasing order, as in the example above, and should terminate when the user enters 0 or a negative value.

INPUT

The program's input is positive integers, entered from the terminal, terminated by 0 or a negative value.

OUTPUT

The program's output consists of prompts for the input values and the input values' prime factorizations. It writes this output to the terminal.

ERRORS

The program can assume that its input is integers; it need not detect any errors.

EXAMPLE

A session with the program might look like this:

  Enter a positive integer (0 to stop): 1776
    Prime factors: 1776 = 37 x 3 x 2 x 2 x 2 x 2

  Enter a positive integer (0 to stop): 6463
    Prime factors: 6463 = 281 x 23

  Enter a positive integer (0 to stop): 349856
    Prime factors: 349856 = 29 x 29 x 13 x 2 x 2 x 2 x 2 x 2

  Enter a positive integer (0 to stop): 36423479
    Prime factors: 36423479 = 36423479

  Enter a positive integer (0 to stop): 1
    Prime factors: 1 = 1

  Enter a positive integer (0 to stop): 0
    

OTHER REQUIREMENTS

Implement a stack abstract data type in a class in which a typedef statement specifies the type of the stack's items. Use a sequential (array-based) stack implementation. As the program identifies prime factors, it should save them by pushing them onto a stack of integers provided by this class.

If d >= 2 is the smallest integer that divides an integer n, then d is prime. Therefore the program can identify prime factors (in ascending order) by repeatedly identifying the smallest factor of the target value and then dividing the target value by the factor. The program need not test that these smallest factors are prime or attempt to list only prime values; this will happen automatically.

Thus, to identify the prime factors of n, first find the smallest factor that divides n, push it onto the stack, and divide n by the factor. Then find the smallest factor of the new value of n; handle it the same way. Continue in this way until n = 1. Then pop and print the values until the stack is empty.

This scheme identifies prime factors in order of increasing magnitude; saving the values on the stack and then popping and printing them displays them in decreasing order, as specified.

HINT

Recall that you wrote a function that returns the smallest factor of its positive integer argument back in Project 2. You can re-use that function in this project.

HAND IN

See About Programming Assignments for a description of what to hand in: design document, user document, code, tests, and summary.

Question: If we wanted to report each integer's prime factors in increasing order, would the stack be necessary or helpful? Explain.

Project 2:

PRIME FACTORIZATION

The smallest nontrivial factor of a positive integer is necessarily prime. (Can you prove this?) Write a program that takes advantage of this fact in a recursive function that writes the prime factors of an integer to the terminal in ascending order.

A run of the program that exercises this function might look like this:

          Enter a positive integer: 5432
          The prime factors of 5432 are 2 2 2 7 97
    

Hint: Begin by writing a function that returns the smallest factor (greater than 1) of its positive integer argument. The recursive function will call this one.

QUESTION: How would you modify the function to print the prime factors in descending order?

In: Computer Science

Given the array a and the binary search function below, list all activations in finding t=19....

  1. Given the array a and the binary search function below, list all activations in finding t=19. (15 Points)

-9

-5

-2

0

1

3

7

11

17

19

21

25

27

31

37

41

a

  

index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

int search(int a[], int t, int l, int r){

if(l<=r){

int m=(l+r)/2;

if(t==a[m]) return m;

else if (t<a[m]) return search(a, t, l,m-1);

else return search(a, t, m+1, r)

}

return -1;

}

  1. Use array as storage body to implement a circular template queue class. (20 Points)

In: Computer Science

Need it ASAP!!! Write a complete Java program to compute personal income tax. Your program should...

Need it ASAP!!!

Write a complete Java program to compute personal income tax. Your program should prompt the user to enter the taxable income (double) and output the income tax (double) according to the table below:

First $20,000 0 Next $20,000 ($20,001 to $40,000) 10 Next $20,000 ($40,001 to $60,000) 20 The remaining (Above $60,000) 30

The tax payable should be rounded to 2 decimal places. The name of this program (class) will be Tax

In: Computer Science

Write two python codes for a TCP client and a server using a Socket/Server Socket. The...

Write two python codes for a TCP client and a server using a Socket/Server Socket. The client sends a file name to the server. The server checks if there is any integer value in the file content. If there is an integer number, the server will send a message to the client “Integer exists” otherwise, the message “Free of Integers”

In: Computer Science

The Learning Journal is a tool for self-reflection on the learning process. In addition to completing...

The Learning Journal is a tool for self-reflection on the learning process. In addition to completing directed tasks, you should use the Learning Journal to document your activities, record problems you may have encountered and to draft answers for Discussion Forums and Assignments. The Learning Journal should be updated regularly (on a weekly basis), as the learning journals will be assessed by your instructor as part of your Final Grade.

Your learning journal entry must be a reflective statement that considers the following questions:

1. Describe what you did. This does not mean that you copy and paste from what you have posted or the assignments you have prepared. You need to describe what you did and how you did it.

2. Describe your reactions to what you did.

3. Describe any feedback you received or any specific interactions you had. Discuss how they were helpful.

4. Describe your feelings and attitudes.

5. Describe what you learned.

Another set of questions to consider in your learning journal statement include:

1. What surprised me or caused me to wonder?

2. What happened that felt particularly challenging? Why was it challenging to me?

3. What skills and knowledge do I recognize that I am gaining?

4. What am I realizing about myself as a learner?

5. In what ways am I able to apply the ideas and concepts gained to my own experience?

Finally, describe one important thing that you are thinking about in relation to the activity.

Minimum of 500 words.

These weeks Topics

Topics:

  • Inheritance: Superclasses and Subclasses
  • Polymorphism: Overriding Methods
  • "This" and "Super"
  • Interfaces

In: Computer Science

JAVA Code Learning objectives; File I/O practice, exceptions, binary search, recursion. Design and implement a recursive...

JAVA Code

Learning objectives; File I/O practice, exceptions, binary search, recursion.

Design and implement a recursive version of a binary search.  Instead of using a loop to repeatedly check for the target value, use calls to a recursive method to check one value at a time.  If the value is not the target, refine the search space and call the method again.  The name to search for is entered by the user, as is the indexes that define the range of viable candidates can be entered by the user (that are passed to the method). The base case that ends recursion is either finding the value within the range or running out of data to search.  The program will work on an array of sorted String objects read in from a text file.  Your program will generate an exception, that provides a message to the user, if the file can't be found or if the starting index is after the ending index.  You will create your own text file of first names in alphabetical order (binary search required ordering) to test your program.  

In: Computer Science

What is the difference between a superkey, candidate key, and a primary key in a normalized...

  1. What is the difference between a superkey, candidate key, and a primary key in a normalized database?

In: Computer Science

You are to create a program to request user input and store the data in an...

You are to create a program to request user input and store the data in an array of structures, and then display the data as requested. The data you are collecting refers to a set of images. The images are OCT images taken of the lining of the bladder. The data you provide will help diagnose the image as cancerous or not, but your code does not need to do that at the moment.

1) Define a global structure that contains the following information:

a) File number (must be >0)
b) Diagnosis number (1-8)
c) Number of layers in the image
d) Maximum average intensity of a single row (should be a float) e) Width of brightest layer

2)
be a global variable.

Declare an array of 9 of the structures in #1. This array should

  1. 3) Initialize each of the file numbers in the array to -1.

  2. 4) Create a loop that will continue asking the user for the above

data until the file number 0 is given, or until information has been provided for 9 images.

5) If the user provides a file number less than 0, ask again. Do not ask for further information if the user provides a file number equal to 0.
6) If the user provides a diagnosis number that is not between 1 and 8, ask again.

7) Store the data in the array of structures in the order it is provided.

8) Write a function to display the information for a particular file number. If the file number was not found, nothing is displayed. The function will return a 1 if the file number was found or a 0 if the file number was not in the array.

9) In your main function, after the loop which requests the data, create another loop that will request a file number from the user and then call the function written for #8 to display the data for that file number. This loop will continue until a file number is provided that is not found.

10) In your main function, after the code for #9, add a loop that will display the information for all items stored in the array in order.

C++ Coding Please

In: Computer Science