Questions
In C++ 14.22 A dynamic class - party list Complete the Party class with a constructor...

In C++

14.22 A dynamic class - party list

Complete the Party class with a constructor with parameters, a copy constructor, a destructor, and an overloaded assignment operator (=).

//main.cpp

#include <iostream>

using namespace std;

#include "Party.h"

int main()
{
return 0;
}

//party.h

#ifndef PARTY_H
#define PARTY_H

class Party
{
private:
string location;
string *attendees;
int maxAttendees;
int numAttendees;
  
public:
Party();
Party(string l, int num); //Constructor
Party(/*parameters*/); //Copy constructor
Party& operator=(/*parameters*/);
//Add destructor
void addAttendee(string name);
void changeAttendeeAt(string name, int pos);
void print();
string getAttendeeAt(int pos);
int getMaxAttendees() const;
int getNumAttendees() const;
string getLocation() const;
};

#endif

//party.cpp

#include <iostream>
#include <string>

using namespace std;

#include "Party.h"

Party::Party()
{
//Default: 10 attendees, location = home
location = "Home";
maxAttendees = 10;
numAttendees = 0;
attendees = new string[maxAttendees];
}

Party::Party(string l, int num)
{
//Complete constructor with parameters
//If num<1, set maxAttendees = 10
}

Party::Party(/*parameters*/)
{
//Complete copy constructor
}

Party& Party::operator=(/*parameters*/)
{
//Complete assignment
}

//Add destructor


//The following functions are provided
//Do not change

void Party::addAttendee(string name)
{
if(numAttendees < maxAttendees)
{
attendees[numAttendees] = name;
numAttendees++;
}
else
cout << "Your party is already full!\n";
}

void Party::changeAttendeeAt(string name, int pos)
{
if(pos>=0 && pos<numAttendees)
attendees[pos] = name;
else
cout << "Invalid index.";
}

void Party::print()
{
if(numAttendees > 0)
{
cout << "Attendees list:\n";
for(int i = 0; i<numAttendees; i++)
cout << attendees[i] << endl;
}
else
cout << "List is empty! Invite more people to your party.\n";
}

string Party::getAttendeeAt(int pos)
{
if(pos>=0 && pos<numAttendees)
return attendees[pos];
else
return "Invalid index.";
}

int Party::getNumAttendees() const
{ return numAttendees; }

int Party::getMaxAttendees() const
{ return maxAttendees; }

string Party::getLocation() const
{ return location; }

In: Computer Science

Add a method to OurQueue class that dequeues the Nth item on a queue and returns...

Add a method to OurQueue class that dequeues the Nth item on a queue and returns it. It must remove the Nth item from the Queue but leave the rest of the queue.

Test it with the following code:

            Console.WriteLine("Testing DequeueNth");
            OurQueue<string> ourQ = new OurQueue<string>(12);
            // Empty Q
            try
            {
                ourQ.DequeueNth(0);
                Console.WriteLine("\a Error on empty list");
            }
            catch
            {
                Console.WriteLine("Empty Queue worked");
            }

            for (int i = 0; i < 9; ++i)
                ourQ.Enqueue("a" + i);
            for (int i = 0; i < 7; ++i)
                ourQ.Dequeue();
            for (int i = 0; i < 5; ++i)
                ourQ.Enqueue("b" + i);

            Console.WriteLine(ourQ);
            Console.WriteLine("Deleted {0}", ourQ.DequeueNth(5));
            Console.WriteLine(ourQ);
            Console.WriteLine("Deleted {0}", ourQ.DequeueNth(4));
            Console.WriteLine(ourQ);

In: Computer Science

true or false give reason language in java 1.A static inner class can access the instance...

true or false give reason language in java

1.A static inner class can access the instance variables and methods of its outer non-static class
2.executeQuery from statement may return more than one resultset object
3.Connection is java.sql interface that establishes a session with a specific database
4.Writable is an interface in Hadoop that acts as a wrapper class to almost all the primitive data type
5.Text is the wrapper class of string in Hadoop

