Questions
Please, write code in c++. Using iostream and cstring library Use pointers! You given a text.Your...

Please, write code in c++. Using iostream and cstring library

Use pointers!

You given a text.Your task is to write a function that will find the longest sequence of digits inside.
Note that the output have to be presened just like in sample.

Note. The program have to use pointer.

Input:
First line contains one line that is not longer than 1000.

Output:
The longest sequence of numbers.All numbers are positive and integers.

Samples:

INPUT OUTPUT
1 This is the longest - 10001 number 10 001
2 101 fdvnjfkv njfkvn fjkvn jffdvfdvfd2010 2 010
2 1a11 11

In: Computer Science

IP address: 158.234.28.72 Subnet Mask: 255.248.0.0 Find Network Address and Broadcast address. Provide all necessary steps.

IP address:  158.234.28.72
Subnet Mask: 255.248.0.0

Find Network Address and Broadcast address. Provide all necessary steps.

In: Computer Science

Write a C program that runs on ocelot for a mini calculator using only the command...

Write a C program that runs on ocelot for a mini calculator using only the command line options. You must use getopt to parse the command line.
Usage: minicalc [-a num] [-d num] [-m num] [-s num] [-e] value
• The variable value is the starting value.
• Value should be validated to be an integer between 1 and 99. Error message and usage shown if not.
• -a adds num to value.
• -d divides value by num.
• -m multiplies value by num.
• -s subtracts num from value.
• -e squares value. (Note: no num is needed.)
• Output should have exactly 2 decimal places no matter what the starting values are.
• If –e is included, it is executed first.
• Use standard order of operations for all operations.
Code should be nicely indented and commented. Create a simple Makefile to compile your program into an executable called minicalc.The Makefile should be called Makefile with no extension. I should be able to type make at the command line to compile your program.

In: Computer Science

Working with Files in C++. Create the following  program called payroll.cpp.  Note that the file you...

Working with Files in C++.

Create the following  program called payroll.cpp.  Note that the file you read must be created before you run this program.  The output file will be created automatically by the program.  You can save the input file in the same directory as your payroll.cpp file by using Add New Item, Text File.  

// File:  Payroll.cpp

// Purpose:  Read data from a file and write out a payroll

// Programmer:  (your name and section)

#include <cstdlib> // for the definition of EXIT_FAILURE

#include <fstream> // required for external file streams

#include <iostream> // required for cin cout

using namespace std;

int main ()

{

ifstream ins; // associates ins as an input stream

 ofstream outs; // associates outs as an output stream

 int id; // id for employee

 double hours, rate; // hours and rate worked

 double pay; // pay calculated

 double total_pay; // grand total of pay

 // Open input and output file, exit on any error

 ins.open ("em_in.txt"); // ins connects to file "em_in.txt"

 if (ins.fail ())

 {

   cout << "*** ERROR: Cannot open input file. " << endl;

   getchar(); //  hold the screen

   return EXIT_FAILURE;

 } // end if

 outs.open ("em_out.txt"); // outs connects to file "em_out.txt"

 if (outs.fail ())

 {

   cout << "*** ERROR: Cannot open output file." << endl;

   getchar();

   return EXIT_FAILURE;

 } // end if

// Set total_pay to 0

total_pay = 0;

ins >> id; // get first id from file

// Do the payroll while the id number is not the sentinel value

while (id != 0)

 {

   ins >> hours >> rate;

   pay = hours * rate;

   total_pay += pay;

   outs << "For  employee " << id << endl;

   outs << "The pay is " << pay << " for " << hours

<< " hours worked at " << rate << " rate of pay" << endl << endl;

   ins >> id;

 } // end while

 // Display a message on the screen

   cout << "Employee processing finished" << endl;

   cout << "Grand total paid out is " << total_pay << endl;

   ins.close(); // close input file stream

   outs.close(); // close output file stream

   return 0;

 }

Create the input file:

Inside C++ go to  File Add New Item and then Text to create a text file.  

Type in the data below

In the same directory as your .cpp file for Payroll.cpp click Files and Save As em_in.txt

1234

35  10.5

3456

40 20.5

0



solution should show :

-the output file  

-the input file

-the screen output

-the source program

In: Computer Science

For this problem, complete the function stub to simulate the following random variable: Suppose we have...

For this problem, complete the function stub to simulate the following random variable: Suppose we have a (possibly) unfair coin where the probability of Head is ? and we flip this coin ? times. Let X = "the number of heads showing."

Demonstrate your solution by generating 105 random variates for the parameters shown and displaying them using show_distribution(...).

STARTER CODE:

# First, create a function which simulates the coin, where
# you return 1 with probability p and 0 with probability 1-p.

N = 10
p = 0.25

num_trials = 10**5

def coinFlip(p):
return 0 # Just to get it to compile
  
def coinFlips(N,p):
return 0 # Just to get it to compile

print("Demonstration:")

seed(0)

In: Computer Science

-----xxxxx-------Could you please use java language. thank you. :::::: XXXX::::::::::: Implement a recursive reverse sorting algorithm....

-----xxxxx-------Could you please use java language. thank you. :::::: XXXX:::::::::::

Implement a recursive reverse sorting algorithm. The following requirements should meet:

a The program shall graphically prompt the user for a file.

bThe program shall read the selected file which will contain 1 integer per line.

c. The program shall sort the values it reads from the file from largest to smallest.

d.The program shall write the values to an output file from largest to smallest in the same directory as the input file.

eThe program shall write 1 integer per line in the output file.

f.The program shall use a recursive algorithm to sort the values

​This assignment should be based on:

i) Functionality - Does the program meet the requirements?

ii) Style - Do you have comments and well-written code?

iii) Design - Were good design principles used in the construction of the program?

iv) Additional Elements - Error handling, unit tests, input checking, etc.

In: Computer Science

Requirements:   You are to write a class called Point – this will represent a geometric point...

Requirements:   You are to write a class called Point – this will represent a geometric point in a Cartesian plane (but x and y should be ints).   Point should have the following:

Data:  

  • that hold the x-value and the y-value. They should be ints and must be private.

Constructors:

  • A default constructor that will set the values to (2,-7)

  • A parameterized constructor that will receive 2 ints (x then y) and set the data to what is received.
  • A copy constructor that will receive a Point. If it receives null, then it should

throw new IllegalArgumentException(<”your meaningful String here”>);

If it is OK, the it should initialize the data (of the new instance being created) to be the same as the Point that was received.

Methods:

  • The methods to be implemented are shown in the PointInterface.java. You can look at this file to see the requirements for the methods.

  • Your Point class should be defined like this:

public class Point implements PointInterface

When your Point.java compiles, Java will expect all methods in the interface to be implemented and will give a compiler error if they are missing. The compiler error will read “class Point is not abstract and does not implement method ”.

