Questions
In need of assistance in C++ code: Design and implement class Rectangle to represent a rectangle...

In need of assistance in C++ code:

Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods:

  1. Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 0 in the default constructor.
  2. A non-argument constructor method to create a default rectangle.
  3. Another constructor method to create a rectangle with user-specified height and width.
  4. Method getArea() that returns the area.
  5. Method getPerimeter() that returns the perimeter.
  6. Method getHeight() that returns the height.
  7. Method getWidth() that returns the width.

Now design and implement a test program to create two rectangle objects: one with default height and width, and the second is 5 units high and 6 units wide. Next, test the class methods on each object to print the information as shown below.

Sample run:

First object:

Height:     1 unit

Width:      1 unit

Area:       1 unit

Perimeter: 4 units

Second object:

Height:     5 unit

Width:      6 unit

Area:       30 units

Perimeter: 22 units

Thanks in advance!

In: Computer Science

Create a module to calculate the amount of royalties that Parker Schnabel must pay Tony Beets...

Create a module to calculate the amount of royalties that Parker Schnabel must pay Tony Beets at the end of the gold mining season based on the following contractual agreement. When the amount of gold mined is 3000 ounces or less the rate is 15% of the gold value. This lower royalty rate is stored in a variable named lowerRate. When the amount of gold mined is greater than 3000 ounces the royalty rate is 20%. This higher rate is stored in a variable named goldRushRate and is applied only to the amount over 3000 ounces. The price of gold is currently $1200.00. This amount is stored in a variable defined as priceGold. The number of ounces mined is stored in a variable integer ouncesMined. You should ask Parker to input the number of ounces that he mined this season and print out “Based on x ounces mined, you paid y in royalties.”  You will need to multiply the ounces of gold mined by the price by the royalty rate to produce the proper royalties.

In: Computer Science

I need an app ideas for social distancing due to covid-19

I need an app ideas for social distancing due to covid-19

In: Computer Science

Systems Analysis 8. Explain how Agile techniques for systems analysis and design are different from the...

Systems Analysis

8. Explain how Agile techniques for systems analysis and design are different from the structured or other object oriented methodologies. Discuss the advantages and disadvantages of the methods and the conditions under which you would use them. (25 points)

In: Computer Science

PYTHON PROGRAM QUESTION 1 Briefly describe how a while loop works QUESTION 2 Compare and contrast  a...

PYTHON PROGRAM

QUESTION 1

  1. Briefly describe how a while loop works

QUESTION 2

Compare and contrast  a while statement and an  if statement ?

QUESTION 3

What is a loop body?

QUESTION 4

What is the value of variable num after the following code segment?

num = 10;

while  num > 0:
  num = num -1;

QUESTION 5

What is the value of variable num after the following code segment is executed?

var num = 1

while  num >10:

  num = num -1

QUESTION 6

Why the loop does not terminate?

n = 10
answer = 1
while n > 0:
answer = answer + n
    n = n + 1
print(answer)

QUESTION 7

Convert the following for loop to a while loop.

total = 0
for i in range(10):
total = total + i

print(total)

QUESTION 8

Write a while loop to display from 0 to 100, step up 5 each time.

0, 5, 10, 15, 20, ... , 100

In: Computer Science

assume the following instruction frequencies/composition in the program: load (lw) 22% sub / compare 21% conditional...

assume the following instruction frequencies/composition in the

program:

load (lw) 22%

sub / compare 21%

conditional branch 20%

store (sw) 12%

add / move 12%

and 6%

4.

How long would it take to run a 100 instruction program on a single cycle datapath architecture, assuming a cycle time of 50ns?

(14)

5.

How long would it take to run the same 100 instruction program on a multi-cycle datapath architecture, assuming a cycle time of 8ns. Further assume that “lw” takes 6 cycles, “sw” takes 4 cycles, and all other instructions take 3 cycles to execute.
(14)

In: Computer Science

Code in C++, create the erase function shown in int main() /* Use of dynamic memory...

Code in C++, create the erase function shown in int main()

/* Use of dynamic memory to implement dynamic array (like vector) */

#include <iostream>
using namespace std;

class MyVector {
private:
    int* arr; //only stores ints
    int size;
    int cap;
public:
    MyVector() : arr{nullptr} {}; // Default constructor;
    ~MyVector(); // Destructor: Cleans up stuff. Here deletes arr
    void push(int ele); // inserts element into vector
    friend ostream& operator <<(ostream& os, MyVector& v);
    
    
};


int main()
{
    MyVector vec;
    vec.push(1); //should store 1 in the vec
    vec.push(2); // should store 2 into the vec
    vec.push(10); // should print all elements
    vec.erase(0) // Erase element at position 0
    cout << vec << endl; // should print remaining elements
    
}

MyVector::~MyVector() // Destructor
{
    delete[] arr;
    cout << "Destroyed vector" << endl;
    
}

ostream& operator <<(ostream& os, MyVector& v)
{
    for(int i = 0; i < v.size; i++)
        os << v.arr[i] << " ";
    return os;
}

