Questions
Take the code below, add the parameter validation as prompted by the highlighted comments. #include <iostream>...

Take the code below, add the parameter validation as prompted by the highlighted comments.

#include <iostream>
using namespace std;

// Prototype (Wait, what's this? Hmmm... how would you find out? )
void calculateBill(double, int);

int main()
{
// local variables
int numMonths = 10;
double rate = 25.99;

// Perform a test for $25.99 membership.
cout << "Calling the calculateBill function with arguments "
??? << rate << " and " << numMonths << "\n";
total = calculateBill(rate, numMonths);
cout << "Bill is " << calculateBill << "\n";

// Perform a test for 70.50 membership.
numMonths = 5;
rate = 70.50;
cout << "Calling the calculateBill function with arguments "
??? << rate << " and " << numMonths << "\n";
total = calculateBill(rate, numMonths);
cout << "Bill is " << calculateBill << "\n";

// Perform a test for $-5 membership.
numMonths = 5;
rate = -5;
cout << "Calling the calculateBill function with arguments "
??? << rate << " and " << numMonths << "\n";
total = calculateBill(rate, numMonths);
cout << "Bill is " << calculateBill << "\n";

//// What should you add to your function now?

// Perform a test for -10 months. Keep -5 to make sure you added that input validation
numMonths = -10;
rate = -5;
cout << "Calling the calculateBill function with arguments "
??? << rate << " and " << numMonths << "\n";
total = calculateBill(rate, numMonths);
cout << "Bill is " << calculateBill << "\n";

//// What should you add to your function now?

return 0;
}

//*****************************************************************
// Definition of function calculateBilll. The memberRate parameter holds *
// the monthly membership rate and the months parameter holds the *
// number of months. The function displays the total charges. *
//*****************************************************************
double calculateBill(double memberRate, int months)
{
return (memberRate * months);
}

In: Computer Science

C++ program Overloaded Hospital Write a c++ program that computes and displays the charges for a...

C++ program

Overloaded Hospital

Write a c++ program that computes and displays the charges for a patient’s hospital stay. First, the program should ask if the patient was admitted as an inpatient or an outpatient. If the patient was an inpatient, the following data should be entered:

  • The number of days spent in the hospital
  • The daily rate
  • Hospital medication charges
  • Charges for hospital services (lab tests, etc.)


The program should ask for the following data if the patient was an outpatient:

  • Charges for hospital services (lab tests, etc.)
  • Hospital medication charges


The program should use two overloaded functions to calculate the total charges. One of the functions should accept arguments for the inpatient data, while the other function accepts arguments for outpatient information. Both functions should return the total charges.

Input Validation: Do not accept negative numbers for any data.

In: Computer Science

Write a computer program using C++ that computes the value of a Lagrange Polynomial and accepts,...

Write a computer program using C++ that computes the value of a Lagrange Polynomial and accepts, as input: (n+1) data points (x0, f(x0)), (x1, f(x1)),...(xn, f(xn)).. at value x, which the polynomial is to evaluated. As output, the program should produce a statement that reads, "f(x) = (the value of f(x))". As a test, use the data values (1,2);(-1,1);(0,0);(2,4);(-2,3)

In: Computer Science

Make an abstrakt about the topic " 6lowpan on network "، and should not be copy...

Make an abstrakt about the topic " 6lowpan on network "، and should not be copy pasted from Google.

In: Computer Science

