Questions
Calculator Class Instructions Create a calculator class that will add, subtract, multiply, and divide two numbers....

Calculator Class Instructions

Create a calculator class that will add, subtract, multiply, and divide two numbers. It will have a method that will accept three arguments consisting of a string and two numbers example ("+", 4, 5) where the string is the operator and the numbers are what will be used in the calculation.

The class must check for a correct operator (+,*,-,/), and a number (integer) for the second and third argument entered. The calculator cannot divide by zero that will be an error.

Separate error messages will be displayed for all errors. Also, separate success messages will be displayed with each successful answer. This script will run using a browser. The output of the script will display after the web address is entered into the browser navigation window. There will be a separate file that will require the class. That file will be used to instantiate the class and call the appropriate method, while the class will do the heavy lifting.

You will have two files
One will be the file that is your class.
The other will be a file that requires your class and call the appropriate method. This is the file you will provide the web address for.

For example:

If you have a file with a class named $Calculator. You will have another class that uses the calculator class and displays the information. That file will have the code shown below.

NOTE: You are to use the code shown below as your test code.

NOTE: For this assignment you can write the following code within a PHP block within the HTML body element. You do not need to write the comments I did that to show you what needs to be outputted depending on what is sent as arguments.

<?php
require_once "Calculator.php";
$Calculator = new Calculator();
echo $Calculator->calc("/", 10, 0); //will output Cannot divide by zero
echo $Calculator->calc("*", 10, 2); //will output The product of the numbers is 20
echo $Calculator->calc("/", 10, 2); //will output The division of the numbers is 5
echo $Calculator->calc("-", 10, 2); //will output The difference of the numbers is 8 echo $Calculator->calc("+", 10, 2); //will output The sum of the numbers is 12
echo $Calculator->calc("*", 10); //will output You must enter a string and two numbers echo $Calculator->calc(10); //will output You must enter a string and two numbers
?>

The browser will output (based upon the above methods):

Cannot divide by zero
The product of the numbers is 20
The division of the numbers is 5
The difference of the numbers is 8
The sum of the numbers is 12
You must enter a string and two numbers You must enter a string and two numbers

in PHP/HTML

In: Computer Science

How would you call a username in a different function when coding in C? I have...

How would you call a username in a different function when coding in C?

I have a function that logs a user in, and I would like to say if (username == 'abc'){do function} but everytime I use the 'username' variable in a different function, it says it is an undeclared identifier.

In: Computer Science

User Python to solve; show all code: A user will enter in data for a basketball...

User Python to solve; show all code:

  1. A user will enter in data for a basketball team. For each player on the team the user will enter
    1. The player’s last name
    2. The average number of point the player scored last season
    3. The number of games the player is projected to play in this year

Write a program that will prompt the user for the player data described above. The user does not know how many players are on the team so allow the user to enter the word end when he/she has finished entering data.

Validate that the player is not entered more than once.

After entering the data, compute the following:

  1. The projected number of points the team will score this year. Assume the player will score the same number of points per game as they did last season.
  2. The name of the player who is projected to score the most points this year. Also display the projected number of points.

In: Computer Science

Java Special Methods: A) Write a method that finds the maximum of two numbers. You should...

Java Special Methods:

A) Write a method that finds the maximum of two numbers. You should not use if-else or any other comparison operator.

B) Write methods to implement the multiply, subtract and divide operations for integers. The results of all of these are integers. Use only the add operator.

In: Computer Science

Given the strings s1 and s2 that are of the same length, create a new string...

Given the strings s1 and s2 that are of the same length, create a new string s3 consisting of the last character of s1 followed by the last character of s2, followed by the second to last character of s1, followed by the second to last character of s2, and so on

In: Computer Science

2. Convert the following decimal fractions to binary with a maximum of six places to the...

2. Convert the following decimal fractions to binary with a maximum of six places to the right of the binary point: [12]

a. 25.84375 b. 57.55 c. 80.90625 d. 84.874023

In: Computer Science

In Java In mathematics, factorial of a non-negative integer n, denoted by n! , is the...

In Java

In mathematics, factorial of a non-negative integer n, denoted by n! , is the product of all positive integers less than or equal to n. For example,

5! = 5 * 4 * 3 * 2* 1 = 120

3! = 3 * 2 * 1 = 6

2! = 2 * 1 = 2

The value of 0! is 1.

