Questions
Write a program which takes 3 inputs values as dimensions of a cuboid. Do the following-...

Write a program which takes 3 inputs values as dimensions of a cuboid. Do the following-

1. Verify it forms a cuboid (non zero, non negative and non-integer inputs).

2. Show the longest and shortest edges.

3. Calculate the surface area of the square made by the two short edges.

4. Calculate the volume of the cuboid.

Refer the following to learn about the cuboid (generally this is called the domain knowledge)

https://www.math-only-math.com/cuboid.html
Volume and Surface Area of Cuboids and Cubes ( GMAT / GRE / CAT / Bank PO / SSC CGL)
Provide value adding comments in the code wherever necessary.
Write test cases covering as many scenarios as possible.
Maintain a tabular format with columns - Test#, Scenario, test steps, expected result, Actual result.

java code required

JAVA CODE

In: Computer Science

This code needs to run a working Reverse Polish Calculator, but when I input my commands...

This code needs to run a working Reverse Polish Calculator, but when I input my commands it only pops my inputs never push them. So my answer is always zero.

Here is my code.

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

struct Node
{
int element;
struct Node *next;
};

//Global variable
struct Node *top = NULL;

void push(int ele)
{
struct Node *newNode;

newNode = (struct Node *) malloc(sizeof(struct Node));

newNode->element = ele;
newNode->next = top;
top = newNode;
}

void pop()
{
struct Node *temp;
temp = top;

if(top == NULL)
printf("Stack is empty!!!\n");
else
{
top = top->next;
printf("%d is popped from the stack\n", temp->element);
free(temp);
}


}

bool isEmpty()
{
if(top == NULL)
return true;
else
return false;
}

int returnTopElement()
{
return top->element;
}

void printStack()
{
struct Node *temp;
temp = top;

printf("Stack : ");

while(temp != NULL)
{
printf("%d ", temp->element);
temp = temp->next;
}

printf("\n");
}

int oneByOne(){
char test; //taking character input
int num = 0;
int num1;
int num2;
int atleastone = 0;
printf("Enter your inputs separated by a space and the operation.\n");
printf("Enter ! when you are done.\n");

while(1){
scanf("%c",&test); //take input of current character
printf("%c is user character\n", test);
if(test == '!'){break;} //terminates character
if(test == ' ' || test == '\n'){ //allows for space or newline input
if(atleastone) //check if at least one previous digit scanned
push(num);
num = 0, atleastone = 0;
continue;
}
else if(test>='0' && test <='9'){
atleastone = 1;
num = num*10 + (test - '0');
continue;
}
if(top == NULL){
printf("This operation is invalid.\n");
break;
}
num1 = returnTopElement(); pop();
if(top == NULL){
printf("This operation is invalid.\n");
break;
}
num2 = returnTopElement(); pop();
if(test == '+');
push(num2+num1); //allows addition
if(test == '-');
push(num2-num1); //allows subtraction
if(test == '*');
push(num2*num1); //allows multiplication
if(test == '/');
push(num2/num1); //allows division
}
if(top == NULL)
return -1;
return returnTopElement();
}

int arrayInput(char** inputArray){
int i = 0;
int atleastone = 0;
int num = 0;
int num1;
int num2;
char test;
while((*inputArray)[i] != '\0'){
test = (*inputArray)[i];i++; //gets char input from function
if(test == '!'){break;} //terminate character
if(test == ' ' || test == '\n'){ //allows for space or newline input
if(atleastone)
push(num);
num = 0, atleastone = 0;
continue;
}
else if(test >= '0' && test <= '9'){
atleastone = 1;
num = num*10 + (test- '0');
continue;
}
if(top == NULL){
printf("This operation is invalid.\n");
break;
}
num2 = returnTopElement(); pop();
if(test == '+');
push(num2+num1); //allows addition
if(test == '-');
push(num2-num1); //allows subtraction
if(test == '*');
push(num2*num1); //allows multiplication
if(test == '/');
push(num2/num1); //allows division
}
if(top == NULL)
return -1;
return returnTopElement();
}

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