In: Computer Science

I have the below program and I am having issues putting all the output in one...

I have the below program and I am having issues putting all the output in one line instead of two.

how can I transform the program for the user enter format ( HH:MM)
Like:
Enter time using 24 format ( HH:MM) : " and the user enter format " 14:25
then the program convert. instead of doing two lines make all one line.

Currently I have the user enter first the Hour and then the minutes but i'd like to change the program to have the user enter the Hour and Minute in the same line. using format : " HH:MM"

#include<iostream>
using namespace std;

void input(int& hours24, int& minutes){
  
   cout<<"Enter hours [0 -23]: "; cin >> hours24;
   cout<<"Enter minutes [0 - 59]: "; cin >> minutes;
}

void output(int hours, int minutes, char AMPM){
  
   if(hours<10) cout<<"0"; cout<<hours; cout<<":";
   if(minutes<10) cout<<"0"; cout<<minutes;
   if(AMPM=='A') cout<<" AM";
   else cout<<" PM";
   cout<<endl;
}

void convert(int& hours, char& AMPM){
   if(hours>12){
       hours-=12;
       AMPM = 'P';
   }
   else if(hours==12){
       AMPM ='P';
   }
   else if(hours==0){
       hours += 12;
       AMPM ='A';
   }
   else{
       AMPM = 'A';
   }
}


int main(){
  
   int hours, minutes;
   char AMPM, ans;
  
   do{
       input(hours,minutes);
       if(hours<0 || hours>23 || minutes<0 || minutes>59){
           cout<<"Error: Invalid hours/minutes entered.\n";
           cout<<"Program will terminate.\n";
           break;
       }
      
       convert(hours,AMPM);
       output(hours,minutes,AMPM);
      
       cout<<"Enter Y or y to continue,"
           <<" anything else quits.\n";
           cin >> ans;
      
   }while(ans=='Y' || ans =='y');


   return 0;
}

In: Computer Science

Python HW Open a new Jupyter notebook Create a new function named fibonacci() that takes one...

Python HW

  1. Open a new Jupyter notebook

  2. Create a new function named fibonacci() that takes one required parameter:

    1. maxint, an integer that will serve as the upper bound of the loop
  3. Following the example on the Python tutorial:

    https://docs.python.org/3/tutorial/introduction.html#first-steps-towards-programming

    Our implementation will have a few changes:

    1. While you will use a while loop to make a Fibonacci sequence, the upper bound of the sequence will be your maxint parameter.
    2. Store the results into a list and append each new generated number
  4. Return the newly generated sequence as a list.

Note

In our example we are choosing to include the initial 0 value.

Expected Output

>>> fibonacci(10)
[0, 1, 1, 2, 3, 5, 8]

Task 02

In this task, you'll be asked to create a simple for-loop to loop over a simple data construct, in this case, to provide the maximum, minimum, and average length of words in a speech performing a lexicographical analysis not unlike what's used to measure reading level.

Specifications

  1. Keep working on the same notebook
  2. Create a function named lexicographics() that takes one parameter:
    1. to_analyze, a required string
  3. Using a single for loop, calculate the following for your text:
    1. The maximum number of words per line in to_analyze (eg, the length of the longest line in to_analyze)
    2. The minimum number of words per line in to_analyze (eg, the length of the shortest line in to_analyze)
    3. The average number of words per line in to_analyze, stored as a decimal.
  4. Return these values as a tuple, in the order in which they are defined above

Expected Output

>>> lexicographics('''Don't stop believing,
Hold on to that feeling.''')
(5, 3, Decimal(4.0))

In: Computer Science

I'm trying to create a function determines the range of outliers in an array using pass...

I'm trying to create a function determines the range of outliers in an array using pass by reference.

I need to write a function that outputs the +3 and -3 standard deviation. I'm having a hard time figuring out what I should identify as my pointers and how to use the pass by reference. This is what I have so far:

#include <stdio.h>

#define ARRAY_SIZE 20

