Questions
Write a Program(code) in Python that performs a large number of floating-point operations and an equal...

Write a Program(code) in Python that performs a large number of floating-point operations and an equal number of integer operations and compares the time required. Please attach an output.

In: Computer Science

Encrypt the given plaintext with the key. Built the key matrix (big size). And show how...

Encrypt the given plaintext with the key. Built the key matrix (big size). And show how you get each letter ciphertext (you can do that by making shapes and arrows in key matrix).

No need to draw key matric again and again.   

Show all your work. If you just write cipher text and key matric without showing (shapes and arrow on key matrix) that how you get the ciphertext then your marks will be deducted.

key :  alphabets

plaintext :   smartness

In: Computer Science

Using JAVA 2. A run is a sequence of adjacent repeated values. Write a code snippet...

Using JAVA

2. A run is a sequence of adjacent repeated values. Write a code snippet that generates a sequence of 20 random die tosses in an array and that prints the die values, marking the runs by including them in parentheses, like this:

1 2 (5 5) 3 1 2 4 3 (2 2 2 2) 3 6 (5 5) 6 (3 3)

Use the following pseudocode:

inRun = false

for each valid index i in the array

If inRun

If values [i] is different from the preceding value

Print )

inRun = false

If not inRun

If values[i] is the same as the following value

Print (

inRun = true

Print values[i]

//special processing to print last value

If inRun and last value == previous value, print  “ “ + value + “)”)

else if inRun and last value != previous value, print  “) “ + value )

else print “ “ + last value

3.

Implement a theater seating chart  as a two-dimensional array of ticket prices, like this:

{10, 10, 10, 10, 10, 10, 10, 10, 10, 10}

{10, 10, 10, 10, 10, 10, 10, 10, 10, 10}

{10, 10, 10, 10, 10, 10, 10, 10, 10, 10}

{10, 10, 20, 20, 20, 20, 20, 20, 10, 10}

{10, 10, 20, 20, 20, 20, 20, 20, 10, 10}

{10, 10, 20, 20, 20, 20, 20, 20, 10, 10}

{20, 20, 30, 30, 40, 40, 30, 30, 20, 20}

{20, 30, 30, 40, 50, 50, 40, 30, 30, 20}

{30, 40, 50, 50, 50, 50, 50, 50, 40, 30}

Write a code snippet that:

- uses a for loop to print the array with spaces between the seat prices

- prompts users to pick a row and a seat using a while loop and a sentinel to stop the loop.

- outputs the seat price to the user.

4. A pet shop wants to give a discount to its clients if they buy one or more pets and at least three other items. The discount is equal to 20 percent of the cost of the other items, but not the pets.

Write a program that prompts a cashier to enter each price and then a Y for a pet or N for another item. Use a price of –1 as a sentinel. Save the price inputs in a double(type) array and the Y or N in a corresponding boolean (type) array.

Output the number of items purchased, the number of pets purchased, the total sales amount before discount and the amount of the discount.

-----------------

Thank you so much!

In: Computer Science

Suppose you are given an integer c and an array, A, indexed from 1 to n,...

Suppose you are given an integer c and an array, A, indexed from 1 to n, of n integers in the range from 0 to 5n (possibly with duplicates). i.e. 0 <= A[i ] <= 5n " I = {1, .., n}.

a.) Write an efficient algorithm that runs in O(n) time in a pseudo code for determining if there are two integers, A[i] and A[j], in A whose sum is c, i.e. c = A[i] + A[j], for 1 <= i < j <= n. Your algorithm should return a set of any pair of those indices (i , j). If there were no such integers, return (0, 0).

b.) Implement your algorithm of Q7 either in Python programming language where A[1:10] = [30, 25, 10, 50, 35, 45, 40, 5, 15, 20] and c = 40.

In: Computer Science

Answer the following question from the perspective of AVR (C language) How to set the data...

Answer the following question from the perspective of AVR (C language)

How to set the data direction (output/input) in (AVR, c language)?

Write a statement to turn ON a pin, say D3.

Write a statement to turn OFF a pin, say D3.

How to toggle a pin?

In: Computer Science

4.4 Formulate the functional requirements for the calendar management system described below. Limit the length of...

4.4 Formulate the functional requirements for the calendar management system described below.

Limit the length of the SRS to no more than two pages. This calendar management software

allows the user to schedule personal activities such as meetings and tasks to be performed.

An activity can take place on a future date during a certain period of time. An activity can

take place for several consecutive days. Each activity has a brief mnemonic description. An

activity can be a recursive activity, which takes place repeatedly every hour, every day, every

week, or every month. A user can schedule an activity using a month-by-month calendar

to select the date or dates, and then zooms in to select the begin time and end time on a

date. The calendar system shall notify the user by email, text message, or phone call the day

before and on the activity day. The user can review past activities and modify the schedule

including updating and deleting activities.

Take the system in 4.4 above, draw a UML class diagram as a domain model (hint: perform the domain modeling steps)

In: Computer Science

In C++, Complete the Code & Show the output. Schedule the following process using Shortest Job...

In C++, Complete the Code & Show the output.

