Questions
In C++ Having call-by-reference allows one to use storeback parameters, i.e., parameters whose values are transmitted...

In C++

Having call-by-reference allows one to use storeback parameters, i.e., parameters whose values are transmitted back to their arguments. In this exercise, you are to write a program that provides several variations of a function that calculates the minimum of two values. Several of the functions also report whether the two values passed in were equal. The functions are all named min — they differ in their arguments and return values:

  • Accept two integers and return their minimum
  • Accept three parameters: two integers, and a third integer storeback set to the minimum of the first two. Return a boolean set to true if the inputs are not equal, and false otherwise.
  • Accept three parameters: two integers, and a boolean storeback set to true if they are not equal and false otherwise. Return an integer set to the minimum of the two inputs.
  • Accept four parameters: two integers, a boolean storeback set to true if they are not equal and false otherwise, and another integer storeback set to the minimum of the two.

Call the file min.cpp. In the same file, write a main function demonstrating use of the above functions. The app should accept pairs of integers from the console (until eof), call each of the function sand print out the results using the format illustrated below:

Sample test run:

first number? 3
second number? 4
int min(x, y): The minimum of 3 and 4 is 3
bool min(x, y, min): The minimum of 3 and 4 is 3
int min(x, y, ok): The minimum of 3 and 4 is 3
void min(x, y, ok, min): The minimum of 3 and 4 is 3

first number? 5
second number? 2
int min(x, y): The minimum of 5 and 2 is 2
bool min(x, y, min): The minimum of 5 and 2 is 2
int min(x, y, ok): The minimum of 5 and 2 is 2
void min(x, y, ok, min): The minimum of 5 and 2 is 2

first number?

In: Computer Science

“Triangle Guessing” game in Python The program accepts the lengths of three (3) sides of a...

Triangle Guessing” game in Python

The program accepts the lengths of three (3) sides of a triangle as input . The program output should indicate if the triangle is a right triangle, an acute triangle, or an obtuse triangle.

  1. Make sure each side of the triangle is a positive integer. Use try/except for none positive integer input.
  2. validating the triangle. That is the sum of the lengths of any two sides of a triangle is greater than the length of the third side. Use try/except for invalid sides input.
  3. For any wrong input, tell the player what is wrong and asking to re-enter.
  4. Allow a player to play multiple times, for example, using a while loop. Remind the player what input to stop the game.
  5. user friendly one.
  6. add comments:
    1. Introduce/describe the program including the author, date, goal/purpose of the program
    2. Document every variable used at the program even the name is meaningful
    3. Explain/comment operation/activity/logic of your code. For example, “Checking whether the inputs are positive integers” and “Checking the validity the 3 lengths to see if they are able to form a triangle”
  7. Testing your program for all possible input and every of the 3 possible triangles

In: Computer Science

THIS PROGRAM HAS TO BE WRITTEN IN C Single function to perform the parity computation on...

THIS PROGRAM HAS TO BE WRITTEN IN C

Single function to perform the parity computation on the input integer passed to this function. The output of the function is 0 if the input has even parity (that is, the number of 1s in the binary representation of the input is even) and 1 if the input has odd parity (that is, the number of 1s in the binary representation of the input is odd).

In: Computer Science

1) Alternative compiled code sequence using instructions in classes A, B, C. What is the average...

1) Alternative compiled code sequence using instructions in classes A, B, C. What is the average CPI of sequence 1 and sequence 2?

class A B C

CPI for class 3 4 6

IC in Sequence 1 6 12 10

IC in sequence 2 2 4 2

2) given the 8-bit binary number 1011 1110 (two's compliment, we will call this number N)

a) what is the hEX representation of N

b) what is the decimal value if N is an 8-bit 2's compliment signed number?(please write steps

c)what is the decimal value if N is an 8-bit unsigned number?

In: Computer Science

Do we have any online or offline tool to convert c and cpp programs into MIPS...

Do we have any online or offline tool to convert c and cpp programs into MIPS and Other assembly languges.. If yes Please share the all the available tools details and Provide One example of conversions. I will upvote for good answer

In: Computer Science

function X=extractDWT(x_train,startS,endS,wStep,wRange) % x_train = input signal % startS   = from second % endS     = end...