double homeworkArray[ARRAY_SIZE] = { 1.3, 5.7, 2.1, -1.2, 0.5, 4.3, 2.1, 50.2, 3.4, 1.1,

-2.1, 4.1, 6.7, 3.9, 4.1, -0.5, -3.3, 2.1, 5.1, -3.1 };

double CalculateMean(double data[], int size)

{

int i;

double sum = 0.0;

for (i = 0; i < size; i++)

{

sum += data[i];

}

return sum / size;

}

double CalculateStandardDeviation(double data[], int size)

{

double mean = CalculateMean(data, size);

double variance = 0.0;

double diff;

int i;

for (i = 0; i < size; i++)

{

diff = data[i] - mean;

variance += diff * diff;

}

return sqrt(variance / (size));}

}

  

int main(int argc, const char * argv[]) {

double lowerRange=0.0, upperRange=0.0;

  

  

double mean = CalculateMean(homeworkArray, ARRAY_SIZE);

double stddev = CalculateStandardDeviation(homeworkArray, ARRAY_SIZE);

printf("Anything outside of (%.2lf - %.2lf) is an outlier.\n",lowerRange,upperRange);

  

return 0;

}

  

In: Computer Science

(General math) In the game of blackjack, the cards 2 through 10 are counted at their...

(General math) In the game of blackjack, the cards 2 through 10 are counted at their face values, regardless of suit; all face cards (jack, queen, and king) are counted as 10; and an ace is counted as a 1 or an 11, depending on the total count of all cards in a player’s hand. The ace is counted as 11 only if the resulting total value of all cards in a player’s hand doesn’t exceed 21; otherwise, it’s counted as 1. Using this information, write a C++ program that accepts three card values as inputs (a 1 corresponding to an ace, a 2 corresponding to a two, and so on), calculates the total value of the hand, and displays the value of the three cards.

In: Computer Science

Write a C-program and run it to meet the requirements listed below. Use the nano editor...

Write a C-program and run it to meet the requirements listed below.

Use the nano editor on Windows or Mac or nano/Geany on R-pi or Geany on Mac.

After running the program, it print outs messages on the Terminal and waits for you to accept a

positive number greater than 9. When you enter a positive number greater than 9, it print outs

what you entered to confirm your input. Then, it calculates and prints out the total sum of 1 + 2 +

... + N, where N is what you entered. It repeats three (3) times to test the program.

The lines of your program need to be properly intended. You must include the scanf function.

[Hints: Use printf, scanf, for-loop, and/or while-loop in your program.]

The results on the Terminal should be similar to the following.

X1, X2, and X3 are the random positive numbers you entered on the Terminal, which should be

greater than 9.

Y1, Y2, and Y3 are the total sum that your program calculated. Your program should calculate

the correct total sum.

Do not embed X1, X2, X3, Y1, Y2, and Y3 in your C-program (No hard-coding).

Your program should accept your input (a number greater than 9) in the Terminal and calculate

the total sum three times before returning to the Terminal as shown below.

Let's calculate the total sum.

=> Please enter a positive number greater than 9:

X1

You entered X1.

The total sum is Y1,

=> Please enter a positive number greater than 9:

X2

You entered X2.

The total sum is Y2,

=> Please enter a positive number greater than 9:

X3

You entered X3.

The total sum is Y3,

Three (3) tests have been completed.

In: Computer Science

2. Write the hexadecimal numbers in the registers of $a0, $a1, $a2, $a3 after the following...

2. Write the hexadecimal numbers in the registers of $a0, $a1, $a2, $a3 after the following codes running:

ori $a0, $0, 11

ori $a1, $0, 19

addi $a1, $a1, -7

slt $t2, $a1, $a0

beq $t2, $0, label

addi $a2, $a1, 0

sub $a3, $a1,$a0

j end_1

label: ori $a2, $a0, 0

add $a3, $a1, $a0

end_1: xor $t2, $a1, $a0

*Values in $a0, $a1, $a2, $a3 after the above instructions are executed.

In: Computer Science

