Questions
Cplusplus Task: You are to write a class called Monomial, using filenames monomial.h and monomial.cpp, that...

Cplusplus

Task: You are to write a class called Monomial, using filenames monomial.h and monomial.cpp, that will allow creation and handling of univariate monomials, as described below.

Monomial Description

Each monomial object has following properties:

  • Each monomial has a coefficient and a power.
  • Monomial power is always positive.
  • Monomial power is always integer.
  • Monomials cannot be added if they have different powers

Class Details

  1. The single constructor for the Monomial class should have 2 parameters: an floating point coefficient value (optional, with a default value of 1.0); and an integer power value (optional, with a default value of 1). If the power value is less then 1, set the power to 1. The class will need to provide internal storage for any member data that must be kept track of.

  2. There should be member functions GetCoefficient, and GetPower, which will return the monomial’s coefficient value, and monomial’s power value, respectively. The GetPower method should return integer results. The GetCoefficient function should return its result as a float.

  3. There should be member functions SetPower, which will set the monomial’s power to the arbitrary positive value. If the parameter is not positive then set the power to the default value 1.

  4. There should be member function Add, which adds the one monomial to the other. The parameter of this member function need to be a constant reference to the other monomial object. The monomials can only be added if they have the same power, otherwise error message must be printed. The result of the addition is saved in the caller object.

  5. There should be two member functions Multiply (overrides), which each allow to multiply a monomial to a number and to another monomial. The first member function need to accept floating point parameter that is used to perform multiplication of the real number on the the monomial object. The second member function need to accept a constant reference to the other monomial object. Use monomials to coefficients and powers to perform their multiplication. The result of the multiplication is saved in the caller object.

  6. There should be a member function called Exponent that perform exponentiation (raise to power) of the monomial to the specified power value. You only can raise monomial to the positive power, if the power parameter is not positive print error message. The result of the exponentiation is saved in the caller object.

  7. A sample driver program (called monomial-driver.cpp) is provided. It uses objects of type Monomial and illustrates sample usage of the member functions.

  8. Your class declaration and definition files must work with my main program from the test driver, as-is (do not change my program to make your code work!). You are encouraged to write your own driver routines to further test the functionality of your class, as well. Most questions about the required behavior of the class can be determined by carefully examining my driver program and the sample execution. Keep in mind, this is just a sample. Your class must meet the requirements listed above in the specification - not just satisfy this driver program. (For instance, I haven’t tested every illegal fill character in this driver program - I’ve just shown a sample). Your class will be tested with a larger set of calls than this driver program represents.

General Requirements

  • No global variables, other than constants!
  • All member data of your class must be private
  • You can only use the <iostream> library for output. !!! No other libraries are allowed !!!.
  • When you write source code, it should be readable and well-documented.
  • Here are some general notes on style guidelines
  • Your monomial.h file should contain the class declaration only. The monomial.cpp file should contain the member function definitions.

Test Driver:

//
// driver.cpp -- driver program to demonstrate the behavior of
//               the Monomial class

#include <iostream>
#include "monomial.h"

using namespace std;

int main()
{
    // create some monomial: x, 2x, 12.5x³, -3xâ¶
    Monomial m1, m2( 2.0 ), m3( 12.5, -1 ), m4( -3.0 , 6);
    // display monomial
    cout << "Monomial `m1` has the coefficient " << m1.GetCoefficient()
         << " and power " << m1.GetPower() << ": ";
    m1.Print();
    cout << "Monomial `m2` has the coefficient " << m2.GetCoefficient()
         << " and power " << m2.GetPower() << ": ";
    m2.Print();
    cout << "Monomial `m3` has the coefficient " << m3.GetCoefficient()
         << " and power " << m3.GetPower() << ": ";
    m3.Print();
    cout << "Monomial `m4` has the coefficient " << m4.GetCoefficient()
         << " and power " << m4.GetPower() << ": ";
    m4.Print();

    // Change monomial power
    cout << "Monomial `m3` power wasn't changed: ";
    m3.SetPower(-1);
    m3.Print();
    cout << "Monomial `m3` power was changed: ";
    m3.SetPower(3);
    m3.Print();

    // can add monomials with the same powers
    cout << "Monomial addition" << endl;
    m1.Add(m2);
    cout << "x + 2x = ";
    m1.Print();
    // cannot add monomials with different powers
    cout << "x³ + 12.5x³ = ";
    m2.Add(m3);

    // can multiply monomial to a number
    cout << "Monomial multiplication by a number" << endl;
    m2.Multiply(2.5);
    cout << "2x * 2.5 = ";
    m2.Print();

    // can multiply monomials
    cout << "Monomial multiplication by a monomial" << endl;
    m3.Multiply(m4);
    cout << "12.5x³ * -3xⶠ= ";
    m3.Print();

    // can raise monomial to the power
    cout << "Monomial exponentiation" << endl;
    m4.Exponent(3);
    cout << "(-3xâ¶)³ = "; // -27x^18
    m4.Print();
    cout << "(3x)â° = "; // -27x^18
    m1.Exponent(-10);

    return 0;
}