Write a program that asks user to enter an integer > 0; if a valid value is entered, it should calculate and display factorial of the number entered. If the user enters an integer <=0, display a message "Invalid entry - valid entry is an integer > 0" and have them re-enter the information.

In: Computer Science

Use Python to solve, show all code Write a program that sums a sequence of integers...

Use Python to solve, show all code

Write a program that sums a sequence of integers from a starting integer to and ending integer. The sequence is generated by skipping a value (e.g. 1,3,5,… or 2,6,10,14…). Prompt the user for a) a starting value greater than 0. Validate the value is greater than 0.

b) the ending value.

c) the value to skip

Print out the sum of the numbers for the sequence. If the starting value is 2, the ending value is 10 and the value to skip is 2, the sequence would be 2,4,6,8,10

Sample Interaction:

Enter the starting value: -1

Error – invalid number

Enter the starting value: 2

Enter the ending value: 10

Enter the value to skip: 2

The sum of the integers from 2 to 10 skipping 2 is 30

In: Computer Science

For this Discussion, you will analyze mobile security threats and evaluate countermeasures. Briefly describe your mobile...

For this Discussion, you will analyze mobile security threats and evaluate countermeasures.

Briefly describe your mobile device and another device currently on the market that uses a different OS. Explain the security vulnerabilities associated with each device. Explain the security solutions that would address the vulnerabilities. Finally, state which OS has more robust security and explain your reasoning.

In: Computer Science

Create a webpage with Margins, Padding, Alignment, and Floating: Begin with a basic web page using...

Create a webpage with Margins, Padding, Alignment, and Floating:

  1. Begin with a basic web page using the 5 required html tags.
  2. Add 4 or 5 paragraphs of text from a page in this chapter.
  3. Format the text to appear as on the page using < p>, < h1>, < ol> and < li> tags.
  4. Enclose the content with a < div> tag.
  5. With an internal stylesheet, set the body element to have no margins and a gray background.
  6. Style the div element with a width of 400 pixels, no top and bottom margins, automatic left and right margins, 10 pixels of padding all around, a 1 pixel black border and a white background.
  7. You finish page should look like this: (https://s3.amazonaws.com/blackboard.learn.xythos.prod/58771c61a39f4/3132468?response-cache-control=private%2C%20max-age%3D21600&response-content-disposition=inline%3B%20filename%2A%3DUTF-8%27%27Screen%2520Shot%25202020-10-08%2520at%25205.09.17%2520PM.png&response-content-type=image%2Fpng&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20201009T150000Z&X-Amz-SignedHeaders=host&X-Amz-Expires=21600&X-Amz-Credential=AKIAYDKQORRYTKBSBE4S%2F20201009%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Signature=663f55cb392c78ef4fc1c5827d8925574c7fe821c186ba18165606c3f2e43814) but choose something else!

In: Computer Science

Using the module discussion forum, work with your fellow students to identify any other database benefits...

Using the module discussion forum, work with your fellow students to identify any other database benefits you can think of, as say compared to a spreadsheet or basic file storage.

In: Computer Science

MACs Question 3: 3a.) Why should a MAC be configurable? 3b.) What are the effects of...

MACs

Question 3:

3a.) Why should a MAC be configurable?
3b.) What are the effects of RF radio realities on the MAC layer?

In: Computer Science

In Java A palindrome is a word or sequence of characters which reads the same backward...

In Java

A palindrome is a word or sequence of characters which reads the same backward and forward, such as madam, dad, racecar, 5885. In java Write a program that asks user to enter a word and prints if the word is a palindrome or not.

In: Computer Science

in Python, Define the class called Line which represents a line with equation ?=??+? with input...

in Python,

Define the class called Line which represents a line with equation ?=??+? with input slope ? and intercept ? to initialize the instances. It should include:

attributes named ? and ? to represent slope and intercept.
method named intersect to return the list, containing coordinates of the intersection point of two lines.
support for + operator to compute the addition of two equations. The sum of two Line objects ?=?1?+?1 and ?=?2?+?2 is defined as the line ?=(?1+?2)?+?1+?2 .
printable representation for the equation of line, which we have already defined in __repr__ speical method below.

In: Computer Science

Wireless Sensor Networks/Internet of Things What should be the major components of an energy consumption model...

Wireless Sensor Networks/Internet of Things

What should be the major components of an energy consumption model for a sensor node?

In: Computer Science