In Python b) Modify your program that reads 3 grades from the user (and computes the...

In Python

  • b) Modify your program that reads 3 grades from the user (and computes the average and letter grade) so that it uses a while loop to read the 3 grades. In the loop body, you will just read one grade and update other variables appropriately. The loop header will ensure 3 iterations.
  • c) Modify your program in part b so that it asks the user how many grades there are and uses a while loop to read that many grades.
  • d) Use a for loop instead of a while loop, for the count-controlled loop you did for part b or c

def read_number():
''' Read the number from the user.
Return a real number -- the number entered by the user.
'''
x_str = input("Enter a number (a real number >=0.0):")
y_str = input("Enter a number (a real number >=0.0):")
z_str = input("Enter a number (a real number >=0.0):")
x_float = float(x_str)
y_float = float(y_str)
z_float = float(z_str)
return x_float, y_float, z_float

def the_sum (x_float, y_float, z_float):
''' Calculate the sum and average of the integers.
Parameter:
integer_float -- a real number at least 0.
Return a real number -- the number of sum.
'''
# Define constant:
result_float = x_float + y_float + z_float
return result_float

def average (sum_float):
'''Calculate the sum and average of the integers.
Parameter:
integer_float -- a real number at least 0.
Return a real number -- the number of average.
'''
# Define constant:
average_float = (sum_float)/3
return average_float

def convert_letter_grade ():
if (average_float >=90 and average_float <=100):
print("The grade is A")
  
elif (average_float >=80 and average_float <=90):
print("The grade is B")
  
elif (average_float >=70 and average_float <=80):
print("The grade is C")
  
elif (average_float >=90 and average_float <=100):
print("The grade is D")
  
else:
print("The grade is F")
  
def print_number (average_float):
''' Print the number of sum and average.
Parameter:
sum_float -- a real number at least 0.
average_float -- a real number at least 0.
'''
print("The given numbers are %f %f %f" % (x_float, y_float, z_float))
# Round the average to three decimal places.
print("The equivalent number of average is {:.3f}".format(average_float))

# Main part of the program
# Input (from the user): number from the user
# Output (to the screen): number of sum and average
# Assumptions: The user will enter valid input, i.e. a non-negative number.

# Read the number from the user.
x_float, y_float, z_float = read_number()


# Calculate the average.
sum_float = the_sum (x_float, y_float, z_float)
average_float = average (sum_float)

# Print the number of sum and average.
print_number (average_float)
convert_letter_grade()
# End of main part of the program.

In: Computer Science

Create a class called Height Copy the code for Height given below into the class. Remember...

  • Create a class called Height

  • Copy the code for Height given below into the class.

  • Remember – test the methods as you go

  • Take a few minutes to understand what the class does. There are comments where you will have to be changing code. A list of changes are given

    • Change the setFeet and setInches mutators to make sure the height and width will not be less than 0, no matter what is passed in to it
    • Change constructor that has formal parameters so that it calls the set methods to change the 3 private instance variables
    • Change the method setHeight, so that it calls the set methods to change the feet and inches instance variables
    • Write the method totalInches. This method is described in the comments
    • Write the method totalFeet. This method is described in the comments
  • Test the Height class to make sure the methods you added/changed work correctly.

Code for class Height

public class Height
{
    private String name;
    private int feet;
    private double inches;


    public Height()
    {
        name = "";
        feet = 0;
        inches = 0.0;
    }
    public Height(String name, int feet, double inches)
    {
        // use the sets to create an object with the values passed in

    }
    public void setHeight(int newFeet, double newInches)
    {
        // use the sets to set the feet and inches with the values passed in

    }
    public void setName(String name)
    {
        this.name = name;
    }
    public void setFeet(int newFeet)
    {
        // write the code to set the feet to the formal
        // parameter - since the feet can't be less than 0
        // make the code check and if that might happen, 
        // it should set the feet to 0


    }
    public void setInches(double newInches)
    {
        // write the code to set the inches to the formal
        // parameter - since the inches can't be less than 0
        // make the code check and if that might happen, 
        // it should set the inches to 0

    }   