Test Driver Output

Monomial `m1` has the coefficient 1 and power 1: 1x^1
Monomial `m2` has the coefficient 2 and power 1: 2x^1
Monomial `m3` has the coefficient 12.5 and power 1: 12.5x^1
Monomial `m4` has the coefficient -3 and power 6: -3x^6
Monomial `m3` power wasn't changed: 12.5x^1
Monomial `m3` power was changed: 12.5x^3
Monomial addition
x + 2x = 3x^1
x³ + 12.5x³ = Cannot add monomials with different powers
Monomial multiplication by a number
2x * 2.5 = 5x^1
Monomial multiplication by a monomial
12.5x³ * -3x⁶ = -37.5x^9
Monomial exponentiation
(-3x⁶)³ = -27x^18
(3x)⁰ = Can raise only to a positive power

In: Computer Science

C++ ONLY Binary Search and Selection Sort A binary search first requires a sort. Use a...

C++ ONLY Binary Search and Selection Sort

A binary search first requires a sort.

Use a selection sort to organize an array, then find the value using a binary search.

Input the array, and a value to find.

Output the sorted array and the value if contained in the array.

/*
* File: main.cpp
* Author:
* Created on:
* Purpose: Binary Search
*/

//System Libraries
#include <iostream> //Input/Output Library
#include <cstdlib> //Random Functions
#include <ctime> //Time Library
using namespace std;

//User Libraries

//Global Constants, no Global Variables are allowed
//Math/Physics/Conversions/Higher Dimensions - i.e. PI, e, etc...

//Function Prototypes
void fillAry(int [],int);
void prntAry(int [],int,int);
void selSrt(int [],int);
bool binSrch(int [],int,int,int&);

//Execution Begins Here!
int main(int argc, char** argv) {
//Set the random number seed
srand(static_cast<unsigned int>(time(0)));
  
//Declare Variables
const int SIZE=100;
int array[SIZE];
int indx,val;
  
//Initialize or input i.e. set variable values
fillAry(array,SIZE);

//Sorted List
selSrt(array,SIZE);
  
//Display the outputs
prntAry(array,SIZE,10);
cout<<"Input the value to find in the array"<<endl;
cin>>val;
if(binSrch(array,SIZE,val,indx))
cout<<val<<" was found at indx = "<<indx<<endl;

//Exit stage right or left!
return 0;
}

In: Computer Science

Java Question I have a Queue containing String type taking in a text file with an...

Java Question

I have a Queue containing String type taking in a text file with an iterator.

I need to use ArrayList and HashMap for freqHowMany to get a frequency table in descending order by the highest frequency words in the text. Any help would be much appreciated and thanks!

final Iterator input = new Scanner(System.in).useDelimiter("(?U)[^\\p{Alpha}0-9']+");
        final Queue queueFinal = new CircularFifoQueue<>(wordsLast);

        while (input.hasNext()) {
            final String queueWord = input.next();
            if (queueWord.length() > minimumLength) {
                queueFinal.add(queueWord); // the oldest item automatically gets evicted
            }

            System.out.println(queueFinal);
        }
    }
}

EXAMPLE:

Your program prints an updated word cloud for each sufficiently long word read from the standard input.