Write a Java program (name it PasswordTest) that reads from the user a string input (representing...

Write a Java program (name it PasswordTest) that reads from the user a string input (representing a password) and determines whether the password is “Valid Password” or “Invalid Password”. A valid password has at least 7 characters and includes at least one lower-case letter, at least one upper-case letter, at least one digit, and at least one character that is neither a letter nor a digit. Your program will need to check each character in the string in order to render a verdict. For example, CS5000/01 is invalid password; however, Cs5000/01 is a valid password. The program should display the entered password and the judgment as shown in the following sample runs:

Entered Password: CS5000/01

Verdict: Invalid Password

Entered Password: Cs5000/011

Verdict: Valid Password

Entered Password: MyOldDogK9

Verdict: Invalid Password

Entered Password: MyOldDogK9#

Verdict: Valid Password

Entered Password: Ab1#

Verdict: Invalid Password

Document your code, and organize and space out your outputs as shown. Design your program such that it allows the user to re-run the program with different inputs in the same run (i.e., use a sentinel loop structure).

In: Computer Science

You will learn how to write a post-incident executive summary report detailing an incident event and...

  • You will learn how to write a post-incident executive summary report detailing an incident event and corrective actions taken.

Assignment Requirements

You have been working as a technology associate in the information systems department at Corporation Techs for almost three months now. Yesterday, you got an e-mail, which specified that a security breach has occurred in your company. The other members of your team also received such e-mails. You checked the firewall logs and it confirmed the security breach.

Later, your team took corrective actions in the environment. They isolated the incident and assessed the damage. Today, your manager calls you and asks you to create an executive summary report detailing the events to be presented to executive management. You need to include a summary of corrective options, which may be in the form of architectural adjustments or other configuration changes that will prevent the reoccurrence of this incident in the future.

Tasks

You need to create a post-incident executive summary report that addresses a security breach. Include an overview of actions taken at each phase of the incident response. Also include suggestions for corrective modifications that would prevent the incident from reoccurring.

In: Computer Science

using python 3 2. Write a python program that finds the numbers that are divisible by...

using python 3

2. Write a python program that finds the numbers that are divisible by both 2 and 7 but not 70, or that are divisible by 57 between 1 and 1000.

3. Write a function called YesNo that receives as input each of the numbers between 1 and 1000 and returns True if the number is divisible by both 2 and 7 but not 70, or it is divisible by 57. Otherwise it returns False.

4. In your main Python program write a for loop that counts from 1 to 1000 and calls this YesNo function inside the for loop and will print "The number xx is divisible by both 2 and 7 but not 70, or that are divisible by 57" if the YesNo function returns True. Otherwise it prints nothing. Note the print statement also prints the number where the xx is above.

In: Computer Science

Simple shell scripting Write a Bash shell script called strcount.sh that counts the number of occurances...

Simple shell scripting

Write a Bash shell script called strcount.sh that counts the number of occurances of a given string within a file. The scripts takes two arguments: the name of the file to check and the string to count occurances of. If the file is not found (or not readable), the script should print the error message Cannot access file and exit with code -1. Otherwise, the script should print the number of occurances of the given string and exit with code 0. If the user fails to specify two arguments, the script should print the error message Usage: strcount.sh <file> <string> and exit with code -1.

Thus, if I have the following file penguins.txt:

  Galapagos penguin
  Erect-crested penguin
  Subantarctic gentoo penguin
  Royal penguin
  Humboldt penguin
  Eastern rockhopper penguin
  Fiordland penguin
  Allied king penguin
  Ellsworth's gentoo penguin
  White-flippered penguin
  Cook Strait little penguin
  Chatham Island little penguin

Then the output should be the following:

  ekrell@ekrell-desktop:~$ ./strcount.sh penguins.txt little
  2

Or if the file does not exist:

  ekrell@ekrell-desktop:~$ ./strcount.sh badfile.txt little
  Cannot access file

Or if the user fails to specify two arguments:

  ekrell@ekrell-desktop:~$ ./strcount.sh 
  Usage: strcount.sh <file> <string>

Write your script here

  <- ... ->
  <- ... ->
  <- ... ->
  <- Add as many lines as you need ->

Credit

Material adopted from http://faculty.smu.edu/hdeshon/

In: Computer Science

There will be three grades for each student in "grades.txt" (see example file bellow). In "student.txt"...

There will be three grades for each student in "grades.txt" (see example file bellow). In "student.txt" there are two students first and last names. In "grades.txt" the grades for each student will be on the same line number as the students name was on in "students.txt".

So if line 1 of "students.txt" contains:

Joe Blow

then line 1 of "grades.txt" would contain Joe Blow's grades:

85 54.3 56

Into an output file called "report.txt" output the student's last name then a comma the their first name. Following this, calculate their average and assign a letter grade using the following scale:

'A': grade >= 90

'B': 90 > grade >= 80

'C': 80 > grade >= 70

'D': 70 > grade >= 60

'F': grade < 60

If the final grade of a student is greater than 100 instead of printing their letter grade output the statement "Teacher was far too easy". The "report.txt" should have a heading on each of the columns the first saying "Student's Name" and the second saying "Student's Grade".

In: Computer Science

Please write a JAVA program which reads a number n from the user and check whether...

Please write a JAVA program which reads a number n from the user and check whether n is a perfect number or not. For example, when n = 7, the print out should be 7 is not a perfect number. If the input n is 6, then the program prints out 6 = 1 * 2 * 3

In: Computer Science

Show what is written by the following segment of code, given item1, item2, and item3 are...

Show what is written by the following segment of code, given item1, item2, and item3 are int variable:

item1 = 4;

item3= 0;

item2 = item1 + 1;

stack.Push(item2);

stack.Push(item2 +1);

stack.Push(item1);

item2 = stack.Top();

stack.Pop();

item1 = item2 + 1;

stack.Push(item1);

Stack.Push(item3);

while (!stack.IsEmpty())

{

     item3 = stack.Top():

     cout <<item3<<endl;

     stack.Pop();

}

cout<<item1 <<endl <<item2<<endl<<item3<<endl;

In: Computer Science

The Monty Hall problem solved on Matlab. Please show code. You are given a choice between...

The Monty Hall problem solved on Matlab. Please show code. You are given a choice between three doors. Behind one door is a new car and behind the other two doors is a goat. You first pick one of the doors at random. Then, a door with a goat is opened for you. You are then given the option to switch your door to the other unopened door. Should you do this? What are your odds of winning if you switch vs not switching? Show using matlab with a large number of runs, where you keep your selection 50% of the time and switch 50% of the time.

In: Computer Science

Given a generic array with ‘n’ items (not only integers). Give a solution for checking whether...

Given a generic array with ‘n’ items (not only integers). Give a solution for checking whether there are any duplicate elements in the array or not? You just need to return a boolean (true or false). State the complexity of your solution. Can you come up with another solution that has O(n logn) complexity? Explain.

In: Computer Science

Write a program to simulate an experiment flipping three coins. Each time the three coins are...

Write a program to simulate an experiment flipping three coins. Each time the three coins are flipped, is called a “trial”. A coin flip can randomly result in either “Heads” (1) or “Tails” (0) Allow the user to enter the number of “trial”s to simulate. Print out each coins’ result after each “trial”. Use seed value 1234. Tally up and determine what percentage of “trial”’s all three coins land on “Heads” in the simulation. C language

In: Computer Science

In MATLAB write a function secant.m to apply the secant method. function [x,i] = secant(f, x0,...

In MATLAB write a function secant.m to apply the secant method.

function [x,i] = secant(f, x0, x1, tol, maxiters)

[x,i] = secant(f, x0, x1, tol, maxiters) performs the secant method with f(x), starting at x_0 = x0 and x_1 = x1, and continuing until either |x_i+1 - x_i| <= tol, or maxiters iterations have been taken. The number of iterations, i, is also returned. An error is raised if the first input is not a function handle. A warning is raised if the maximum number of iterations is reached without achieving the tolerance.

Test the function on the problem f(x) = 0.9 cos(x) - sqrt(x) = 0, with starting values x0 = 0 and x1 - 1, and a tolerance of 10^-8 and maxiters of 20.

In: Computer Science