Schedule the following process using Shortest Job First Scheduling algorithm

Porcress Burst time Arrival time
1 8 0
2 2 0
3 1 0
4 4 0

Compute the following and show the output

a) Individual Waiting time & Turnaround time

b) Average Waiting time & Turnaround time

c) Display the Gantt chart (Order of Execution)   

#include

using namespace std;

//structure for every process

struct Process {

int pid; // Process ID

int bt; // Burst Time

int art; // Arrival Time

};

// Soring Process based on Burst Time Descending Order

void sort(Process a[],int n) {

//-------------Sorting

// Write Code Here

}

// function to find the waiting time for all processes

void WaitingTime(Process proc[], int n, int wt[])

{

// Write Code Here

}

// function to calculate turn around time

void TurnAroundTime(Process proc[], int n, int wt[], int tat[])

{

// Write Code Here

}

int main() {

const int n=4;

Process proc[] = { { 1, 8, 0 },

{ 2, 2, 0 },

{ 3, 1, 0 },

{ 4, 4, 0 } };

int wt[n], tat[n], total_wt = 0,total_tat = 0;

// Sort Processes based on Burst Time

sort(proc,n);

// Function to find waiting time of all processes

WaitingTime(proc, n, wt);

// Function to find turn around time for all processes

TurnAroundTime(proc, n, wt, tat);

  

// Write Code Here

cout<<"\n\nOrder of Execution ";

for (int i = 0; i < n; i++) {

cout<<"P"<";

}

return 0;

}

In: Computer Science

Please Use C++ to finish as the requirements. Implement a class called SinglyLinkedList. In the main...

Please Use C++ to finish as the requirements.

Implement a class called SinglyLinkedList. In the main function, instantiate the SinglyLinkedList class. Your program should provide a user loop and a menu so that the user can access all the operators provided by the SinglyLinkedList class.

  1. DestroyList
  2. InitializeList
  3. GetFirst
  4. InsertFirst, InsertLast, Insert
  5. DeleteFirst, DeleteLast, Delete
  6. IsEmpty
  7. Length
  8. Print, ReversePrint

In: Computer Science

NASA has sent about a dozen robotic lander and rover missions to Mars, and only seven...

NASA has sent about a dozen robotic lander and rover missions to Mars, and only seven have succeeded. One of these missions, the Mars Polar Lander, was lost due to a problem with a sensor. A sensor onboard the spacecraft triggered the shutdown of the lander's engines when it thought the craft had landed on the planet, but it had not reached the surface yet; in fact, the craft was 131 feet above the surface when the engines were turned off, and the resulting drop destroyed the vehicle.

For this discussion, identify and discuss at least one other disaster that was caused by an embedded system failure, including problems with either the hardware or software.

In: Computer Science

What is a variable type? Name three variable types, explain what each type represents, and provide...

What is a variable type? Name three variable types, explain what each type represents, and provide an example of how you might use each one.

In: Computer Science

Array based application #include <iostream> #include <string> #include <fstream> using namespace std; // Function prototypes void...

Array based application

#include <iostream>
#include <string>
#include <fstream>
using namespace std;

// Function prototypes
void selectionSort(string [], int);
void displayArray(string [], int);
void readNames(string[], int);

int main()
{
   const int NUM_NAMES = 20;
   string names[NUM_NAMES];

   // Read the names from the file.
   readNames(names, NUM_NAMES);

   // Display the unsorted array.
   cout << "Here are the unsorted names:\n";
   cout << "--------------------------\n";
   displayArray(names, NUM_NAMES);

   // Sort the array.
   selectionSort(names, NUM_NAMES);

   // Display the sorted array.
   cout << "\nHere are the names sorted:\n";
   cout << "--------------------------\n";
   displayArray(names, NUM_NAMES);

   return 0;
}

// ********************************************************
// The selectionSort function performs an ascending order *
// selection sort on an array of strings. The size *
// parameter is the number of elements in the array. *
// ********************************************************
void selectionSort(string values[], int size)
{
   int startScan;
   int minIndex;
   string minValue;

   for (startScan = 0; startScan < (size - 1); startScan++)
   {
       minIndex = startScan;
       minValue = values[minIndex];

       for(int index = startScan + 1; index < size; index++)
       {
           if (values[index] < minValue)
           {
               minValue = values[index];
               minIndex = index;
           }
       }

       values[minIndex] = values[startScan];
       values[startScan] = minValue;
   }
}

// ********************************************************
// The displayArray function displays the contents of *
// the array. *
// ********************************************************
void displayArray(string values[], int size)
{
   for (int i = 0; i < size; i++)
       cout << values[i] << endl;
}