You can actually copy the PointInterface methods definitions into your Point class so it will have the comments and the method headers.   If you do this, be sure to take out the ; in the method headers or you will get a “missing method body” syntax error when compiling…

  • But a toString() method and a .equals(Object obj) method are automatically inherited from the Object class. So if you do not implement them, Java will find and use the inherited ones – and will not give a compiler error (but the inherited ones will give the wrong results). The Point class should have its own .toString and .equals methods.
  • ==============================================================================
  • This is the interface (called PointInterface.Java) for a Point class (which will represent a 2-dimensional Point)
  • public interface PointInterface

    {

    // toString

    // returns a String representing this instance in the form (x,y)

    (WITHOUT a space after the ,)

    public String toString();

    // distanceTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns the distance from this Point to the Point that was

    received

    // NOTE: there is a static method in the Math class called hypot

    can be useful for this method

    public double distanceTo(Point otherPoint);

    //equals - returns true if it is equal to what is received (as an Object)

    public boolean equals(Object obj);

    // inQuadrant

    // returns true if this Point is in the quadrant specified

    // throws a new IllegalArgumentException if the quadrant is

    out of range (not 1-4)

    public boolean inQuadrant(int quadrant);

    // translate

    // changes this Point's x and y value by the what is received (thus

    "translating" it)

    // returns nothing

    public void translate(int xMove, int yMove);

    // onXAxis

    // returns true if this Point is on the x-axis

    public boolean onXAxis();

    // onYAxis

    // returns true if this Point is to the on the y-axis

    public boolean onYAxis();

    //=============================================

    // The method definitions below are commented out and

    // do NOT have to be implemented

    // //===========================================

    // halfwayTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns a new Point which is halfway to the Point that is

    received

    //public Point halfwayTo(Point another);

    // slopeTo

    // throws a new IllegalArgumentException(

    if null is received

    // returns the slope between this Point and the one that is

    received.

    // since the slope is (changeInY/changeInX), then first check to see if

    changeInX is 0

    // if so, then return Double.POSITIVE_INFINITY; (since the

    denominator is 0)

    //public double slopeTo(Point anotherPoint)

    }

In: Computer Science

Q1: Constraint: Use concept of dynamic allocation for implementation Statement: In a class there are N...

Q1: Constraint:
Use concept of dynamic allocation for implementation


Statement:
In a class there are N students. All of them have appeared for the test. The teacher evaluated
the test and noted marks according to their roll numbers. Marks of each students has to be incremented
by 5. Print list of marks of students before and after increment.

In: Computer Science

Design a finite state machine that accepts binary strings divisible by 5. Input is fed to...

Design a finite state machine that accepts binary strings divisible by 5. Input is fed to the FSM one bit at a time, from the most significant bit to the least significant bit (left to right). For example, 1010 should be accepted, but 1100 should be rejected. Clearly explain how you designed your state transitions. Showing the FSM alone is worth minimal credit!

In: Computer Science

Imagine that you are Chris Configurator, a network administrator for the ABC Company. Your organization is...

Imagine that you are Chris Configurator, a network administrator for the ABC Company. Your organization is expecting a fiscal year of limited financial resources. You have been asked by the Director of Network Operations to develop a set of recommendations as to how virtualization and network optimization methods could be used as a way to meet the growing demands for use of network services while also controlling the cost of expansion of network infrastructure. Discuss the elements of your plan to use virtualization and network optimization techniques as well as remote monitoring to meet the needs of your organization.

In: Computer Science

why is the the OSI Layer important to IT specialist ?

why is the the OSI Layer important to IT specialist ?

In: Computer Science

Implement function (in C programming) that calculates and returns the total size of items in a...