function X=extractDWT(x_train,startS,endS,wStep,wRange)
% x_train = input signal
% startS   = from second
% endS     = end second
% wStep   = overlapping
% wRange = window size
FS=128;

N=size(x_train,3);
sz=floor((endS-(startS+wRange))/wStep)+1;
X=zeros(sz*140,2);
cn=0;
for i=1:N
   
    for sig=startS:wStep:endS-wRange
       
        sW=sig*FS+1;
        eW=(sig+wRange)*FS;
       
        C3Sig=x_train(sW:eW,1,i);
        C4Sig=x_train(sW:eW,3,i);
       
        waveletFunction = 'db4';
        waveletLevel=3;
        [wCoe,L] = wavedec(C3Sig,waveletLevel,waveletFunction);
        C3D3 = detcoef(wCoe,L,3);   % Mu
       
       
        [wCoe,L] = wavedec(C4Sig,waveletLevel,waveletFunction);
        C4D3 = detcoef(wCoe,L,3); % Mu
       
        cn=cn+1;
        % Mean of the absolute values
        X(cn,1)=sum(C3D3.^2)/numel(C3D3);
        X(cn,2)=sum(C4D3.^2)/numel(C4D3);
    end
end

end

Need code explanation for above code?

In: Computer Science

SQL FORMAT (11-13 are completed and correct) -- 11. what are the names of all students...

SQL FORMAT (11-13 are completed and correct)

-- 11. what are the names of all students who have taken some course? Don't show duplicates.
select distinct(name) from student where tot_cred > 0;

-- 12. what are the names of departments that offer 4-credit courses? Don't list duplicates.
select distinct(dept_name) from course where credits=4;

-- 13. What are the names and IDs of all students who have received an A in a computer science class?
select distinct(name), id from student natural join takes natural join cours$

-- 14. How many B grades have been given to physics majors?


-- 15. What is the average total credits of students who have taken CS-319?


-- 16. What is the average total credits of students who have taken CS-101?


-- 17. What are the course IDs of courses taught by instructor Katz?


-- 18. What are the course IDs of all courses offered by instructor Crick's department?


-- 19. What is the course_id, semester, and year of sections of computer science courses?
-- Don't show duplicates.


-- 20. What are the names of students who have taken a class taught by instructor Srinivasan?

In: Computer Science

use postorder and inorder tree traversals to make preorder traversal. #!/usr/bin/env python3 # encoding: UTF-8 """Turning...

use postorder and inorder tree traversals to make preorder traversal.

#!/usr/bin/env python3
# encoding: UTF-8
"""Turning in-order and post-order tree traversals into pre-order"""


def get_preorder(inorder: str, postorder: str) -> str:
"""Return pre-order traversal of a tree based on its in-order and post-order traversals"""
#Complete the following function
#raise NotImplementedError


In: Computer Science

1. Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and...

1. Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is false. Print "Red balloon" if isBalloon and isRed are both true. Print "Not a balloon" otherwise. End with newline.

import java.util.Scanner;

public class RedBalloon {
   public static void main (String [] args) {
      Scanner scnr = new Scanner(System.in);
      boolean isRed;
      boolean isBalloon;

      isRed = scnr.nextBoolean();
      isBalloon = scnr.nextBoolean();

      /* Your solution goes here */

   }
}

2. Assign isTeenager with true if kidAge is 13 to 19 inclusive. Otherwise, assign isTeenager with false.

import java.util.Scanner;

public class TeenagerDetector {
   public static void main (String [] args) {
      Scanner scnr = new Scanner(System.in);
      boolean isTeenager;
      int kidAge;

      kidAge = scnr.nextInt();

      /* Your solution goes here */

      if (isTeenager) {
         System.out.println("Teen");
      }
      else {
         System.out.println("Not teen");
      }
   }
}

In: Computer Science

Write a program that copies the contents of one file to a destination file. This program...

Write a program that copies the contents of one file to a destination file. This program works by first prompting the user for the name of the source and destination files. Be sure to include all necessary error checking, including ensuring that the source file exists. Also, if available, you have to use Linux system calls and not standard C library functions in your program.

  • Write/type your source code in your submission file/document.

