Questions
Using the idea of the Bubble Sort algorithm, design an algorithm in pseudocode that gets 3...

Using the idea of the Bubble Sort algorithm, design an algorithm in pseudocode that gets 3 numbers a, b, c, from the user, and prints the 3 numbers in ascending order

In: Computer Science

In each of the projects that follow, you should write a program that contains an introductory...

In each of the projects that follow, you should write a program that contains an introductory docstring. This documentation should describe what the program will do (analysis) and how it will do it (design the program in the form of a pseudocode algorithm). Include suitable prompts for all inputs, and label all outputs appropri- ately. After you have coded a program, be sure to test it with a reasonable set of legitimate inputs.

5 An object’s momentum is its mass multiplied by its velocity. Write a pro- gram that accepts an object’s mass (in kilograms) and velocity (in meters per second) as inputs and then outputs its momentum.

6 The kinetic energy of a moving object is given by the formula KE=(1/2)mv2, where m is the object’s mass and v is its velocity. Modify the program you created in Project 5 so that it prints the object’s kinetic energy as well as its momentum.

Write a program that takes as input a number of kilometers and prints the corresponding number of nautical miles. Use the following approximations:

- A kilometer represents 1/10,000 of the distance between the North Pole and the equator.

- There are 90 degrees, containing 60 minutes of arc each, between the North Pole and the equator.

- A nautical mile is 1 minute of an arc.

*please use IDLE( python 3.7)

In: Computer Science

Please convert decimal value -32760 into 2's complement binary value

Please convert decimal value -32760 into 2's complement binary value

In: Computer Science

Part 2: Insertion Sort Q3. Arrange the following arrays in ascending order using Insertion sort. Show...

Part 2: Insertion Sort

Q3. Arrange the following arrays in ascending order using Insertion sort. Show all steps.

7          11        2          9          5          14

Q4. State the number of comparisons for each pass.

Pass

# comparisons

1st

2nd

3rd

4th

5th

In: Computer Science

convert 0x41BA8000 to IEEE-754 floating-point value

convert 0x41BA8000 to IEEE-754 floating-point value

In: Computer Science

Using Java: Implement print2D(A) so that it prints out its 2D array argument A in the...

Using Java:

  1. Implement print2D(A) so that it prints out its 2D array argument A in the matrix form.

  2. Implement add2Ds(A,B) so that it creates and returns a new 2D array C such that C=A+B.

  3. Implement multiScalar2D(c,A) so that it creates and returns a new 2D array B such that

    B=c×A.

  4. Implement transpose2D(A), which creates and returns a new 2D array B such that B is

    the transpose of A.

Your output should look like the following:A=

1234 5678 9 10 11 12

B=

2468 10 12 14 16 18 20 22 24

A+B=

3 6 9 12 15 18 21 24 27 30 33 36

5XA=

51015 20 25 30 35 40 45 50 55 60

Transpose of A =

159 2 6 10 3 7 11 4 8 12

Note that your methods should work for 2D arrays of any sizes.

In: Computer Science

convert 0x41BA8000 to IEEE-754 floating-point value

convert 0x41BA8000 to IEEE-754 floating-point value

In: Computer Science

Complete the code that inserts elements into a list. The list should always be in an...

Complete the code that inserts elements into a list. The list should always be in an ordered state.

#include <stdio.h>
#include <stdlib.h>

/* list of nodes, each with a single integer */
struct element {
struct element *next;
int value;
};

/* protypes for functions defined after main */
struct element *elementalloc(void);
struct element *listinitialize();
struct element *insertelement(struct element *, int);
void printlist(struct element *);

/* main
* Creates an ordered list
* Elements added to the list must be inserted maintaining the list
* in an ordered state
*/
int main() {
struct element *listhead = NULL;
listhead = listinitialize();
for (int i = 3; i < 100; i+=11){
listhead = insertnewelement(listhead, i);
}
printlist(listhead);
}

/* allocate memory for a new list element */
struct element *elementalloc(void) {
return (struct element *)malloc(sizeof(struct element));
}

