Questions
Given a program as shown below: #include <stdio.h> void function1(void); void function2 (int, double x); void...

Given a program as shown below:

#include <stdio.h>

void function1(void);

void function2 (int, double x);

void main (void)

{

int m;

double y;

m=15;

y=308.24;

printf ("The value of m in main is m=%d\n\n",m);

function1();

function2(m,y);

printf ("The value of m is main still m = %d\n",m);

}

void function1(void)

{

printf("function1 is a void function that does not receive\n\\r values from main.\n\n");

}

void function2(int n, double x)

{

int k,m;

double z;

k=2*n+2;

m=5*n+37;

z=4.0*x-58.4;

printf ("function2 is a void function that does receive\n\\r values from main.The values received from main are:\n\\r\t n=%d \n\r\t x=%lf\n\n", n,x);

printf ("function2 creates three new variable, k, m and z\n\\rThese variable have the values:\n\\r\t 1=%d \n\r\t m=%d \n\r\t z=%lf \n\n",k,m,z);

}

  1. What is a function prototype?
  2. What is a function definition?
  3. What is a function call?
  4. Must the number, order and type of parameters in the arguement list of a function call and its defination match?

In: Computer Science

Please type out, not handwrite. THANKS!! Compare and contrast Wireless networks and Home networks impact on...

Please type out, not handwrite. THANKS!!

Compare and contrast Wireless networks and Home networks impact on the future of computing in a few paragraphs.

In: Computer Science

Prepare A Demo Objective: What are the commands you would need to use to backup your...

Prepare A Demo

Objective
: What are the commands you would need to use to backup your media files like music / pictures / movie folders and backup media files, like .mp3 / .jpg / .mp4 or .mov files, into their respective folders from a common media folder?

Process:

A) List, line by line, the sequence of commands needed to backup your media files.

B) Provide a brief description of what each section is doing between each section.

C) Example: Copying media files, with a blank line in between, what command is being used.

Use blank lines to between sections for readability in your documentation. It is OK to list groups of commands or comments without extra blank lines.

(No Screenshots please)

In: Computer Science

Example code of inserting nodes, deleting nodes, and deleting specific nodes in a Linked List in...

Example code of inserting nodes, deleting nodes, and deleting specific nodes in a Linked List in C++?

How do I create nodes? explain each line of code pleasee

In: Computer Science