printf("Check oneByone function: \n");
int ans = oneByOne();
if(top == NULL){
printf("The input is invalid.\n");
}
else{
printf("The answer is %d\n", ans);
}

char * e = "23 45 + 3 *";
char ** expression = &e;
printf("\nChecking arrayInput function for %s \n", *expression);
printf("The above expression is hardcoded in the code itself. \n");
ans = arrayInput(expression);
if(top == NULL){
printf("The input expression is invalid. \n");
}
else{
printf("The answer of the input expression is %d\n", ans);
}

return 0;
}

In: Computer Science

Explain the importance of awareness when dealing with employees security. Provide an example of two security...

Explain the importance of awareness when dealing with employees security. Provide an example of two security policies that would help prevent internal employee fraud.

In: Computer Science

2.20 Domain Lab 3.1 -- Velocity Calculator You may (or may not) need the following constants:...

2.20 Domain Lab 3.1 -- Velocity Calculator

You may (or may not) need the following constants:

  • Pi = 3.14
  • Speed of Light (c) = .307 parsecs/year
  • Gravity (g) = 9.81 m/s squared

Velocity Calculator Your program should ask the user (in this order) for:

  • Initial Velocity
  • Acceleration
  • A Time Period

Your program should then calculate and display the resulting final velocity based on the inputs provided.

In: Computer Science