The program takes up to three positive command-line arguments:

  • freqHowMany indicates the size of the word cloud, i.e., the number of words in descending order of frequency to be shown
  • wordMinLength indicates the minimum length of a word to be considered; shorter words are ignored
  • wordLastNwords indicates the size of a moving window of n most recent words of sufficient length for which to update the word cloud

Your program then reads a continuous stream of words, separated by whitespace or other non-word characters, from the standard input. (A word can have letters, numbers, or single quotes.) For each word read, your program prints to standard output, on a single line, a textual representation of the word cloud of the form

The idea is to connect this tool to a streaming data source, such as Twitter, or speech-to-text from a 24-hour news channel, and be able to tell from the word cloud in real time what the current "hot" topics are.

THANKS!

In: Computer Science

CPP Task: You are to write a class called Monomial, using filenames monomial.h and monomial.cpp, that...

CPP Task: You are to write a class called Monomial, using filenames monomial.h and monomial.cpp, that will allow creation and handling of univariate monomials, as described below.

Monomial Description

Each monomial object has following properties:

  • Each monomial has a coefficient and a power.
  • Monomial power is always positive.
  • Monomial power is always integer.
  • Monomials cannot be added if they have different powers

Class Details

  1. The single constructor for the Monomial class should have 2 parameters: an floating point coefficient value (optional, with a default value of 1.0); and an integer power value (optional, with a default value of 1). If the power value is less then 1, set the power to 1. The class will need to provide internal storage for any member data that must be kept track of.

  2. There should be member functions GetCoefficient, and GetPower, which will return the monomial’s coefficient value, and monomial’s power value, respectively. The GetPower method should return integer results. The GetCoefficient function should return its result as a float.

  3. There should be member functions SetPower, which will set the monomial’s power to the arbitrary positive value. If the parameter is not positive then set the power to the default value 1.

  4. There should be member function Add, which adds the one monomial to the other. The parameter of this member function need to be a constant reference to the other monomial object. The monomials can only be added if they have the same power, otherwise error message must be printed. The result of the addition is saved in the caller object.

  5. There should be two member functions Multiply (overrides), which each allow to multiply a monomial to a number and to another monomial. The first member function need to accept floating point parameter that is used to perform multiplication of the real number on the the monomial object. The second member function need to accept a constant reference to the other monomial object. Use monomials to coefficients and powers to perform their multiplication. The result of the multiplication is saved in the caller object.

  6. There should be a member function called Exponent that perform exponentiation (raise to power) of the monomial to the specified power value. You only can raise monomial to the positive power, if the power parameter is not positive print error message. The result of the exponentiation is saved in the caller object.

  7. A sample driver program (called monomial-driver.cpp) is provided. It uses objects of type Monomial and illustrates sample usage of the member functions.

  8. Your class declaration and definition files must work with my main program from the test driver, as-is (do not change my program to make your code work!). You are encouraged to write your own driver routines to further test the functionality of your class, as well. Most questions about the required behavior of the class can be determined by carefully examining my driver program and the sample execution. Keep in mind, this is just a sample. Your class must meet the requirements listed above in the specification - not just satisfy this driver program. (For instance, I haven’t tested every illegal fill character in this driver program - I’ve just shown a sample). Your class will be tested with a larger set of calls than this driver program represents.

General Requirements

  • No global variables, other than constants!
  • All member data of your class must be private
  • You can only use the <iostream> library for output. !!! No other libraries are allowed !!!.
  • When you write source code, it should be readable and well-documented.
  • Here are some general notes on style guidelines
  • Your monomial.h file should contain the class declaration only. The monomial.cpp file should contain the member function definitions.

Test Driver:

//
// driver.cpp -- driver program to demonstrate the behavior of
//               the Monomial class

#include <iostream>
#include "monomial.h"

using namespace std;