[Restrictions] For file handling operations, only use the open, close, read and write system calls. For other operations you can use the library functions. For every use of library function where system call was required, 2 marks will be deducted.

Following error situations must be taken care of in the code: File not present, read error, write error, close error, create error, return value of system calls.

In: Computer Science

I. Design and code a class Rectangle that has the following properties: Two private members double...

I. Design and code a class Rectangle that has the following properties:

  1. Two private members double length and width

  2. A constructor that accepts two parameters for the private members

  3. Default constructor that sets both members to 0

  4. Setters/getters for each private member

  5. Method area() that returns the area of the rectangle

  6. Method Perim() that returns the perimeter of the rectangle

  7. Method toString that return the param as a String

  8. Method Add that accepts a Rectangle and returns a rectangle with the length as sum of lengths of this and the input rectangle and the width as the sum too.

  9. Method equals() that accepts a rectangle and returns true if the two rectangles are the same and false if not.

II. Design a Class Cube that has the following:

  1. Private member Rectangle

  2. Private member height.

  3. A constructor that accepts three double (length, width, height)

  4. Setters getters

  5. Method volume that returns the volume of the cube which is the area of the rectangle multiplied by the height

  6. Method toString() that returns the length, width and height as a string

  7. Method equals that accepts another Cube and returns true if the two cubes are the same and false if not. Use the equals in Rectangle.

  8. Method Cube add(Cube C) that returns the sum of the Cube this

In: Computer Science

absorption refection scattering refraction and diffraction can all have an impact on RF signal strength. Identify...

absorption refection scattering refraction and diffraction can all have an impact on RF signal strength. Identify at least three objects or types of materials in each of the five categories that can impact rf signals. Next research how much the impact is in terms of loss either DBm or mW.

In: Computer Science

This is my code I need to complete it? //The code package arraylists; import java.util.ArrayList; import...

This is my code I need to complete it?

//The code

package arraylists;

import java.util.ArrayList;
import java.util.Scanner;

/**
*
*
*/
public class SoftOpening {
  
public static void main(String[] args) {
  
  
Scanner input = new Scanner(System.in);
  
ArrayList foodList = generateMenu();
  
User user = generateUser(input);
user.introduce();
  
userBuyFood(foodList, user, input);
user.introduce();
}
public static ArrayList generateMenu(){
  
ArrayList foodList = new ArrayList<>();
  
Food pizza1 =new Food(1,"pizza","Seafood",11,12);
Food pizza2 =new Food(2,"pizza","Beef",9,10);
Food Friedrice =new Food(3,"fried rice","Seafood",5,12);
Food Noodles =new Food(4,"noodles","Beaf",6,14);
  
foodList.add(pizza1);
foodList.add(pizza2);
foodList.add(Friedrice);
foodList.add(Noodles);
  
return foodList ;
}
  
public static void getMenu(ArrayList foodlist){
  
  
for (int i =0;i
System.out.println(foodlist.get(i));

}
  
}
  
}
Q1: generateUser(Scanner in) that generates a user whose account and money are added by using the Scanner parameter. ?

Q2: userBuyFood(ArrayList, User user, Scanner in) to invoke the getMenu(), ask the user to selects the foods in the menu, compute the cost and invoke the addExpense() from the User class?

Q3: Invoke the method introduce() of the User object to show his/her balance ?

public class Food {
private int id;
private String name;
private String type;
private int size;
private double price;
  
public Food(int id, String name,String type,int size,double price){
this.id= id;
this.name= name;
this.type= type;
this.size= size;
this.price= price;
  
}

public void setId(int id) {
this.id = id;
}
  
public void setName(String name) {
this.name = name;
}

public void setType(String type) {
this.type = type;
}

public void setSize(int size) {
this.size = size;
}
  
public void setPrice(double price) {
this.price = price;
}
  
public int getId() {
return id;
}
  
public String getName() {
return name;
}
  
public String getType() {
return type;
}

public double getPrice() {
return price;
}

public int getSize() {
return size;
}

  
@Override
public String toString(){
return " [Id] "+id + " [Name] "+ name+ " [Type] "+size+" [Size] "+type+" [Type] "+price+" [Price] ";

}   
}