this is java code package calculator; import java.util.Scanner; import java.lang.Math; public class Calculator { public static...

this is java code

package calculator;

import java.util.Scanner;

import java.lang.Math;

public class Calculator {

public static void main(String[] args) {

   double numx, numy;

Scanner scanner = new Scanner(System.in);

System.out.println(" Enter an operation :");

System.out.println("1: Addition");

System.out.println("2: Subtraction");

System.out.println("3: Multiplication");

System.out.println("4: Division");

System.out.println("5: Modulus");

System.out.println("6: Power");

System.out.println("7: Square");

System.out.println("8: Factorial");

System.out.println("9: Log");

System.out.println("10: Sin");

System.out.println("11: Absolute value");

System.out.println("12: Average Of Array Elements");

String operator = scanner.next();

System.out.println();

double output;

switch(operator)

{

case "1":

    System.out.print("Enter first number:");

/* We are using data type double so that user

* can enter integer as well as floating point

* value

*/

numx = scanner.nextDouble();

System.out.print("Enter second number:");

numy = scanner.nextDouble();

   output = sum( numx, numy);

break;

case "2":

    System.out.print("Enter first number:");

/* We are using data type double so that user

* can enter integer as well as floating point

* value

*/

numx = scanner.nextDouble();

System.out.print("Enter second number:");

numy = scanner.nextDouble();

   output = Subtraction( numx, numy);

break;

case "3":

    System.out.print("Enter first number:");

/* We are using data type double so that user

* can enter integer as well as floating point

* value

*/

numx = scanner.nextDouble();

System.out.print("Enter second number:");

numy = scanner.nextDouble();

   output = Multiplication( numx,numy);

break;

case "4":

    System.out.print("Enter first number:");

/* We are using data type double so that user

* can enter integer as well as floating point

* value

*/

numx = scanner.nextDouble();

System.out.print("Enter second number:");

numy = scanner.nextDouble();

   output = Division( numx, numy );

break;

case "5":

    System.out.print("Enter first number:");

/* We are using data type double so that user

* can enter integer as well as floating point

* value

*/

numx = scanner.nextDouble();

System.out.print("Enter second number:");

numy = scanner.nextDouble();

output =Modulus( numx,numy);

   break;

case "6":

    System.out.print("Enter first number:");

numx = scanner.nextDouble();

System.out.print("Enter second number:");

numy = scanner.nextDouble();

   output = power( numx, numy);

   break;

case "7":

   System.out.print("Enter first number:");

numx = scanner.nextDouble();

   output= Square_root( numx);

   break;

case "8":

    System.out.print("Enter first number:");

numx = scanner.nextDouble();

output=factorial( numx);

break;

case "9":

       System.out.print("Enter first number:");

     numx = scanner.nextDouble();

   output=log1( numx); // log function

   break;

case "10":

     System.out.print("Enter first number:");

     numx = scanner.nextDouble();

   output=sin1( numx); //sin finction

   break;

case "11":

     System.out.print("Enter first number:");

     numx = scanner.nextDouble();

   output=absolute( numx); //absolute function

   break;

case "12":

      

  

output= average( );

   break;

/* If user enters any other operator apart from

* then display an error message to user

*

*/

default:

System.out.printf("You have entered wrong operator");

return;

}

System.out.println(output);

}

public static double sum(double numx, double numy)

{

double sum=0;

return sum=numx+numy;

}

public static double Subtraction(double numx, double numy)

{

double sub=0;

return sub=numx-numy;

}

public static double Multiplication(double numx, double numy)

{

double Mul=0;

return Mul=numx*numy;

}

public static double Division(double numx, double numy)

{

double Division=0;

return Division=numx/numy;

}

public static double Modulus(double numx, double numy)

{

double Mod=0;

return Mod=numx%numy;

}

public static double power(double numx, double numy)

{

double output = Math.pow(numx, numy);

return output;

}

public static double Square_root(double numx)

{

double output = Math.sqrt(numx);

return output;

}

public static double factorial(double numx)

{

double factorial=1;  

for(int i = 1; i <= numx; ++i) //loop for calculation of factorial

{

// factorial = factorial * i;

factorial *= i;

}

return factorial;

}

public static double log1(double numx)

{

    double output=1;

return output=Math.log(numx);

}

public static double absolute(double numx)

{

    double output=1;

return output=Math.abs(numx);

}

public static double sin1(double numx)

{

double output=1;

return output=Math.sin(numx);

}

public static double average( )

{

    int n =1;

    Scanner scanner = new Scanner(System.in);

double total = 0;

   System.out.println("Enter size of array");

   n=scanner.nextInt();

   int i=0;

   double[] arr = new double[n];

   while(i<arr.length) // while loop for getting elements in array

   {

       System.out.print("Enter Element No."+(i+1)+": ");

   arr[i] = scanner.nextDouble();

   i++;

   }

   for(int j=0; j<arr.length; j++){ // loop to calculate sum of array

    total = total + arr[j];

}

   double average = total / arr.length;

   return average;

}

}

for this code draw High level flowchart.

In: Computer Science

How do I stop the comma from printing at the end of Neptune? #include <iostream> using...

How do I stop the comma from printing at the end of Neptune?

#include <iostream>

using namespace std;

int main() {

string planets[] = {"Mercury","Venus","Earth","Mars","Jupiter","Saturn","Uranus","Neptune"};

cout << "Contents in the array: ";

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

cout << *(planets + i) << ", ";

}

cout << endl;

return 0;

}

In: Computer Science

a) The ASCII code for the letter A is 1000001, and the ASCII code for the...

a) The ASCII code for the letter A is 1000001, and the ASCII code for the letter a is 1100001. Given that the ASCII code for the letter G is 1000111, without looking at Table 2.7, what is the ASCII code for the letter g?

b) The EBCDIC code for the letter A is 1100 0001, and the EBCDIC code for the letter a is 1000 0001. Given that the EBCDIC code for the letter G is 1100 0111, without looking at Table 2.7, what is the ASCII code for the letter g?

c) The ASCII code for the letter A is 1000001, and the ASCII code for the letter a is 1100001. Given that the ASCII code for the letter Q is 1010001, without looking at Table 2.7, what is the ASCII code for the letter q?

In: Computer Science

What is a NOSQL database? For what types of applications would be a NOSQL database preferred...

What is a NOSQL database? For what types of applications would be a NOSQL database preferred over a relational database. Provide the name of a NOSQL database used in the real world.

In: Computer Science

1. What are the names of the parts of a UNIX command? list them, and give...

1. What are the names of the parts of a UNIX command? list them, and give a brief description of each.

2. Can multiple UNIX commands be typed on the same single command line? Explain how

3. How can you find out which utilities are available on your system for editing files? Which utilities are available for editing on your system?