int main()
{
    // create some monomial: x, 2x, 12.5x³, -3xâ¶
    Monomial m1, m2( 2.0 ), m3( 12.5, -1 ), m4( -3.0 , 6);
    // display monomial
    cout << "Monomial `m1` has the coefficient " << m1.GetCoefficient()
         << " and power " << m1.GetPower() << ": ";
    m1.Print();
    cout << "Monomial `m2` has the coefficient " << m2.GetCoefficient()
         << " and power " << m2.GetPower() << ": ";
    m2.Print();
    cout << "Monomial `m3` has the coefficient " << m3.GetCoefficient()
         << " and power " << m3.GetPower() << ": ";
    m3.Print();
    cout << "Monomial `m4` has the coefficient " << m4.GetCoefficient()
         << " and power " << m4.GetPower() << ": ";
    m4.Print();

    // Change monomial power
    cout << "Monomial `m3` power wasn't changed: ";
    m3.SetPower(-1);
    m3.Print();
    cout << "Monomial `m3` power was changed: ";
    m3.SetPower(3);
    m3.Print();

    // can add monomials with the same powers
    cout << "Monomial addition" << endl;
    m1.Add(m2);
    cout << "x + 2x = ";
    m1.Print();
    // cannot add monomials with different powers
    cout << "x³ + 12.5x³ = ";
    m2.Add(m3);

    // can multiply monomial to a number
    cout << "Monomial multiplication by a number" << endl;
    m2.Multiply(2.5);
    cout << "2x * 2.5 = ";
    m2.Print();

    // can multiply monomials
    cout << "Monomial multiplication by a monomial" << endl;
    m3.Multiply(m4);
    cout << "12.5x³ * -3xⶠ= ";
    m3.Print();

    // can raise monomial to the power
    cout << "Monomial exponentiation" << endl;
    m4.Exponent(3);
    cout << "(-3xâ¶)³ = "; // -27x^18
    m4.Print();
    cout << "(3x)â° = "; // -27x^18
    m1.Exponent(-10);

    return 0;
}

Test Driver Output

Monomial `m1` has the coefficient 1 and power 1: 1x^1
Monomial `m2` has the coefficient 2 and power 1: 2x^1
Monomial `m3` has the coefficient 12.5 and power 1: 12.5x^1
Monomial `m4` has the coefficient -3 and power 6: -3x^6
Monomial `m3` power wasn't changed: 12.5x^1
Monomial `m3` power was changed: 12.5x^3
Monomial addition
x + 2x = 3x^1
x³ + 12.5x³ = Cannot add monomials with different powers
Monomial multiplication by a number
2x * 2.5 = 5x^1
Monomial multiplication by a monomial
12.5x³ * -3x⁶ = -37.5x^9
Monomial exponentiation
(-3x⁶)³ = -27x^18
(3x)⁰ = Can raise only to a positive power

In: Computer Science

1/Your team was asked to program a self-driving car that reaches its destination with minimum travel...

1/Your team was asked to program a self-driving car that reaches its destination with minimum travel time.

Write an algorithm for this car to choose from two possible road trips. You will calculate the travel time of each trip based on the car current speed and the distance to the target destination. Assume that both distances and car speed are given.

2/

Write a complete Java program that do the following:

  1. Declare String object and a variable to store your name and ID.
  2. DisplayYour Name and Student ID.
  3. Display Course Name, Code and CRN
  4. Replace your first name with your mother/father name.
  5. Display it in an uppercase letter.

Note:Your program output should look as shown below.

My Name: Ameera Asiri

My student ID: 123456789

My Course Name: Computer Programming

My Course Code: CS140

My Course CRN: 12345

AIYSHA ASIRI

Note: Include the screenshot of the program output as a part of your answer.

3/

Write a tester program to test the mobile class defined below.

Create the class named with your id (for example: Id12345678) with the main method.

  1. Create two mobiles M1 and M2 using the first constructor.
  2. Print the characteristics of M1 and M2.
  3. Create one mobile M3 using the second constructor.
  4. Change the id and brand of the mobile M3. Print the id of M3.

Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.

public class Mobile {

private int id;

private String brand;

public Mobile() {

    id = 0;

    brand = "";

}

public Mobile(int n, String name) {

    id = n;

    brand = name;

}

public void setBrand(String w) {

    brand = w;

}

public void setId(int w) {

    id = w;

}

Public int getId() {

return id;

}

public String getBrand() {

return brand;

}

}

4/

Write a method named raiseSalary that accepts two integers as an argument and return its sum multiplied by 15%. Write a tester program to test the method. The class name should be your ID (for example: Id12345678).

Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.