/* simple list initialization function */
struct element *listinitialize() {
const int numbers[7] = {4, 9, 13, 18, 27, 49, 60};
struct element *newlist = NULL;
struct element *tail = NULL;
struct element *temp = NULL;
for (int i = 0; i < 7; i++) {
if (newlist == NULL) {
newlist = elementalloc();
newlist->next = NULL;
newlist->value = numbers[i];
tail = newlist;
} else {
temp = elementalloc();
temp->value = numbers[i];
temp->next = NULL;
tail->next = temp;
tail = tail->next;
}
}
return newlist;
}

/* function to insert elements into an ordered list */
struct element *insertnewelement(struct element *listhead, int x) {
struct element *newelement;
newelement = elementalloc();

struct element *iter = listhead;
while( ) {

}

return listhead;
}

/* print the list and the respective memory locations in list order */
void printlist(struct element *listhead)
{
while (listhead != NULL) {
printf("Memory: %p contains value: %d\n", listhead, listhead->value);
listhead = listhead->next;
}
}

In: Computer Science

How do I change my if statements into while and for loops, so that I can...

How do I change my if statements into while and for loops, so that I can make my bot go straight and turn exactly 12 times.

/***********************************************************************
* Exp7_1_RotaryEncoder -- RedBot Experiment 7_1
*
* Knowing where your robot is can be very important. The RedBot supports
* the use of an encoder to track the number of revolutions each wheels has
* made, so you can tell not only how far each wheel has traveled but how
* fast the wheels are turning.
*
* This sketch was written by SparkFun Electronics, with lots of help from
* the Arduino community. This code is completely free for any use.
*
* 8 Oct 2013 M. Hord
* Revised, 31 Oct 2014 B. Huang
***********************************************************************/

#include <RedBot.h>
RedBotMotors motors;

RedBotEncoder encoder = RedBotEncoder(3,9); // initializes encoder on pins A2 and 10
int buttonPin = 12;
int countsPerRev = 192; // 4 pairs of N-S x 48:1 gearbox = 192 ticks per wheel rev

// variables used to store the left and right encoder counts.
int lCount;
int rCount;

void setup()
{
pinMode(buttonPin, INPUT_PULLUP);
Serial.begin(9600);
Serial.println("left right");
Serial.println("================");
}

void turn()

{

long lCount = 0;

long rCount = 0;

long targetCount;

float numRev;

motors.leftMotor(-80);

motors.rightMotor(0);
// variables for tracking the left and right encoder counts

long prevlCount, prevrCount;

long lDiff, rDiff; // diff between current encoder count and previous count

encoder.clearEnc(BOTH); // clear the encoder count

delay(100); // short delay before starting the motors.

while (lCount < 0)

{

// while the right encoder is less than the target count – debug print

// the encoder values and wait – this is a holding loop.

lCount = encoder.getTicks(LEFT);

rCount = encoder.getTicks(RIGHT);

Serial.print(lCount);

Serial.print("\t");

Serial.print(rCount);

Serial.print("\t");

Serial.println(targetCount);

// calculate the rotation “speed” as a difference in the count from previous cycle.

lDiff = (lCount - prevlCount);

rDiff = (rCount - prevrCount);

// store the current count as the “previous” count for the next cycle.

prevlCount = lCount;

prevrCount = rCount;

}

delay(500); // short delay to give motors a chance to respond.
motors.brake();

}


void loop(void)
{
  
// wait for a button press to start driving.

  
if(digitalRead(buttonPin) == LOW)
{
encoder.clearEnc(BOTH); // Reset the counters.
delay(500);
motors.drive(180); // Start driving forward.
}
  

// store the encoder counts to a variable.
lCount = encoder.getTicks(LEFT); // read the left motor encoder
rCount = encoder.getTicks(RIGHT); // read the right motor encoder

// print out to Serial Monitor the left and right encoder counts.
Serial.print(lCount);
Serial.print("\t");
Serial.println(rCount);

// if either left or right motor are more than 5 revolutions, stop
  
if ((lCount >= 5*countsPerRev) || (rCount >= 5*countsPerRev ))
{
  
turn();
encoder.clearEnc(BOTH);
//motors.brake();
delay(500);
motors.drive(180); // Start driving forward.
  
  
}
  
}

In: Computer Science

convert 0x41BA8000 to IEEE-754 floating-point value

convert 0x41BA8000 to IEEE-754 floating-point value