// ********************************************************
// The readNames function reads the contents of the *
// "names.dat" file into the array. *
// ********************************************************
void readNames(string values[], int size)
{
int index = 0;   // Array index

// Open the file.
ifstream inFile;
inFile.open("names.dat");

// Test that the file was opened.
if (!inFile)
{
cout << "Error opening names.dat\n";
exit(0);
}

   // Read the names from the file into the array.
while (index < size)
{
// Get a line from the file.
       getline(inFile, values[index]);

// Increment index.
index++;
}

// Close the file.
inFile.close();

Program 1:

Use the array based application above to build an equivalent STL Vector application. Keep in mind that a vector object can be passed to functions like any other object, it is not an array.

Use the following as the input data for the names.dat file.

Collins, Bill
Smith, Bart
Allen, Jim,
Griffin, Jim
Stamey, Marty
Rose, Geri,
Taylor, Terri
Johnson, Jill,
Allison, Jeff
Looney, Joe
Wolfe, Bill,
James, Jean
Weaver, Jim
Pore, Bob,
Rutherford, Greg
Javens, Renee,
Harrison, Rose
Setzer, Cathy,
Pike, Gordon
Holland, Beth

In: Computer Science

Question: Write a program that prompts users to pick either a seat or a price. Mark...

Question:

Write a program that prompts users to pick either a seat or a price. Mark sold seats by changing the price to 0. When a user specifies a seat, make sure it is available. When a user specifies a price, find any seat with that price.

Code Provided:

(Please help me finish the line marked with "Complete this method", Please don't change other lines.)

Besides, if you could kindly mark each your line is for what purpose, I'll be very happy.

import java.util.Scanner;

public class SeatingChart
{
/**
Prints the price of seats in a grid like pattern.
@param seats a 2D array of prices
*/
public void printSeats(int[][] seats)
{
   System.out.print(" ");
   for (int j = 0; j < seats[0].length; j++)
{
System.out.print("s" + (j+1) + " ");
}
   System.out.println();
     
for (int i = 0; i < seats.length; i++)
{
   System.out.print("r" + (seats.length-i) + ":");
for (int j = 0; j < seats[i].length; j++)
{
System.out.printf("%3d", seats[i][j]);
}
System.out.println();
}
}

/**
Marks a seat with the price given to 0.
If there is no seat with the price, print an error message.
@param seats: the array of seat prices
@param price: the price to mark to zero
*/
public void sellSeatByPrice(int[][] seats, int price)
{
   // COMPLETE THIS METHOD
  
     
     
// System.out.println("Sorry, no seat found with that price.");
}

/**
Marks a seat based on a given row and seat number from input.
If seat or row numbers are invalid, print error messages.
If the seat is already occupied, print error message.
@param seats: the array of seat prices
@param rownum: row number
@param seatnum: seat number
*/
public void sellSeatByNumber(int[][] seats, int rownum, int seatnum)
{
   // COMPLETE THIS METHOD
  
     
     
//System.out.println("Sorry, seat already occupied.");
//System.out.println("Sorry, invalid seat number.");
//System.out.println("Sorry, invalid row.");
}

public static void main(String[] args)
{
// initial values come from problem description
int[][] seats = { { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
{ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
{ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 },
{ 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
{ 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
{ 10, 10, 20, 20, 20, 20, 20, 20, 10, 10 },
{ 20, 20, 30, 30, 40, 40, 30, 30, 20, 20 },
{ 20, 30, 30, 40, 50, 50, 40, 30, 30, 20 },
{ 30, 40, 50, 50, 50, 50, 50, 50, 40, 30 } };

SeatingChart seating = new SeatingChart();
seating.printSeats(seats);

System.out.println("Pick by <s>eat or <p>rice or <q> to quit: ");
Scanner in = new Scanner(System.in);
String choice = in.next();
while (!choice.equals("q"))
{
if (choice.equals("s"))
{
   System.out.println("Enter the row number you want: ");
int rownum = in.nextInt();
System.out.println("Enter the seat number you want: ");
int seatnum = in.nextInt();
seating.sellSeatByNumber(seats, rownum, seatnum);
}
else
{
// pick by price
System.out.println("What price do you want to buy?");
int price = in.nextInt();
seating.sellSeatByPrice(seats, price);
}
seating.printSeats(seats);
System.out.println("Pick by <s>eat or <p>rice or <q> to quit: ");
choice = in.next();
}
  
in.close();
}
}

In: Computer Science

1) Using IEEE 754 format, determine the number this represents: (64 bits)     0 11000111010 1100110000000100000000000000100000000000000000000000 2) Using...

1) Using IEEE 754 format, determine the number this represents:

(64 bits)     0 11000111010 1100110000000100000000000000100000000000000000000000

2) Using complement two:

a) Represent 127

b) 127 – 499

3) How many nibbles can fit in three Word?

4) Using complement one:

a) What number represents 10001111?

In: Computer Science

Is Wireshark open-source or proprietary? What does it mean to be open-source vs proprietary in the...

Is Wireshark open-source or proprietary? What does it mean to be open-source vs proprietary in the first place? Give an example of something that is open source vs something that is proprietary in the field of networking and telecommunications.

In: Computer Science

<Python Coding> Book : Discovering Computer Science chap3.2 (open source) 1. Write a modified version of...

<Python Coding>

Book : Discovering Computer Science chap3.2 (open source)

1. Write a modified version of the flower bloom program that draws a flower with 18 sides, using an angle of 100.

2. Write a program that uses a for loop to draw a square with side length 200.

3. Write a program that uses a for loop to draw a rectangle with side length 200 and width 100.

In: Computer Science