In: Computer Science

#C. Write a program that accepts any number of homework scores ranging in value from 0...

#C.

Write a program that accepts any number of homework scores ranging in value from 0 through 10. Prompt the user for a new score if they enter a value outside of the specified range. Prompt the user for a new value if they enter an alphabetic character. Store the values in an array. Calculate the average excluding the lowest and highest scores. Display the average as well as the highest and lowest scores that were discarded.

In: Computer Science

Please provide ALL documentation stated at the bottom (in bold) for each circuit Description: Build and...

Please provide ALL documentation stated at the bottom (in bold) for each circuit

Description: Build and test the following circuits using gate-level modeling in Verilog HDL.

1. 3-input majority function.

2. Conditional inverter (see the table below: x - control input, y - data input). Do NOT use XOR gates for the implementation.

x Output
0 y
1 y'

3. Two-input multiplexer (see the table below: x,y - data inputs, z - control input).

z Output
0 x
1 y

4. 1-bit half adder.

5. 1-bit full adder by cascading two half adders.

6. 1-bit full adder directly (as in fig. 4.7 in the text).

7. 4-bit adder/subtractor with overflow detection by cascading four 1-bit full adders (see fig. 4.13 in the text). Use multiple bit variables (vectors) for the inputs and output (see 4-bit-adder.vl)

Requirements:

  1. Create truth tables and use maps for simplification (not needed for circuits 5 and 7).
  2. Create a module for each circuit, instantiate it in a test module and test it.
  3. The hierarchical circuits (5 and 7) should use instances of their constituent modules.
  4. For testing use  all combinations of input values and show the corresponding output for all circuits except for the 4-bit adder/subtractor.
  5. No need to use all possible inputs for testing the 4-bit adder/subtractor. You may pick one positive number, one negative number and 0, and then add and subtract all combinations of two of them. Test also overflow situations and show the inputs/output both in binary and signed decimal.

Documentation:

***************Write a project report containing for each circuit:***************************

  1. Short text description.
  2. Truth table and map for the functions that can be simplified (not needed for the hierarchical implementations 5 and 7).
  3. Gate level circuit diagram with components and wires labeled with the names as used in the Verilog code. Use block diagrams for the components of the hierarchical circuits.
  4. HDL source code (included as text, not image).
  5. Verilog output showing the test results as explained in the requirements.

In: Computer Science

1/Your team was asked to program a self-driving car that reaches its destination with minimum travel...

1/Your team was asked to program a self-driving car that reaches its destination with minimum travel time.

Write an algorithm for this car to choose from two possible road trips. You will calculate the travel time of each trip based on the car current speed and the distance to the target destination. Assume that both distances and car speed are given.

2/

Write a complete Java program that do the following:

  1. Declare String object and a variable to store your name and ID.
  2. DisplayYour Name and Student ID.
  3. Display Course Name, Code and CRN
  4. Replace your first name with your mother/father name.
  5. Display it in an uppercase letter.

Note:Your program output should look as shown below.

My Name: Ameera Asiri

My student ID: 123456789

My Course Name: Computer Programming

My Course Code: CS140

My Course CRN: 12345

AIYSHA ASIRI

Note: Include the screenshot of the program output as a part of your answer.

3/

Write a tester program to test the mobile class defined below.

Create the class named with your id (for example: Id12345678) with the main method.

  1. Create two mobiles M1 and M2 using the first constructor.
  2. Print the characteristics of M1 and M2.
  3. Create one mobile M3 using the second constructor.
  4. Change the id and brand of the mobile M3. Print the id of M3.

Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.

public class Mobile {

private int id;

private String brand;

public Mobile() {

    id = 0;

    brand = "";

}

public Mobile(int n, String name) {

    id = n;

    brand = name;

}

public void setBrand(String w) {

    brand = w;

}

public void setId(int w) {

    id = w;

}

Public int getId() {

return id;

}

public String getBrand() {

return brand;

}

}

4/

Write a method named raiseSalary that accepts two integers as an argument and return its sum multiplied by 15%. Write a tester program to test the method. The class name should be your ID (for example: Id12345678).