void MyVector::push(int ele)
{
    // Check if arr == nullptr. If yes, dynamically create an array of elements. Insert ele into array
    if (arr == nullptr) {
        cap = 2;
        arr = new int[cap];
        arr[0] = ele;
        size = 1;
    }
    else {
        // Check if there is space
        if (size < cap) {
            arr[size] = ele;
            size++;
        }
        else {
            int* temp = arr;
            arr = new int[2*cap];
            for (int i = 0; i < cap; i++)
                arr[i] = temp[i];
            delete[] temp;
            cap = 2*cap;
            arr[size] = ele;
            size++;
        }

    }
    
}

In: Computer Science

in java A NavigableSet is a set that stores it’s element in order. Say we have...

in java

A NavigableSet is a set that stores it’s element in order. Say we have a bunch of items
and we want to store them in order but we don’t want any duplicates. Write a generic
class that implements a structure that does that.

In: Computer Science

C data structure Initially, we do not need to do any error checking - we can...

C data structure

Initially, we do not need to do any error checking - we can assume that the input postfix expression is syntactically correct.

Input

The input is a string that represents a postfix expression. To simplify the problem, your calculator will be restricted to operating on single-digit non-negative integers. Only the following characters are allowed in the string:

  • the operators '+', '-'. '*', and '/'

  • the digits '0' through '9'

  • the space (blank) character ' '

Example input:

  7 8 5 * +

Processing

To handle spaces in the input, need to make one minor addition to the algorithm

  if (ch is a blank)

      ignore it

   end if

Program should ask the user to enter a text file with postfix expression on a single line. we can either read the line one character at a time, or can read the line into a string and then process the string one character at a time. Your program should then print the value of the expression. program should include a loop so that the user can evaluate multiple postfix expressions. Your output might look like:

  Enter postfix expression:

   5 8 9 + *

   The value of the expression is result of postfix

   More expressions (Y or N)? Y

   Enter postfix expression:

   9 5 /

   The value of the expression is 1

   More expressions (Y or N)? N

program should perform integer calculations only(single digit only). Do not use floating-point (float or double) variables for your calculations.

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

Second part would be interesting in this part we have to do error checking after calculator thoroughly tested.

Error checking

1). Invalid character in the input expression- if the error occurs, print an error message stating that an invalid character was encountered.

2) Stack is empty when the algorithm needs to remove an operand- this happens when the expression has too many operators or when the operators and operands are not ordered correctly. We call this a malformed expression, if this occurs, print an error message indicating that the expression is malformed.

3). When the loop in the algorithm ends, there should be exactly one value left on the stack and it is the value of input expression. If the input contained too many operands, there will be more than one value left on the stack. If you remove what should be the result of the expression and the stack is not empty, then the expression was malformed and should print error message indicating.

In all cases, if an error occurs do not try to continue processing the input string and do not try to print the value of the expression. Just print the error message. Do not end application- just ask user if he wants to try another expression.

In: Computer Science

In C++ Language: Program a multiple(4) choice quiz with 10 question that allows the user to...

In C++ Language: Program a multiple(4) choice quiz with 10 question that allows the user to input their choice. Validate their choice, if choice is valid continue. If choice is not valid have the user input a different answer. If the user gets 3 of the 10 choices incorrect, then the quiz is over.

In: Computer Science

Discuss the three types of communication in IPv4 network

Discuss the three types of communication in IPv4 network

In: Computer Science

Consider this class with a const variable and function: class Student { private: const int IDNum;...

Consider this class with a const variable and function:
class Student {
private:
const int IDNum;
public:
Student();
int getIDNum() const:
};
a. How do you initialize the const variable IDNum to 100? Write the code:
b. Are getters normally declared const?
c. Are setters normally declared const?
d. Can a const function call a non-const function?
e. Can a non-const function call a const function?
f. Can a const function use a non-const variable?
g. Can a non-const function use a const variable?

In: Computer Science

using matlab: 1- Using ‘input’ command, ‘prompt’ your name and ask for a grade (A, B,...

using matlab:

1- Using ‘input’ command, ‘prompt’ your name and ask for a grade (A, B, C, D, F should be accepted only, otherwise it should ask again)

2- Use ‘display’ command for the previous problem and display your name and your grade

In: Computer Science

What are the 3 goals of computer security, define them Design a Authentication mutual protocol not...

What are the 3 goals of computer security, define them

Design a Authentication mutual protocol not subject to reflection attack

What are 3 types of hashing. Draw a diagram of hash function

What is a memory layout. Draw an example

Describe Buffer Flow attack

In: Computer Science

1. Insight into RF systems a. Would a high-gain dish antenna be suitable for use as...

1. Insight into RF systems

a. Would a high-gain dish antenna be suitable for use as the antenna at the base station in a PtMP (Point to Multi-Point) setup, yes or no? Explain your answer.

2. Radio frequency terminology:

Research and concisely describe the following RF terms:

  1. Isotropic antenna
  2. Antenna gain
  3. Beam width

In: Computer Science