In: Computer Science

Write a JavaFX application that presents a button and a circle. Every time the button is...

Write a JavaFX application that presents a button and a circle. Every time the button is pushed, the circle should be moved to a new random location within the window.

This must only be one .java file. I cannot use

import javafx.geometry.Insets;

import javafx.scene.canvas.Canvas;

import javafx.scene.canvas.GraphicsContext;

import javafx.scene.layout.HBox;

This is what I have so far:

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class CircleJumper extends Application
{
public double circlePositionX = 300;
public double circlePositionY = 300;
  
@Override
   public void start(Stage primaryStage)
{
Circle circle = new Circle(circlePositionX, circlePositionY, 70);
circle.setFill(Color.BLUE);

//create button to create new circle
Button push = new Button("PRESS!");
push.setOnAction(this::processButtonPress);
  
  
Group root = new Group(circle, push);
Scene Scene = new Scene(root, 700, 500, Color.WHITE);
  
       primaryStage.setTitle("Circle Jumper"); // Set the stage title
       primaryStage.setScene(Scene); // Place the scene in the stage
       primaryStage.show(); // Display the stage
   }
  
public void processButtonPress(ActionEvent event)
{   
Circle circle = new Circle(Math.random(), Math.random(), 50);
circle.setFill(Color.BLUE);
Group root = new Group(circle);
Scene Scene = new Scene(root, 700, 500, Color.WHITE);
}
  
public static void main(String[] args)
{
launch(args);
}

In: Computer Science

Create, and write, three people's names into an external file named "names.txt."  You should overwrite the file...

  1. Create, and write, three people's names into an external file named "names.txt."  You should overwrite the file if it already exists.
  2. Read those three people's names into the program from the text file and print them out to the end user's console.
  3. Append three more people's names to the external file named "names.txt."
  4. Read those six people's names from the text file into the program and print them out to the end user's console.

Then try:

  • Get the filename from the end user for all file I/O
  • Get the number of names from the end user for all file I/O
  • Use loops to get the names from the end user for all file I/O
  • Use a loop to repeat the program if the end user desires

***

ADDITIONAL NOTES IN CASE YOU ARE HAVING I/O TROUBLES:

//Writing from your Source Code to an External .txt File:
PrintWriter outputFile = new PrintWriter("names.txt");        
outputFile.println("Mike");
outputFile.close();

*************
//Appending from your Source Code to an External .txt File:
FileWriter fileWrite = new FileWriter("names.txt", true);
PrintWriter outWrite = new PrintWriter(fileWrite);
outWrite.println("John");
outWrite.close();

*************
//Reading from an external .txt File into your Source Code:
File myFile = new File("Customers.txt");
Scanner inputFile = new Scanner(myFile);
String str = inputFile.nextLine();
inputFile.close();

In: Computer Science

Use Java to rewrite the following pseudo-code segment using a loop structure without goto, break, or...

Use Java to rewrite the following pseudo-code segment using a loop structure without goto, break, or any other unconditional branching statement:

k = (j+13)/27; //assume i,j,k are integers properly declared.

loop:

if k > 10 then goto out

k=k+1.2;

i=3*k-1;

goto loop;

out: …

In: Computer Science

Given the Linux shell command descriptions, please write down the corresponding shell commands in a terminal...

Given the Linux shell command descriptions, please write down the corresponding shell commands in a terminal window.

            a) list the current directory contents with the long format

            b) print the name of the working directory

            c) change directory to the root directory

            d) change the permissions of file "myfile" (owned by yourself) so that (1)you can read/write, but cannot execute; (2) all other users cannot read/write/execute this file.

            e) make a new directory called “mydir”

In: Computer Science

Are you planning to allow clients to ACCESS YOUR RAW DATA (Big Data) or are you...

Are you planning to allow clients to ACCESS YOUR RAW DATA (Big Data) or are you planning on analyzing that Big Data and presenting FINISHED ANALYTICS to clients?? If you are planning on allowing many many customers to access your data, then how big is your helpdesk and how big does your network throughput need to be to allow customer-access?  And what about Security?  If you're mostly in the cloud - is your CSP going to provide sufficient security?  If you are mostly NOT in the cloud - what's your general plan for Security?

In: Computer Science