Your answer should include a screenshot of the output. Otherwise, you will be marked zero for this question.

In: Computer Science

Please convert This java Code to C# (.cs) Please make sure the code can run and...

Please convert This java Code to C# (.cs)
Please make sure the code can run and show the output 
Thank you!
Let me know if you need more information.

Intructions

For this assignment you will be creating two classes, an interface, and a driver program:

  • Class Calculator will implement the interface CalcOps
    o As such it will implement hexToDec() - a method to convert from

    Hexadecimal to Decimal.

  • Class HexCalc will inherit from Calculator.

  • Interface CalcOps will have abstract methods for add( ), subtract( ),

    multiply( ) and divide( ).

  • Both classes will implement the CalcOps interface.

o Class Calculator’s add, subtract, multiply and divide will take in 2 integers and return an integer. If you prefer it can take in 2 strings, and return a string.

o Class HexCalc’s add, subtract, multiply and divide will take in 2 strings (hexadecimal numbers) and return a string (hexadecimal number).

This Calculator class will work with whole numbers (int) and hexadecimal (String) values. The hexToDec ( ) method is a helper method included in interface CalcOps, that requires the Calculator class to implement the method which converts hexadecimal numbers to decimal. (Hint: Use language specific utility methods to convert hexadecimal to decimal.)

SOURCE CODE
TestCalculator.java
---------------------------------------------------------------------
import java.util.*;

public class TestCalculator {

    static Scanner sc = new Scanner(System.in);

    public static  void  main(String[] args) {

        System.out.println("Would you like to do calculations with " +
                "decimal or hexadecimal numbers (1 for Decimal, 2 for Hexadecimal)?");
        int choice = sc.nextInt();
        while(true) {
            int operation = menu();
            if (operation == 0) {
                System.out.println("You chose to Exit> THANK YOU !!! HAVE A GREAT DAY!!! ");
                System.exit(0);
            }
            Calculator parent = new Calculator();

            if (choice == 1) {

                System.out.println("Please enter the first number");
                int first = sc.nextInt();
                System.out.println("Please enter the second number");
                int second = sc.nextInt();

                switch (operation) {
                    case 1:
                        System.out.println(parent.add(first, second));
                        break;
                    case 2:
                        System.out.println(parent.subtract(first, second));
                        break;
                    case 3:
                        System.out.println(parent.multiply(first, second));
                        break;
                    case 4:
                        System.out.println(parent.divide(first, second));
                        break;
                }
            }
            if (choice == 2) {
                System.out.println("Please enter the first hexadecimal number");
                String f = sc.next();
                System.out.println("Please enter the second hexadecimal number");
                String s = sc.next();

                HexCalc child = new HexCalc();
                // convert from String to int
                int first = parent.hexToDec(f);
                int second = parent.hexToDec(s);

                switch (operation) {
                    case 1:
                        System.out.println(child.decToHex(parent.add(first, second)));
                        break;
                    case 2:
                        System.out.println(child.decToHex(parent.subtract(first, second)));
                        break;
                    case 3:
                        System.out.println(child.decToHex(parent.multiply(first, second)));
                        break;
                    case 4:
                        System.out.println(child.decToHex(parent.divide(first, second)));
                        break;
                }

            }
        }

    }
    public static int menu() {
        System.out.println("---MENU---");
        System.out.println("0 - Exit");
        System.out.println("1 - Addition");
        System.out.println("2 - Subtraction");
        System.out.println("3 - Multiplication");
        System.out.println("4 - Division");
        System.out.print("Please Choose an Option: ");

        return sc.nextInt();
    }
}

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

Calcops interface 
----------------
public interface Calcops {

    // basic arithmetic operations
    public int hexToDec (String hexToDecimal) ;
    public int add(int a1, int a2);
    public int subtract(int s1, int s2);
    public int  multiply(int m1, int m2);
    public int divide(int d1, int d2);

}

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

Calculator.java
-------------------------------------------
public class Calculator implements CalcOps{

    public int hexToDec(String hexToDecimal) {
        int dec = Integer.parseInt(hexToDecimal,16);
        return dec;
    }

    public int add(int x, int y) {
        return x+y;
    }

    public int subtract(int x, int y) {
        return x-y;
    }