Implement function (in C programming) that calculates and returns the total size of items in a directory given by name.

  • Only consider immediate contents (no need to recursively check subdirectories).
  • Assume that appropriate header files are included (no need to specify them using #include).


int dir_size(const char *name);

In: Computer Science

Basic arithmetic calculation. Use instruction “li” to initialize register $t1 with a constant value 10. li...

  1. Basic arithmetic calculation.
    1. Use instruction “li” to initialize register $t1 with a constant value 10.

li $t1, 10   # [$t1] <- 10

finish the following calculation using MIPS assembly code.

$t2 = $t1 + $t1

$t3 = $t1 << 2 (shift to left by 2 bits)

$t4 = $t1 & 0x0000ffff (bitwise AND)

$t5 = $t1 | 0x0000fffff (bitwise OR)

$t6 = $t2 + $t3 + $t4 + $t5

Write MIPS assembly code to finish the above calculation and print out the result, value of $t6.

In: Computer Science

BankAccount: You will create 3 files: The .h (specification file), .cpp (implementation file) and main file....

BankAccount:
You will create 3 files: The .h (specification file), .cpp (implementation file) and main file. You will practice writing class constants, using data files. You will add methods public and private to your BankAccount class, as well as helper methods in your main class. You will create an array of objects and practice passing objects to and return objects from functions. String functions practice has also been included.

  1. Extend the BankAccount class. The member fields of the class are: Account Name, Account Id, Account Number and Account Balance. The field Account Id (is like a private social security number of type int) Convert the variables MIN_BALANCE=9.99, REWARDS_AMOUNT=1000.00, REWARDS_RATE=0.04 to static class constants Here is the UML for the class:

                                                        BankAccount

-string accountName // First and Last name of Account holder

-int accountId // secret social security number

-int accountNumber // integer

-double accountBalance // current balance amount

+ BankAccount()                     //default constructor that sets name to “”, account number to 0 and balance to 0

+BankAccount(string accountName,int id, int accountNumber, double accountBalance)   // regular constructor

+getAccountBalance(): double // returns the balance

+getAccountName: string // returns name

+getAccountNumber: int

+setAccountBalance(double amount) : void

+equals(BankAccount other) : BankAccount // returns BankAccount object **

-getId():int **

+withdraw(double amount) : bool //deducts from balance and returns true if resulting balance is less than minimum balance

+deposit(double amount): void //adds amount to balance. If amount is greater than rewards amount, calls

// addReward method

-addReward(double amount) void // adds rewards rate * amount to balance

+toString(): String   // return the account information as a string with three lines. “Account Name: “ name

                                                                                                                                                   “Account Number:” number

                                                                                                                                                    “Account Balance:” balance

  1. Create a file called BankAccount.cpp which implements the BankAccount class as given in the UML diagram above. The class will have member variables( attributes/data) and instance methods(behaviours/functions that initialize, access and process data)
  2. Create a driver class to do the following:
    1. Read data from the given file BankData.data and create and array of BankAccount Objects

The order in the file is first name, last name, id, account number, balance. Note that account name consists of both first and last name

  1. Print the array (without secret id) similar to Homeowork2 EXCEPT the account balance must show only 2 decimal digits. You will need to do some string processing.
  2. Find the account with largest balance and print it
  3. Find the account with the smallest balance and print it.
  4. Determine if there are duplicate accounts in the array. If there are then set the duplicate account name to XXXX XXXX and rest of the fields to 0. Note it’s hard to “delete” elements from an array. Or add new accounts if there is no room in the array. If duplicate(s) are found, print the array.


    BankData.dat
    Matilda Patel 453456 1232 -4.00
    Fernando Diaz 323468 1234 250.0
    Vai vu 432657 1240 987.56
    Howard Chen 234129 1236 194.56
    Vai vu 432657 1240 -888987.56
    Sugata Misra 987654 1238 10004.8
    Fernando Diaz 323468 1234 8474.0
    Lily Zhaou 786534 1242 001.98

In: Computer Science

MATLAB Write a code that takes the initial velocity and angle as an input and outputs...

MATLAB

Write a code that takes the initial velocity and angle as an input and outputs the maximum height of the projectile and its air time.

Follow the pseudo code below. This will not be provided in as much detail in the future so you’ll have to provide pseudocode or a flowchart to showcase your logic. For this first assignment though, the logic is laid out below with some indented more detailed instructions.

PROGRAM Trajectory:
Establish the User Interface (Typically referred to as the UI);

INPUT INPUT

Solve
Solve
Print

Start with an explanation of activity

Ask the user for the initial velocity;

Ask the user for the initial angle;

Include descriptive requests for inputs so the user knows what information is required.

for the maximum height the ball reaches;

for the length of time the ball is in the air;

the answers for the user;

Include a description with that return so the user understands what the data is

Plot height versus time; Plot height versus distance;

Do not overwrite your previous figure! This is a new plot but you still want the old one.

Make it clear what the plots are. Label the plot axes with units, include a title, and use a marker for the plot points.

END

In: Computer Science