    public String getName()
    {
        return name;
    }
    public int getFeet()
    {
        return feet;
    }
    public double getInches()
    {
        return inches;
    }


    // write the method totalInches. This method returns the total 
    // number of inches tall the person is. For example, if the
    // person is 5 feet 3.5 inches, this method would return 63.5 since
    // 63.5 inches is the height of the person in inches





    // write the method totalFeet. This method returns the total feet 
    // tall the person is as a decimal. For example, if a person 
    // is 5 feet 6 inches tall, this method would return 5.5, the height
    // of the person in feet


}
  • Once you have the class working
  • Create a class called Main – copy the code below into the class
  • You can run the code as is, before making changes. [If you submit the Main and Height classes at this point, you should get 6 points, if the class is correct.]
  • Do Part A and Part B at the top of main
  • Follow the comments to write the methods in the Main class. (Remember the methods will be public and static) Submit the code after you get each method working for points.
  • NOTICE - there is a Scanner object already declared for you to use (keyboard)
  • Besides the main method you will be writing four methods – make sure you use these exact method names - also follow the directions in the comments, it suggests an order to writing the code
    • printMenu – displays the following menu on the screen – allows the user to enter a selection, and returns the selection. To save on typing – the print statements to print the menu are given below and can be copied directly, so you don’t have to type them. You do have to allow the user to type in their selection and return it.

System.out.println("1. Change Person 1 Data");

System.out.println("2. Change Person 2 Data");

System.out.println("3. Print Person 1 Data");

System.out.println("4. Print Person 2 Data");

System.out.println("5. Compare Heights of Person 1 and 2 with graph");

System.out.println("6. Exit");

System.out.print("Enter Selection: ");

  • changePersonData– This method has a Height object passed in. It allows the user to enter new values for the object passed in. It has two error checking loops to make sure the values are positive. When it executes it looks like this:

Enter the name: Lori

Enter number of feet: -8

Invalid feet - try again!!!

Enter number of feet: -1

Invalid feet - try again!!!

Enter number of feet: 3

Enter number of inches: -4

Invalid inches - try again!!!

Enter number of inches: -5

Invalid inches - try again!!!

Enter number of inches: 2.5

  • printPersonData – Directions in comments in main

  • printLineOfGraph – Directions in comments in main - make sure you uncomment the method calls in the method printTotalInchesGraph

  • Put a loop in main so the menu will keep displaying until the user types choice to quit

  • When you have it running correctly, upload the Height and Main class to zybook and submit it for grading.

Code for class Main

import java.util.Scanner;
public class Main
{
    public static Scanner keyboard = new Scanner(System.in);

    public static void main(String [] args)
    {

        Height person1 = new Height();
        Height person2 = new Height("John", 6, 2);
// Part A        
        // Write the statement to change the name of person1 
        // to be "Lori"

// Part B        
        // Write the statement to change the height of person1 
        // to be 5 foot 6 inches


        int choice = 0;
// Implement each of the methods called from the switch statement below.
// I have put a number in comments, they are only suggestions as
// to the order you might want to implement them

// So for each comment method call, uncomment it and then implement it
// below main. A description is given for each method below main. 

// After you have them implemented put the switch statement into a loop so  
// that the menu will continue to display on the screen until the 
// user chooses option 6

// 1. choice = printMenu();

          switch(choice)
          {
          case 1:
// 4. changePersonData(person1);
              break;
          case 2:
// 4. changePersonData(person2);
              break;
          case 3:
// 2. printPersonData(person1);
              break;
          case 4:
// 2. printPersonData(person2);
              break;
          case 5:
// 3. Do the method printLineOfGraph  which is called from in printTotalInchesGraph - directions are below
       printTotalInchesGraph(person1, person2); 
              break;
          case 6:
             break;
          default:
              System.out.println("Invalid - Try Again!!!");
              break;
         }   

      // This should only display on the screen after the 
      // user has quite the menu
      System.out.println("The End");
    }