4. What does the following command do? What is $PATH and echo $PATH?

5. What is the result of giving the which utility the name of a command that resides in a directory that is nor in your search path?

In: Computer Science

Assume that a disk has an average seek time of 9 msec and a rotation speed...

Assume that a disk has an average seek time of 9 msec and a rotation speed of 7000 RPM. Assume also that there are 40 sectors in a track. What is the average time expected to retrieve a single sector?

In: Computer Science

I need a sample of code of the below senario in Java with Spring Boot framework...

I need a sample of code of the below senario in Java with Spring Boot framework

Create a login and register page and user be able to register and then log in.

Data need to be stored from the user are:

Id, First Name, Last Name, DOB, Email, and Phone Number.

if user inputs the wrong credential system displays error.

please use JSPs. and JSTL dependencies

In: Computer Science

Python program problem: A group of statisticians at a local college has asked you to create...

Python program problem:

A group of statisticians at a local college has asked you to create a set of functions that compute the median and mode of a set of numbers. Define these functions, median and mode, in a module named stats.py. Also include a function named mean, which computes the average of a set of numbers. Each function should expect a list of numbers as an argument and return a single number. Each function should return 0 if the list is empty. Include a main function that tests the three statistical functions using the following list defined in main: userList = [3, 1, 7, 1, 4, 10] An example of the program output is shown below: List: [3, 1, 7, 1, 4, 10] Mode: 1 Median: 3.5 Mean: 4.33

In: Computer Science

package imageblocks; import java.awt.Color; import utils.Picture; public class ImageBlocks { static Color BLACK = new Color(0,0,0);...


package imageblocks;

import java.awt.Color;

import utils.Picture;

public class ImageBlocks {
static Color BLACK = new Color(0,0,0);
static Color WHITE = new Color(255,255,255);
private int height;
private int width;
boolean [][] visited;
Picture pic;
  
public ImageBlocks(Picture pic) {
   this.pic = pic;
   height = pic.height();
   width = pic.width();
}
  
  
private boolean isBlack(int x,int y){
return pic.get(x,y).equals(BLACK);
}
private boolean isWhite(int x,int y){
return pic.get(x,y).equals(WHITE);
}
  
/**

* METHOD TO BE COMPLETED
* count the number of image blocks in the given image
* Counts the number of connected blocks in the binary digital image
* @return number of black blocks
*/
public int countConnectedBlocks(){
       //TODO
   }

}

== Picture Class for Help ==

public final class Picture implements ActionListener {

private BufferedImage image; // the rasterized image

private JFrame frame; // on-screen view

private String filename; // name of file

private boolean isOriginUpperLeft = true; // location of origin

private final int width, height; // width and height

   /**

   * Initializes a blank <tt>w</tt>-by-<tt>h</tt> picture, where each pixel is black.

   */

public Picture(int w, int h) {

if (w < 0) throw new IllegalArgumentException("width must be nonnegative");

if (h < 0) throw new IllegalArgumentException("height must be nonnegative");

width = w;

height = h;

image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);

// set to TYPE_INT_ARGB to support transparency

filename = w + "-by-" + h;

}

   /**

   * Initializes a new picture that is a deep copy of <tt>pic</tt>.

   */

public Picture(Picture pic) {

width = pic.width();

height = pic.height();

image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);

filename = pic.filename;

for (int x = 0; x < width(); x++)

for (int y = 0; y < height(); y++)

image.setRGB(x, y, pic.get(x, y).getRGB());

}

   /**

   * Initializes a picture by reading in a .png, .gif, or .jpg from

   * the given filename or URL name.

   */

public Picture(String filename) {

this.filename = filename;

try {

// try to read from file in working directory

File file = new File(filename);

if (file.isFile()) {

image = ImageIO.read(file);

}

// now try to read from file in same directory as this .class file

else {

URL url = getClass().getResource(filename);

if (url == null) { url = new URL(filename); }

image = ImageIO.read(url);

}

width = image.getWidth(null);

height = image.getHeight(null);

}

catch (IOException e) {

// e.printStackTrace();

throw new RuntimeException("Could not open file: " + filename);

}

}

   /**

   * Initializes a picture by reading in a .png, .gif, or .jpg from a File.

   */

public Picture(File file) {

try { image = ImageIO.read(file); }

catch (IOException e) {

e.printStackTrace();

throw new RuntimeException("Could not open file: " + file);

}

if (image == null) {

throw new RuntimeException("Invalid image file: " + file);

}

width = image.getWidth(null);

height = image.getHeight(null);

filename = file.getName();

}

   /**

   * Returns a JLabel containing this picture, for embedding in a JPanel,

   * JFrame or other GUI widget.

   */