public class FoodTest {
  
public static void main(String[] args) {
  
ArrayList foodList = new ArrayList<>();
Food pizza1 =new Food(1,"pizza","Seafood",11,12);
Food pizza2 =new Food(2,"pizza","Beef",9,10);
Food Friedrice =new Food(3,"fried rice","Seafood",5,12);
Food Noodles =new Food(4,"noodles","Beaf",6,14);
  
foodList.add(pizza1);
foodList.add(pizza2);
foodList.add(Friedrice);
foodList.add(Noodles);
  
for (int i =0;i
System.out.println(foodList.get(i));

}
  
  
  
  
}
  
}

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

package arraylists;

import java.util.Scanner;

/**

*

*

*/

public class User {

   private String accountName;

   private String password ;

   private double money;

public void setAccountName(String accountName) {

this.accountName = accountName;

}

  

public void setPassword(String password) {

this.password = password;

}

  

public void setMoney(double money) {

this.money = money;

}

public String getAccountName() {

return accountName;

}

  

public String getPassword() {

return password;

}

  

public double getMoney() {

return money;

}

  

  

public void introduce() {

  

  

System.out.println(" The account Name is "+accountName+" The balance is "+money+" $ ");

  

}

  

   public void addExpense(double value, Scanner in){

   if (value > money)

   System.out.println(" Plan to expence "+value+" $ but no sufficient ");

   else {

   System.out.println(" Plan to expence "+value+" $ ");

   System.out.println(" please enter password ");

  

   String password1 = in.nextLine();

   if (password.equals(password1))

   {

   money =money-value;

  

   System.out.println(" expence "+value+" $ and balance "+money+" $ ");

  

   }

  

   }

   }

public void addMoney(double value){

  

   money += value;

   System.out.println(" Got "+value+" $ as income , balance is "+money+" $ ");

   //System.out.println(accountName+"has a balance of "+money);

}

}

In: Computer Science

Question 1: What is For Loop? Explain with 2 Examples. You can write code in any...

Question 1: What is For Loop? Explain with 2 Examples. You can write code in any programming language.

In: Computer Science

I have a problem with my code. It does not run. Please can someone check the...

I have a problem with my code. It does not run. Please can someone check the code and tell me where I went wrong?

This is the question:

Program Specification: Write a C program that takes the length and width of a rectangular yard, and the length and width of a rectangular house (that must be completely contained in the yard specified) as input values. Assuming that the yard has grass growing every where that the house is not covering, and you own a lawn mower can mow one square foot per second, on average. Compute the time (in minutes) needed to mow the yard.

Requirements: 1. Use conditional logic to display an error message (instead of erroneous output) only if neither the specified house nor the same house rotated 90 degrees does not fit on the specified yard. 2. Otherwise - display all of the user’s inputs and the computed result in a reasonable report like format.

This is the code:

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

int main()
{
   float Length_y;
   float Width_y;
   float Length_h;
   float Width_h;
   float Area_y;
   float Area_h;
   float Area_G;
   float Time;

   printf("Enter the length of the yard: \n");
   scanf("%f", &Length_y);

   printf("Enter the width of the yard: \n");
   scanf("%f", &Width_y);

   printf("Enter the length of the house: \n");
   scanf("%f", &Length_h);

   printf("Enter the width of the house: \n");
   scanf("%f", &Width_h);

   if ((Length_h>=Length_y)||(Width_h>=Width_y))
   {
       Length_h= Width_h;
       Width_h= Length_h;
       Area_y= Length_y*Width_y;
       Area_h= Length_h*Width_h;
       Area_G= Area_y-Area_h;
       Time= Area_G/60;

       printf("Length of the yard is %f \n", Length_y );
       printf("Width of the yard is %f \n", Width_y );
       printf("Length of the house is %f \n", Length_h );
       printf("Width of the house is %f \n", Width_h);
       printf("Area of the yard is %f \n", Area_y);
       printf("Area of the house is %f \n", Area_h);
       printf("Area with grass is %f \n", Area_G);
       printf("Time to mow lawn is %f \n", Time);
   }
   else
   {
       printf("House does not fit in yard.\n");
   }
   return 0;

}

In: Computer Science