    // printMenu 
    // This method prints the menu on the screen. It then
    // asks the user to type in their selection  (as an integer) and 
    // the method returns the selection. You do NOT have
    // to type all of the menu in - see directions in Zybooks
    // to copy and paste











    // changePersonData
    // This method has an object of the Height class passed in
    // It then asks the user to type in a new name and 
    // calls the method to change the name.
    // Then it asks the user to type in the height in feet
    // the method will error check the feet and continue asking 
    // the user to enter the feet until a valid feet is entered.
    // the feet must be zero or larger.
    // It then calls the method to update the feet
    // Lastly, the method asks the user to type in the inches.
    // Similarly to the feet, it will error check and continue
    // asking to type it in until the user types a valid (zero 
    // or greater) inches
    // Finally it calls the method to change the inches
    // See instructions on zbooks, too
    // Points for this method might not show up until you put the loop in main









    // printPersonData 
    // This method has an object of the height class passed in.
    // It uses the object and the methods for the object to print the 
    // objects information in the form:
    /*  
        Height Data
        Name: John
        Height: 6 feet 2.0 inches
        Height in Inches: 74.00 inches
        Height in Feet: 6.17 feet
    */






   // This method calls printLineGragh - make sure you uncomment the two method calls in this method
   // when you implement printLineOfGraph
     public static void printTotalInchesGraph(Height obj1, Height obj2)
    {
        System.out.println("Name: " + obj1.getName());
    //    printLineOfGraph(obj1.totalInches());
        System.out.println("Name: " + obj2.getName());
    //    printLineOfGraph(obj2.totalInches());

    }

    // printLineOfGraph
    // This method has a double passed into it
    // It will print as many asterisks as the value passed in
    // for example:    printLineOfGraph(4.8) will print ****
    // Notice: it does not worry about the decimal, it just 
    // prints the number of asterisks as the whole number
    // after printing the asterisks in a row it prints a new line
    // you can typecast the double formal parameter and 
    // store it in a new variable, and then use that in the loop





} // End of Main class

A sample output is given

1. Change Person 1 Data
2. Change Person 2 Data
3. Print Person 1 Data
4. Print Person 2 Data
5. Compare Heights of Person 1 and 2 with graph
6. Exit
Enter Selection: 4

Height Data
Name: John
Height: 6 feet 2.0 inches
Height in Inches: 74.00 inches
Height in Feet: 6.17 feet

1. Change Person 1 Data
2. Change Person 2 Data
3. Print Person 1 Data
4. Print Person 2 Data
5. Compare Heights of Person 1 and 2 with graph
6. Exit
Enter Selection: 2
Enter the name: Minnie
Enter number of feet: -1
Invalid feet - try again!!!
Enter number of feet: -8
Invalid feet - try again!!!
Enter number of feet: 3
Enter number of inches: 2.8
1. Change Person 1 Data
2. Change Person 2 Data
3. Print Person 1 Data
4. Print Person 2 Data
5. Compare Heights of Person 1 and 2 with graph
6. Exit
Enter Selection: 3

Height Data
Name: Lori
Height: 5 feet 6.0 inches
Height in Inches: 66.00 inches
Height in Feet: 5.50 feet

1. Change Person 1 Data
2. Change Person 2 Data
3. Print Person 1 Data
4. Print Person 2 Data
5. Compare Heights of Person 1 and 2 with graph
6. Exit
Enter Selection: 1
Enter the name: Mickey
Enter number of feet: 4
Enter number of inches: -1
Invalid inches - try again!!!
Enter number of inches: -8
Invalid inches - try again!!!
Enter number of inches: 2.5
1. Change Person 1 Data
2. Change Person 2 Data
3. Print Person 1 Data
4. Print Person 2 Data
5. Compare Heights of Person 1 and 2 with graph
6. Exit
Enter Selection: 3

Height Data
Name: Mickey
Height: 4 feet 2.5 inches
Height in Inches: 50.50 inches
Height in Feet: 4.21 feet