public JLabel getJLabel() {

if (image == null) { return null; } // no image available

ImageIcon icon = new ImageIcon(image);

return new JLabel(icon);

}

   /**

   * Sets the origin to be the upper left pixel.

   */

public void setOriginUpperLeft() {

isOriginUpperLeft = true;

}

   /**

   * Sets the origin to be the lower left pixel.

   */

public void setOriginLowerLeft() {

isOriginUpperLeft = false;

}

   /**

   * Displays the picture in a window on the screen.

   */

public void show() {

// create the GUI for viewing the image if needed

if (frame == null) {

frame = new JFrame();

JMenuBar menuBar = new JMenuBar();

JMenu menu = new JMenu("File");

menuBar.add(menu);

JMenuItem menuItem1 = new JMenuItem(" Save... ");

menuItem1.addActionListener(this);

menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,

   Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

menu.add(menuItem1);

frame.setJMenuBar(menuBar);

frame.setContentPane(getJLabel());

// f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

frame.setTitle(filename);

frame.setResizable(false);

frame.pack();

frame.setVisible(true);

}

// draw

frame.repaint();

}

   /**

   * Returns the height of the picture (in pixels).

   */

public int height() {

return height;

}

   /**

   * Returns the width of the picture (in pixels).

   */

public int width() {

return width;

}

   /**

   * Returns the color of pixel (<em>x</em>, <em>y</em>).

   */

public Color get(int x, int y) {

if (x < 0 || x >= width()) throw new IndexOutOfBoundsException("x must be between 0 and " + (width()-1));

if (y < 0 || y >= height()) throw new IndexOutOfBoundsException("y must be between 0 and " + (height()-1));

if (isOriginUpperLeft) return new Color(image.getRGB(x, y));

else return new Color(image.getRGB(x, height - y - 1));

}

   /**

   * Sets the color of pixel (<em>x</em>, <em>y</em>) to given color.

   */

public void set(int x, int y, Color color) {

if (x < 0 || x >= width()) throw new IndexOutOfBoundsException("x must be between 0 and " + (width()-1));

if (y < 0 || y >= height()) throw new IndexOutOfBoundsException("y must be between 0 and " + (height()-1));

if (color == null) throw new NullPointerException("can't set Color to null");

if (isOriginUpperLeft) image.setRGB(x, y, color.getRGB());

else image.setRGB(x, height - y - 1, color.getRGB());

}

   /**

   * Is this Picture equal to obj?

   */

public boolean equals(Object obj) {

if (obj == this) return true;

if (obj == null) return false;

if (obj.getClass() != this.getClass()) return false;

Picture that = (Picture) obj;

if (this.width() != that.width()) return false;

if (this.height() != that.height()) return false;

for (int x = 0; x < width(); x++)

for (int y = 0; y < height(); y++)

if (!this.get(x, y).equals(that.get(x, y))) return false;

return true;

}

   /**

   * Saves the picture to a file in a standard image format.

   * The filetype must be .png or .jpg.

   */

public void save(String name) {

save(new File(name));

}

   /**

   * Saves the picture to a file in a standard image format.

   */

public void save(File file) {

this.filename = file.getName();

if (frame != null) { frame.setTitle(filename); }

String suffix = filename.substring(filename.lastIndexOf('.') + 1);

suffix = suffix.toLowerCase();

if (suffix.equals("jpg") || suffix.equals("png")) {

try { ImageIO.write(image, suffix, file); }

catch (IOException e) { e.printStackTrace(); }

}

else {

System.out.println("Error: filename must end in .jpg or .png");

}

}

   /**

   * Opens a save dialog box when the user selects "Save As" from the menu.

   */

public void actionPerformed(ActionEvent e) {

FileDialog chooser = new FileDialog(frame,

   "Use a .png or .jpg extension", FileDialog.SAVE);

chooser.setVisible(true);

if (chooser.getFile() != null) {

save(chooser.getDirectory() + File.separator + chooser.getFile());

}

}

In: Computer Science

Create a short list of ways to pop your filter bubble. What can be done to...

  1. Create a short list of ways to pop your filter bubble.
  2. What can be done to diversify the information you see on the internet and social media platforms?

In: Computer Science

*In Java Please! Tasks This assignment has three parts: Create a LinkedList class. Create a BirdSpecies...

*In Java Please!

Tasks

This assignment has three parts:

  1. Create a LinkedList class.
  2. Create a BirdSpecies class.
  3. Print out the results after testing each of the methods in both of the classes and solving a simple problem with them.

