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 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 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
In: Computer Science
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 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.
[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 length and width
A constructor that accepts two parameters for the private members
Default constructor that sets both members to 0
Setters/getters for each private member
Method area() that returns the area of the rectangle
Method Perim() that returns the perimeter of the rectangle
Method toString that return the param as a String
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.
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:
Private member Rectangle
Private member height.
A constructor that accepts three double (length, width, height)
Setters getters
Method volume that returns the volume of the cube which is the area of the rectangle multiplied by the height
Method toString() that returns the length, width and height as a string
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.
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 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 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 programming language.
In: Computer Science
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
//This is an ArrayReverser Problem..
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Read in the list of numbers
int[] numbers;
String input = sc.nextLine();
if (input.equals("")) {
numbers = new int[0];
} else {
String[] numberStrings = input.split(" ");
numbers = new int[numberStrings.length];
for (int i = 0; i < numberStrings.length; i++) {
numbers[i] = Integer.parseInt(numberStrings[i]);
}
}
// Reverse the list
int[] resultArray = reverseArray(numbers);
// Print the reversed list
StringBuilder resultSb = new StringBuilder();
for (int i = 0; i < resultArray.length; i++) {
resultSb.append(new Integer(resultArray[i]).toString());
if (i < resultArray.length - 1) {
resultSb.append(" ");
}
}
System.out.println(resultSb.toString());
}
public static int[] reverseArray(int[] originalArray) {
// TODO implement this function
throw new UnsupportedOperationException();
//put code here
}
}
//Thanks.
In: Computer Science
Question 2: How can we find the real root of a polynomial with one variable? Also discuss the Newton-Raphson method.
In: Computer Science
you may not use the Python ord() or chr() functions
you may not use the Python ord() or chr() functions
you may not use the Python ord() or chr() functions
You will write a total of four functions, each of which will take two inputs and return a string:
The first argument will be a string containing the plaintext (or clear text) message to be encrypted for the two encrypt functions, and a string containing a ciphertext to be decrypted. The second argument will be the key.
For this assignment, you will always leave all characters in plaintext or ciphertext that are not letters (i.e., spaces and punctuation marks) unchanged.
Plaintext message letters may be either upper or lower case, but you should output only upper case ciphertext.
Remember the string function upper() you used in lab.
Note that you are writing two functions for each cryptosystem, an encrypt and a decrypt, so one partial test of the correctness of your work is whether first encrypting and then decrypting returns the original string (except that you may have converted some lower case letters to upper case).
Caesar Cipher
Caesar part of the homework: Write c_encrypt() and c_decrypt(), both of which take two arguments, the first one a string and the second one an integer key.
Both should return a string.
This will be much easier if both functions use the cencrypt() shift function you wrote for the lab.
As with the lab, you may not use the Python ord() or chr() functions
Vigenère Cipher
The Vigenère Cipher was more or less completely unbreakable from its introduction sometime in the 1500s until well into the 1800s.
The key in Vigenère is a key word that is used over and over again to give a different key to the Caesar cipher for each letter of the encryption (and decryption), with 'A', in good Python form, representing a rotation of 0. (We Pythonistas start at 0, not 1!)
So if the key is ABACUS, then we encrypt:
Back in the 1800s people wanting to use this system would make use of a Vigenère square, also known as the tabula recta, shown in the middle of the Wikipedia entry for the Vigenère cipher, but we can use Python.
Vigenère part of the homework: Write vig_encrypt() and vig_decrypt() functions. Each takes two strings as inputs, with the first being the plaintext/ciphertext, and the second being the key. Both should be calling functions you wrote earlier to help make the work easier.
The key will be a string consisting only of letters, but the letters might be in upper, lower, or mixed case. Important: If the plaintext to be encrypted has non-alphabetic characters (e.g., spaces or punctuation):
One check on your work: vig_encrypt('ATTACKATDAWN', 'LEMON') should return the string LXFOPVEFRNHR; another is that vig_encrypt('Hi Mom!', 'LEMON') should return the string SM YCZ!
you may not use the Python ord() or chr() functions
you may not use the Python ord() or chr() functions
you may not use the Python ord() or chr() functions
In: Computer Science
Question 3: What is Function? Explain with examples. Provide at least 2 program examples.
In: Computer Science