    public int multiply(int x, int y) {
        return x*y;
    }

    public int divide(int x, int y) {
        return x/y;
    }
}

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

HexCalc.java
----------------
public class HexCalc extends Calculator implements CalcOps{

    public String decToHex(int Dec) {
        String hex = Integer.toHexString(Dec);
        return hex;
    }
}

================================================================================================

OUTPUT

===================================================

In: Computer Science

(a) Create a class Webcam which stores the information of a webcam. It includes the brand,...

(a) Create a class Webcam which stores the information of a webcam. It includes the brand, the model number (String) and the price (double, in dollars). Write a constructor of the class to so that the information mentioned is initialized when a Webcam object is created. Also write the getter methods for those variables. Finally add a method toString() to return the webcam information in the following string form. "brand: Logitech, model number: B525, price: 450.0" Copy the content of the class as the answers to this part.

(b) Create a class ComputerShop which stores the webcam information in a map webcamMap, whose key is the concatenation of the brand and model number, separated by ": " (a colon and a space). The value is a Webcam object. Write a method addWebcam(Webcam oneWebcam) which adds oneWebcam to webcamMap. Copy the content of the class, which any include import statement(s) required, as the answers to this part.

(c) Create a class TestComputerShop with a main() method which creates a ComputerShop object aShop and add the first webcam with brand "Logitech", model number "B525" and price 450.0. Add the second webcam with brand "Microsoft", model number "HD-3000" and price 235.0. Copy the content of the class as the answers to this part.

(d) Write a method showWebcam() of ComputerShop which loops through the keys of webcamMap using the enhanced for-loop and directly prints each webcam object stored using System.out.println(). (Loop through the values is simpler but using the keys is required in this part.) This should show suitable information since the method toString() has been written in (a). Add a statement in TestComputerShop to display all the webcam information of aShop. Copy the content of the method, line(s) added and execution output as the answers to this part.

(e) Write a method modelNumberSet() of ComputerShop which returns model numbers of the webcams in a set. You should loop through the values of webcamMap using the enhanced for-loop and collect the model numbers. Add a statement in TestComputerShop to display the set using System.out.println(). Copy the content of the method, line(s) added and new execution output as the answers to this part.

(f) Write a method priceList() of ComputerShop which returns the prices of the webcams in a list. You should loop through the values of webcamMap using the enhanced for-loop and collect the prices of the webcams. Add a statement in TestComputerShop to display the list using System.out.println(). Copy the content of the method, line(s) added and new execution output as the answers to this part.

In: Computer Science