1. Change Person 1 Data
2. Change Person 2 Data
3. Print Person 1 Data
4. Print Person 2 Data
5. Compare Heights of Person 1 and 2 with graph
6. Exit
Enter Selection: 4

Height Data
Name: Minnie
Height: 3 feet 2.8 inches
Height in Inches: 38.80 inches
Height in Feet: 3.23 feet

1. Change Person 1 Data
2. Change Person 2 Data
3. Print Person 1 Data
4. Print Person 2 Data
5. Compare Heights of Person 1 and 2 with graph
6. Exit
Enter Selection: 5

Name: Mickey
**************************************************
Name: Minnie
**************************************

1. Change Person 1 Data
2. Change Person 2 Data
3. Print Person 1 Data
4. Print Person 2 Data
5. Compare Heights of Person 1 and 2 with graph
6. Exit
Enter Selection: 6
The End

In: Computer Science

We are sending a MP3 file of 300,000 bits from Host A to Host B. Host...

We are sending a MP3 file of 300,000 bits from Host A to Host B. Host A and B are each connected to a switch S via 100 Mbps links. Assume that each link introduces a propagation delay of 10 µs (microsecond). Calculate the total transfer time of the entire file (from first bit sent to last bit received) for the following:

  1. Suppose the MP3 file is sent as one message. S is a store-and-forward device; it begins retransmitting immediately after it has finished receiving the packet.
  2. Suppose that the MP3 file is broken into 6 packets, each of 50,000 bits. S is a store-and-forward device; it begins retransmitting immediately after it has finished receiving the packet.
  3. Suppose that the MP3 file is broken into 6 packets, each of 50,000 bits. S implements ‘cut-through” switching: It is able to begin retransmitting the packet after the first 500 bits have been received.

In: Computer Science

IEEE 754 format of 32-bit floating-point is as follows. 1 8 (bits) 23 (bits) What’s stored...

IEEE 754 format of 32-bit floating-point is as follows.

1

8 (bits)

23 (bits)

  1. What’s stored in each region?
  2. What’s the bias value and how to get it?
  3. For decimal fraction: – 0.625, please represent it as given format (Note: you must show the specific procedure/stepsin order to get full credits. If you only present final result directly, you will only get half of the credits even if it is correct.).  

In: Computer Science

php please // 2) mirrorEnds // Complete method mirrorEnds that given a string, looks for a...

php please

// 2) mirrorEnds

// Complete method mirrorEnds that given a string, looks for a mirror

// image (backwards) string at both the beginning and end of the given string.

// In other words, zero or more characters at the very beginning of the given

// string, and at the very end of the string in reverse order (possibly overlapping).

// For example, "abXYZba" has the mirror end "ab".

//

// assert("" == mirrorEnds(""));

// assert("" == mirrorEnds("abcde"));

// assert("a" == mirrorEnds("abca"));

// assert("aba" == mirrorEnds("aba"));

//

function mirrorEnds($str) {

}

echo PHP_EOL . "mirrorEnds(abcdefcba) abc: " . mirrorEnds ( 'abcdefcba' ) . "\n";

assert ( 'abc' == mirrorEnds ( 'abcdefcba' ) );

echo " mirrorEnds(zzRSTzz) zz: " . mirrorEnds ( 'zzRSTzz' ) . "\n";

In: Computer Science

php please // 5) isArraySorted // Given an array , return true if the element are...

php please

// 5) isArraySorted

// Given an array , return true if the element are in ascending order.

// Note: 'abe' < 'ben' and 5 > 3

// Precondition $arr has all the same type of elements

function isArraySorted($arr) {

  

}

echo PHP_EOL . 'isArraySorted(array(1, 2, 2, 99) 1: ' . isArraySorted ( array (

1,

2,

2,

99 ) ) . "\n";

assert ( isArraySorted ( array (

1,

2,

2,

99 ) ) );

echo 'isArraySorted(array(2, 2, 1) false: ' . isArraySorted ( array (

2,

2,

1 ) ) . "\n";

In: Computer Science