in java please: Given any integer, print an English phrase that describes the integer (e.g. “One...

in java please:

Given any integer, print an English phrase that describes the integer (e.g. “One Thousand, Two Hundred Thirty Four”). An ArrayList must be used in your program.

In: Computer Science

In Python: Write a function called sum_odd that takes two parameters, then calculates and returns the...

In Python:

Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second.

To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use at least 1 decision structure.

Examples:

sum_odd(0, 5) should return the value 9 as (1 + 3 + 5) = 9

sum_odd(6, 10) should return the value 16

sum_odd(13, 20) should return the value 64

sum_odd(7, 11) should return the value 27

In: Computer Science

Write a recursive and an iterative function to calculate the nth element in a Fibonacci sequence....

Write a recursive and an iterative function to calculate the nth element in a Fibonacci sequence. A Fibonacci sequence is defined as the element 1, followed by another 1, and each element thereafter is the sum of the previous two elements. For example, the first 9 elements of a Fibonacci sequence are:

  • 1 2 3 5 8 13 21 34

This famous sequence was originally used to predict the growth of rabbit populations!

Once you have each of the functions working for n equal to 40, determine which method is more efficient by timing the two separate function calls and printing out the time required for each method call to return the 40th element in the sequence. Return the 40th element to main and print it. After that, print out a complete Fibonacci sequence from element 1 to element 40, along with its position number.

  1. 1
  2. 1
  3. 2
  4. 3

.       .

.       .

This last part should not be timed.

The timer function you need for this Project is:

                        Date d1 = new Date();

                        long milliseconds = D1.getTime();

                                                OR

                        long start = System.currentTimeMillis();

Turn in the source, output, and a short paragraph explaining the reason the two methods took different amounts of time to execute.

Please write in JAVA

and please write recursive part and iterative part separate!

In: Computer Science

DATA MINING : Find an interesting data set on the Web. Provide a high level description...

  1. DATA MINING : Find an interesting data set on the Web. Provide a high level description of the data set and minimally give its name, location, number of features (with some discussion of the feature types), and number of entries. Describe how data mining can be applied to it (e.g., for classification, etc.) and describe why you think it is interesting.

In: Computer Science

There are PRO's and CON's to mounting and emulating the suspect system. Post a short discussion...

There are PRO's and CON's to mounting and emulating the suspect system. Post a short discussion item on some PRO's and CON's of booting up a forensic image.

In: Computer Science

wireless vulnerabilies

wireless vulnerabilies

In: Computer Science

Given an IP address of 220.84.9.123 and a subnet mask of 255.255.255.240 Write down the address...

  1. Given an IP address of 220.84.9.123 and a subnet mask of 255.255.255.240

Write down the address of the network, show your calculation.

Write also the broadcast address

2. On a network with an IP address of 133.133.133.13 and a subnet mask of 255.255.248.0 what is the network ID?  Show your calculation.  Write also the broadcast address

  1. On a Class C network, you have a subnet mask of 255.255.255.192.  
  1. How many hosts per subnet do you have?
  2. On how many subnets was divided this class C address?  Show your calculations.

4. Your company has leased a Class C network whose network ID is 222.91.37.0. You want to create 30 subnets within this network. Show how many bits, you would need to change, and the range of addresses in one of the subnets.

In: Computer Science

Direct memory access is used for high-speed I/O devices in order to avoid increasing the CPU's...

Direct memory access is used for high-speed I/O devices in order to avoid increasing the CPU's execution load.

(a) What does the CPU do to interface with the device to coordinate the transfer?
(b) How does the CPU know when the memory operations are complete?
(c) The CPU is allowed to execute other programs while the DMA controller is transferring data. Does DMA interfere with the execution of the other programs? If so, describe what form of interference are caused.


In: Computer Science

1.Which of the following is a DML operation on table employee? change an employee's stree address...

1.Which of the following is a DML operation on table employee?

change an employee's stree address

cancel the insertion of 3 new employees in table employee

add a column phone2 to table employee to limit the salary amount to be at most $200,000

add a constraint in table employee to limit the salary amount to be at most $200,000

In: Computer Science

15.1 File IO Warm-up For this exercise, you will receive two string inputs, which are the...

15.1 File IO Warm-up

For this exercise, you will receive two string inputs, which are the names of the text files. You need to check if the input file exists. If input file doesn't exist, print out "Input file does not exist."

You are required to create 4 functions:

void removeSpace (ifstream &inStream, ofstream &outStream): removes white space from a text file and write to a new file. If write is successful, print out "Text with no white space is successfully written to outFileName."

int countChar (ifstream &inStream): returns number of character in input file.

int countWord(ifstream &inStream): returns number of words in input file.

int countLines(ifstream &inStream): returns number of lines in input file.

After calling each function, you have to reset the state flags and move the stream pointer to beginning of file. You can do that by closing and re-opening the file, or by calling member functions:

inStream.clear(); inStream.seekg(0);

Example:

Input: input.txt output.txt

Output:

Text with no white space is successfully written to output.txt.

Number of characters is: 154

Number of words is: 36

Number of lines is: 10

here is the code in C++:

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

void removeSpace(ifstream &inStream, ofstream &outStream);
int countChar (ifstream &inStream);
int countWords(ifstream &inStream);
int countLines (ifstream &inStream);

int main()
{
string input, output;
cin >> input >> output;

ifstream inStream(input);
ofstream outStream(output);

if(inStream.fail())
cout << "Input file does not exist.\n" ;
else
{
removeSpace(inStream, outStream);
cout << "Text with no white space is successfully written to outFileName.\n";
inStream.clear();
inStream.seekg(0, inStream.beg);

cout << "Number of characters is: " << countChar(inStream) << endl;
inStream.clear();
inStream.seekg(0, inStream.beg);

cout << "Number of words is: " << countWords(inStream) << endl;
inStream.clear();
inStream.seekg(0, inStream.beg);

cout << "Number of lines is: " << countLines(inStream) << endl;
inStream.close();
}

outStream.close();

return 0;
}

//define your functions here

In: Computer Science

Write a working C++ program to ask the user for a set of grades which are...

Write a working C++ program to ask the user for a set of grades which are to be stored in an array in increasing sequence. The user must first provide the number which represents the count of all grades to be provided. For example, if there will be 10 grades, the user is first prompted to provide the number 10. Subsequently, each grade is provided, one at a time. Allow for a maximum of 30 grades in defining the array. When all the grades have been sorted properly, print them all, along with the average.

Process the array using a function which is invoked from the main body of the program. The main body asks for the count of grades and then invokes the grade sequencing function.

You must write in proper C++ syntax and actually execute the program to ensure it works properly.

In: Computer Science