Write a program that plays an addition game with the user (imagine the user is a...

Write a program that plays an addition game with the user (imagine the user is a 5th grade student).

First ask the user how many addition problems they want to attempt.

Next, generate two random integers in the range between 10 and 50 inclusive. You must use the Math.random( ) method call.   Prompt the user to enter the sum of these two integers. The program then reports "Correct" or "Incorrect" depending upon the user's "answer".  If the answer was incorrect, show the user the the correct sum.

Display a running total of how many correct out of how many total problems ( ex: 2 correct out of 5, 3 correct out of 5, etc) after each problem is answered.

Continue this until the user has attempted the total number of problems desired.

java

In: Computer Science

A checksum is a value that is computed based upon some information. It is functional in...

A checksum is a value that is computed based upon some information. It is functional in the sense that given the same information, the exact same value will be computed.   Checksums are often used when information is being transmitted over a network. This lets the receiving end know if the information was transmitted accurately.

All published books have a unique 10 and 13 digit ISBN number. This stands for International Standard Book Number. Your textbook in this class has an ISBN-10 number. The first 9 digits (which may include leading zeros) are the information part of the ISBN-10 number. The 10th digit is a checksum which is calculated from the other 9 digits using the following formula where d1 is the first digit beginning on the left, d2 is the second digit, etc.:

( (1* d1) + (2 * d2) + (3 * d3) + (4 * d4) + (5 * d5) + (6 * d6) + (7 * d7) + (8 * d8) + (9 * d9) ) % 11

Because the large sum then uses modulus 11 arithmetic, the possible values for the checksum are the numbers 0 through 10. According to the ISBN-10 convention, the checksum can only be a single character (digit) so if the checksum is 10 the last character is denoted as X (Roman numeral for 10) .

Write a program that loops, prompting the user to enter the first 9 digits into an input dialog box.  You must parse the input value as a single integer.  Compute the checksum digit and output the complete 10 digit ISBN number using a Confirm Dialog asking if the user wants to enter another 9 digit number. If the user selects the YES button, then loop. If NO is selected, the program will end.

An example of this program in action (without dialog boxes) is:

Enter the first 9 digits of an ISBN number: 013601267 <enter>

The ISBN-10 number is: 0136012671

Do you want to enter another? <yes>

Enter the first 9 digits of an ISBN number: 013031997 <enter>

The ISBN-10 number is: 013031997X

Do you want to enter another? <no>

Extracting the Digits from the Integer

The algorithm to compute the checksum is relatively simple, so the interesting part of this program is figuring out how to extract each of the 9 digits from the integer. Hint: Section 3.13 (9th Edition) Case Study: Lottery shows you how to extract the digits from a 2-digit number.

Remember, I am forcing you to turn the String from the dialog box into an integer. I will not accept a solution that doesn't do this. When the ISBN number has leading zeros, it makes the problem more complex because you must go from a String to an int and back to a String again.

In: Computer Science

There are several typical cube computation methods such as Multi-Way, BUC, and Star-cubing. Briefly describe each...

There are several typical cube computation methods such as Multi-Way, BUC, and Star-cubing. Briefly describe each one of these methods outlining the key points.

Please write, not a screenshot

In: Computer Science

A RISC processor that uses the five-stage instruction fetch and execution design is driven by a...

A RISC processor that uses the five-stage instruction fetch and execution design is driven by a 1-GHz clock. Instruction statistics in a large program are as follows:

Branch                                                20%

Load                                                    30%

Store                                                    10%

Computational instructions                40%

Please answer the following questions.

1-Assume 80% of the memory access operations are in the cache, and 20% are in the main memory. A cache miss has a 3-cycle penalty. What is the instruction throughput for non-pipelined execution?

2- Assume there are an instruction cache and a data cache. For both caches, a cache miss stalls the pipeline for 3 cycles. Assume the cache hit rate for the instruction cache is 85%. 80% of the Load instructions load data from the data cache, while 20% of them load data from the main memory. 40% of the Store instructions store data into the data cache, while 60% of them store data into the main memory. What is the instruction throughput for pipelined execution?

3-Assume all memory accesses are cache hit. 20% of the Load instructions are followed by a dependent computational instruction, and 30% of the computational instructions are also followed by a dependent computational instruction. 20% of the branch instructions are unconditional, while 80% are conditional. 40% of the conditional branches are taken, 60% are not taken. The penalty for taking the branch is one cycle. If data forwarding is allowed, what is the instruction throughput for pipelined execution?

In: Computer Science

In each of these exercises, consider the relation, CKs, and FDs. Determine if the relation is...

In each of these exercises, consider the relation, CKs, and FDs. Determine if the relation is in BCNF, and if not in BCNF give a non-loss decomposition into BCNF relations. The last 5 questions are abstract and give no context for the relation nor attributes.

1. Consider a relation Player which has information about players for some sports league. Player has attributes id, first, last, gender. id is the only CK and the FDs are:
idfirst
idlast
idgender

Player-sample data

ID First Last gender
1 Jim Jones Male
2 Betty Smith Female
3 Jim Smit Male
4 Lee Mann Male
5 Samantha McDonald Female

2.Consider a relation Employee which has information about employees in some company. The employee has attributes id, first, last, sin (social insurance number) where id and sin are the only CKs, and the FDs are:
idfirst
idlast
sinfirst
sinlast
idsin
sinid

Employee – sample data

ID First Last SIN
1 Jim Jones 111222333
2 Betty Betty 333333333
3 Jim Smith 456789012
4 Lee Mann 123456789
5 Samantha McDonald 987654321
  • Complete the exercise to achieve 3NF. Describe in your own words these normalization concepts into your saved document file.
    • You may display this information in table format (as posted in the exercise) or use DBDL design format.

In: Computer Science