Task 1 – LinkedList Class

Create a LinkedList class. It may be singly linked, circularly linked, or doubly linked. A singly linked list may be in either direction, forwards or backwards, while a doubly linked list must be in both directions, forwards and backwards. A circularly linked list will connect the end with the beginning, instead of pointing to null, but otherwise it is a singly linked list. We will need at least one private variable which represents the starting point of our list. The nodes for this list will need the typical private fields of next and data, but also count which will store the number of times a specific species of bird has appeared in a survey.

We must also create a constructor for our LinkedList. Let’s create a default constructor that creates a list of size zero.

Next is to create an Add method. This will add the given BirdSpecies object to the end of the list, if the species is not already in the list. If it is in the list, then the variable count of that species is increased by one (remember that count comes from the node, not the list or BirdSpecies class). Also keep track of the position where a new BirdSpecies was added into the list. This will be returned to the Main method.

Another method called GetCount that returns the count of a given BirdSpecies. If that species is not on the list, return zero.

Finally, a GetReport method that returns the name and count of each BirdSpecies on the list. If the list is empty, return a special message that says the list is empty.

Task 2 – BirdSpecies Class

Create a BirdSpecies class that has private variables for the name of the species. Use an overloaded constructor to create a BridSpecies with a given name. Also use a getter and setter that manipulate the name. Finally, let’s make a ToString method that returns the name of the species.

Task 3 – The Tester Class

            Create a Tester Class, with a Main method. In the Main method, create one LinkedList object. The values will be entered into the LinkedList using user input and a loop. The loop will keep accepting user input until they enter “done” when asked if they wish to enter another bird species. If the user enters a new bird species into the list, use the ToString method of the new BirdSpecies object to display its name along with the position that it now has in the list. If another bird of the same species is added to the list, display the ToString method of the original BirdSpecies object and its count (but not its position). Finally, print out the list using the GetReport method of the LinkedList.

∃ Some Sample Output:

Enter a bird species: Black-chinned hummingbird

Entered bird species: Black-chinned hummingbird at position 0.

Are you done entering birds? no

Enter a bird species: West African swallow

Entered bird species: West African swallow at position 1.

Are you done entering birds? no

Enter a bird species: Black-chinned hummingbird

Entered bird species: Black-chinned hummingbird, count increased to 2.

Are you done entering birds? done

Contents of the list:

Black-chinned hummingbird with count 2

West African swallow with count 1

You need to implement your sourcecode into the given template below:

//Template for Class BirdSpecies------------------------------------------------------------------

package com.company;
public class BirdSpecies
{
private String nameOfSpecies;
public BirdSpecies(String nameOfSpecies)
{
//Initialize the name of the bird.
}
public void SetName(String name)
{
//Change the name of the bird.
}
public String GetName()
{
//Return the name of the bird.
}
@Override
public String toString()
{
//Return the name of the bird.
}
}

// Template for Class LinkedList-------------------------------------------------------------------------------------

package com.company;

public class LinkedList
{
private Node first;

public LinkedList()
{
this.first = null;
}

public int Add(Type data)
{
//CASE 0: List is empty or first is the same species.


//CASE 1: List is not empty, search for species as we move to the end of the list,
// otherwise add at end.
}

public int GetCount(Type data)
{
//Search through the list looking for the value given.
//Otherwise return 0 if we reached the end.
}

public String GetReport()
{
//CASE 0: List is empty, return a special message.

//CASE 1: List is not empty, return the species and count of each bird.
//Hint, use the toString of the bird to do so.
}

//Simple Node Class
class Node
{
E data;
Node next;
int count;

public Node(E data)
{
this.data = data;
this.next = null;
this.count = 1;
}
}
}

//Template for Main Class (No change needed here)-------------------------------------------------------

package com.company;

public class Main
{
public static void main(String[] args)
{
LinkedList list = new LinkedList<>();

System.out.println("Entered the black chin at: " + list.Add(new BirdSpecies("Black-chinned hummingbird")));
System.out.println("Entered the African swallow at: " + list.Add(new BirdSpecies("West African Swallow")));
System.out.println("Entered the second black chin at: " + list.Add(new BirdSpecies("Black-chinned hummingbird")));
System.out.println("Entered the African swallow at: " + list.Add(new BirdSpecies("West African Swallow")));

System.out.println("Count of black chin is: " + list.GetCount(new BirdSpecies("Black-chinned hummingbird")) );

System.out.println(list.GetReport());
}
}

In: Computer Science