Questions
Write a C++ program to calculate and print the product of odd integers and even integers...

Write a C++ program to calculate and print the product of odd integers and even integers of the first ‘n’ natural numbers .

In: Computer Science

Part  2: Approximating the Value of Pi Mathematical constant pi it most often to find the circumference...

Part  2: Approximating the Value of Pi

Mathematical constant pi it most often to find the circumference or the area of a circle. For simplicity, the value that is commonly used for pi is 3.14. However, pi is actually an irrational number, meaning that that it has an infinite, nonrepeating number of decimal digits. The value is

3.1415926535897932384626433832795028841971693993751058209749445923078164062…

In this lab, we will approximate the value of pi using a technique known as Monte Carlo Simulation. This means that we will use random numbers to simulate a “game of chance”. The result of this game will be an approximation for pi.

Setup

The game that we will use for this simulation is “darts”. We will “randomly” throw a number of darts at a specially configured dartboard. The set up for our board is shown below. In the figure, you can see that we have a round dartboard mounted on a square piece of wood. The dartboard has a radius of one unit. The piece of wood is exactly two units square so that the round board fits perfectly inside the square.

But how will this help us to approximate pi? Consider the area of the circular dartboard. It has a radius of one so its area is pi. The area of the square piece of wood is 4 (2 x 2). The ratio of the area of the circle to the area of the square is pi/4. If we throw a whole bunch of darts and let them randomly land on the square piece of wood, some will also land on the dartboard. The number of darts that land on the dartboard, divided by the number that we throw total, will be in the ratio described above (pi/4). Multiply by 4 and we have pi.

Throwing Darts

Now that we have our dartboard setup, we can throw darts. We will assume that we are good enough at throwing darts that we always hit the wood. However, sometimes the darts will hit the dartboard and sometimes they will miss.

In order to simulate throwing the darts, we can generate two random numbers between zero and one. The first will be the “x coordinate” of the dart and the second will be the “y coordinate”. However, we have a problem. The coordinates for the dartboard go from -1 to 1.

How can we turn a random number between 0 to 1 into a random number between -1 and 1? We know that random.random() will return a number between 0 and 1. We may obtain a number between -1 and 1by calculating random.random() *2 -1.

Activity 4: The program has been started for you. You need to fill in the part that will “throw the dart”. Once you know the x,y coordinate, have the turtle move to that location and make a dot. by using the dot() function of turtle. Note that the tail is already up so it will not leave a line.

import turtle

import math

import random

wn = turtle.Screen()

wn.setworldcoordinates(-1,-1,1,1)

fred = turtle.Turtle()

fred.up()

numdarts = 50

for i in range(numdarts):

randx = random.random()

randy = random.random()

x =

y =

wn.exitonclick()

Counting Darts

We already know the total number of darts being thrown. The variable numdarts keeps this for us. What we need to figure out is how many darts land in the circle? Since the circle is centered at (0,0) and it has a radius of 1, the question is really simply a matter of checking to see whether the dart has landed within 1 unit of the center. Luckily, there is a turtle method called distance that will return the distance from the turtle to any other position. It needs the x,y for the other position.

For example, fred.distance(0,0) would return the distance from fred’s current position to position (0,0), the center of the circle.

Now we simply need to use this method in a conditional to ask whether fred is within 1 unit from the center. If so, color the dart red, otherwise, color it blue. Also, if we find that it is in the circle, count it. Create an accumulator variable, call it insideCount, initialize it to zero, and then increment it when necessary. Remember that the increment is a form of the accumulator pattern using reassignment.

The Value of Pi

After the loop has completed and visualization has been drawn, we still need to actually compute pi and print it. Use the relationship insideCount/numdarts *4, why?

Run your program with larger values of numdarts to see if the approximation gets better. If you want to speed things up for large values of numdarts, like 1000, set the tracer to be 100 using wn.tracer(100).

NB: The language is Python.

In: Computer Science

I have this C program that has two functions to solve this Blackjack Solution. But i...

I have this C program that has two functions to solve this Blackjack Solution. But i need to use only function (not including main of course).

Is it possible to get to just one function outside of Main? #include<stdio.h> int isvalid(char card1, char card2); int sum(char card1, char card2); int sum(char card1, char card2) { int result=0; if(card1=='A' && card2=='A') return 12; if(card1<='9' && card1>='2') result+=card1-'0'; if(card1=='T' || card1 == 'J' || card1=='Q' || card1=='K') result+=10; if(card1=='A') result+=11; if(card2<='9' && card2>='2') result+=card2-'0'; if(card2=='T' || card2 == 'J' || card2=='Q' || card2=='K') result+=10; if(card2=='A') result+=11; return result; } int isvalid(char card1, char card2) { int i,cnt=0; char a[]="23456789ATJQK"; for(i=0;a[i];i++) { if(card1==a[i]) cnt++; if(card2==a[i]) cnt++; } if(cnt==2) return 1; return 0; } int main() { char c1, c2; scanf("%c %c",&c1,&c2); if(isvalid(c1,c2)) printf("%d\n",sum(c1,c2)); else printf("Invalid input"); return 0; }

In: Computer Science

Relational Database You should understand that a relational database is a collection of tables that are...

Relational Database

You should understand that a relational database is a collection of tables that are related to one another based on a common field. The tables within the database contain a collection of records. The records within the table contain a collection of fields. Each field in the table represents a particular characteristic of the data.

A field, or a collection of fields, is designated as the primary key. The primary key uniquely identifies a record in the table. When the primary key of one table is represented in a second table to form a relationship, it is called a foreign key.

Think about creating a database that will store information about students. Design a table that will contain information about students. You should decide on all the fields (characteristics) they would need to maintain student records. Select a field that would uniquely identify a student (usually a student ID). Explain why the student’s name would not be a good choice for the primary key Next, “fill in” the data for a particular student

Create another table that will store information about the student organizations students participate in (or extracurricular activities, sports, etc.).When you decided what the second table will be, determine the required fields. Most importantly, decide on the common field that will link these tables in a relational database.

In: Computer Science

Skills needed to complete this assignment: linked lists, stacks PROMPT (In C++) Postfix notation is a...

Skills needed to complete this assignment: linked lists, stacks

PROMPT (In C++)

Postfix notation is a mathematical notation in which operators follow their operands; for instance, to add 3 and 4 one would write 3 4 + rather than 3 + 4. If there are multiple operations, operators are given immediately after their second operands; so, the expression written 3-4+5 in conventional notation would be written as 3 4 - 5 + in postfix notation: 4 is first subtracted from 3 and then 5 is added to it.

An advantage of postfix notation is that it removes the need for parentheses that are required by infix notation. While 3-4*5 can also be written 3-(4*5), which is difficult from (3-4) * 5. In post fix notation, the former could be written 3 4 5 * -, while the latter could be written 3 4 - 5 * or 5 3 4 - *.

Stacks can be used to evaluate expressions in postfix notations by following these steps:

1. If a number is typed, push it on the stack

2. If an operation is typed, depending on the operation, pop off two numbers from the stack, perform the operation, and push the result back on the stack.

You should complete the Stack class and other functions in the template file so that when the user enters an expression in postfix notation, the program calculates and shows the result. In this assignment the user enters one digit positive numbers only, but the result can be any integer. Only basic operations (+, -, /, *) are entered by the user and integer division is used in calculations. User input ends with a semicolon.

Class Stack uses a linked list to implement a stack, it has five public member functions:

1. Default constructor: initializes the stack to an empty stack

2. isEmpty: returns true if the stack is empty and false otherwise

3. push: pushes a new number to the top of stack

4. pop: removes the top of the stack

5. top: returns the value at the top of the stack, does not remove it from the stack.

TEMPLATE CODE (MUST USE THIS CODE)

DO NOT edit any other code, only write your code in the sections that say /*your code here*/

#include <iostream>

#include <cstdlib>

using namespace std;

const char SENTINEL = ';';

struct Node {

int data;

Node *link;

};

//precondition: c is initialized

//precondition: returns true if c is '+', '-', '*' or '/'

bool isOperator(char c);

//precondition: o1 and o2 are initialized and op is an operator

//precondition: returns op(o1, o2), e.g. if op is '-' then returns o1-o2

int calculate(int o1, in o2, char op);

//precondition: c is a digit

//precondition: returns the integer value of c

int charToInt(char c);

class Stack {

public:

//default constructor

//initializes the stack to an empty stack

Stack();

//this is a const function, meaning it cannot change any of the member variables

//returns true if the stack is empty, false otherwise

bool isEmpty() const;

//returns the value at the top of the stack, does not modify the stack, does not check if the stack is empty or not

int top() const;

//adds data to the top of the stack

void push(int data);

//removes the top value of stack, does not return it, does nothing if the stack is empty

void pop();

private:

Note *listHead; //pointer to the head of a linked list

};

int main() {

char in;

Stack operandStack;

cout << "Enter a postfix expression (ending with " << SENTINEL << " and press Enter):\n";

cin >> in;

while(in != SENTINEL) {

if(isOperator(in)) { //pop two numbers from stack

int n1, n2;

if(operandStack.isEmpty()) {

//print error message

/*your code here*/

exit(1);

}

n2 = operandStack.top();

operandStack.pop();

if(operandStack.isEmpty()) {

//print error message

/*your code here*/

exit(1);

}

n1 = operandStack.top();

operandStack.pop();

//push the result of calculation to the top of operandStack

/*your code here*/

} else {

//push the number to the top of operandStack

/*your code here*/

}

cin >> in;

}

//pop a number from the top of stack

int result;

result = operandStack.top();

operandStack.pop();

if(operandStack.isEmpty()) //nothing left in the stack

cout << "\nThe result is: " << result << endl;

else // there is still numbers in the stack

{

//print an error message

/*your code here*/

}

return 0;

}

Stack::Stack() {

/*your code here*/

}

bool Stack::isEmpty() const {

/*your code here*/

}

int Stack::top() const {

/*your code here*/

}

void Stack::pop() {

/*your code here*/

}

void Stack::push(int data) {

/*your code here*/

}

int calculate(int o1, o2, char op) {

/*your code here*/

}

bool isOperator(char c) {

return c == '+' || c == '-' || c == '*' || c == '/';

}

int charToInt(char c) {

return(static_cast(c) - static_cast('0'));}

Input/Output Example

Example #1:

Enter a postfix expression (ending with ; and press Enter):

3 4 - 5 +;

The result is: 4

Example #2

Enter a postfix expression (ending with ; and press Enter):

3 4 - 5;

Not enough operators entered!

Example #3

Enter a postfix expression (ending with ; and press Enter):

3 4 - 5 + *;

Not enough operands entered for operator: *

In: Computer Science

How would I modify this Python Program to include two different if statement structures? "For this...

How would I modify this Python Program to include two different if statement structures? "For this program, decisions may include adding different charges to a tables' check based on what the diner orders, and/or deciding when to quit the program, among other possibilities. "

def display_menu_items():
   print("item cost")
   print("1.item-1 5")
   print("2.item-2 10")
   print("3.item-3 15")
   print("4.item-4 50")
   print("5.item-5 25")
   print("6.item-6 2")
   print("7.item-7 26")


def main():
   print("Enter -1 to quit manager or any other number to continue")
   enter_to_quit=int(input())
   if (enter_to_quit==-1):
       quit()
   print("enter table number")
   table_number=int(input())
  
   print("enter no.of diners (maximum limit 4)")
   number_of_diners=int(input())
  
   print("select an item and enter -1 to exit")
   items=[]
   item_number=[]
   select=0
   ch=[0,5,10,15,50,25,2,26]
   display_menu_items()
  
   while ( select is not -1):
       items.append(ch[select])
       item_number.append(select)
       select=int(input())
  
   total_items_cost=0
  
   for i in items:
       total_items_cost=total_items_cost+i
  
   print("Total cost without tax =",total_items_cost)
   total_cost=total_items_cost+(total_items_cost/100)*8
  
   print("cost for individual diner =",total_cost/number_of_diners)
   print("total cost with tax = ",total_cost)
   print("suggestions for tip 1.10% 2.15% 3.20% 4.25% ")
  
   tip=int(input())
   tip_list=[10,15,20,25]
   total_tip=tip_list[tip]
   total_tip=(total_cost/100)*total_tip
  
   print("table information")
   print("table no:- ",table_number)
   print("selected items:-")
  
   item_list=["item-1","item-2","item-3","item-4","item-5","item-6","item-7"]
  
   for i in range(1,len(items)):
       print(item_list[item_number[i]-1])
   print("total cost= ",total_cost)
   print("tip= ",total_tip)
   print("total cost with tip= ",total_cost+total_tip)
   main()

In: Computer Science

Q1: In the Internet Protocol (IP), the Header Error Checksum (HEC) is the only measure to...

Q1: In the Internet Protocol (IP), the Header Error Checksum (HEC) is the only measure to check for errors of any kind. Which makes the IP header reliable.

T or  F

Q2:  Every router strips off the IP header and puts a new header

T or  F

Q3:  (Short Answer) What is Dynamic re-keying?

Q4: In a VPN, the IP packets secured using IPSec uses different Internet circuits as any other traffic can use. There are dedicated circuits for IPSec.

T or F?

Q5: Authentication Header (AH) has two IP headers and encapsulated security payload (ESP) has only one.

T or  F

Q6: For having a host-to-host tunnel private IP addresses can't be used in the hosts.

T or F?

Q7:   (Short Answer) What does the Authentication Header (AH) and encapsulated security payload (ESP) each provides?

Q8:  (Short Answer) What is a Security Parameter Index (SPI)?

Q9: The meaning of tunnel in the tunnel model of IPSec is that the protected IP packets are outside another IP header (the outer header) and the outer headers of many IP packets can be visualized as making a tunnel wall through which the inner IP packets are passing.

T or F

Q10: (Short Answer) What replaces IPSec security associations (SAs)?

In: Computer Science

Go online and search for information about a commercial off-the-shelf program that had a serious security...


Go online and search for information about a commercial off-the-shelf program that had a serious security problem. Describe the problem in a brief paper. Be prepared to share your findings with the class. 500 words

In: Computer Science

. Write an essay of not less than 3 pages on only one topic chosen from...

. Write an essay of not less than 3 pages on only one topic chosen from any of the following areas in introduction to computing:

  1. basic concepts of word processing
  2. Internet application
  3. computer systems
  4. ergonomics - health implications in the use of a PC
  5. protection and care of a computer system

In: Computer Science

Hello, Im trying to converter this C# program into python, i have started but am stuck...

Hello, Im trying to converter this C# program into python, i have started but am stuck on alot of small syntax! Please help me!

def Wired
def "RTClib.h"

int PWMSTEP = 2
int PWMSTART = 340
int PWMEND = 1023
int iENDPOINT
int correctionStep = 1
int correctionThreshold = 5
int fadeOutstep = 5

int numReadings = 5
float readings[numReadings]
int readIndex = 0
float total = 0
float average = 0

def SoftwareSerialmySerial = 7 8


Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();

def RED 0x1
def YELLOW 0x3
def GREEN 0x2
def TEAL 0x6
def BLUE 0x4
def VIOLET 0x5
def WHITE 0x7
int sensorPin = A1
int sensorPin2 = A2
int sensorValue = 0
int sensor2Value = 0

int isetPWM = 0
int usersetMaxFlow = 0
int usersetMinFlow = 0
int setFlow = 0
float fymin
bool DBUG = true

int rawflow = 0
int rawpressure = 0

def sflowrate
int flowrate = 0
int ipwm = 0
int oldipwm = 0
float flowdifference
int actualflowrate = 0
int actualpressure = 0
bool bnewGasIn

bool bovershoot = false
int imode

int led = LED_BUILTIN
int PWMPIN = 10

int PRESSUREPIN = A6

int RESET = 1
int SYSTEM_IDLE = 6
int GASIN = 2
int FADEIN = 13
int FADEOUT = 14
int RAWGASIN = 15
int STEP1 = 100
int STEP0 = 10
int STEP2 = 200
int STEP3 = 300
int STEP4 = 400
int STEP5 = 500

int MMIN = 16
int MMAX = 17
int MRUN = 18

int SYSTEM_STATE
int TEST_STATE

bool FLOW_MODE = true
float newpflow
def previousMillis = 0
int initialflowrate
def interval = 0
int hbcounter = 0
int buttonState = 0
def buf[20]
int incomingLen
int sblen
def c
bool bOkNum
float ymin
float ymax
float xmax
int pressureOffset
int targetpressure
int zeropressure
def startMillis
int address = 0
str flowDataStruct {
int deltaP[51]
int zeropressure;
}
int tdeltaP[51]
def DataStructflowData[3]
int itarget
int iindex
int ncages

void setup() {

int iret = EEPROM.readBlock(address, flowData,3)

def SYSTEM_STATE = SYSTEM_IDLE
def Timer1.initialize(1000); // msec so 2500=400Hz
def pinMode(PWMPIN, OUTPUT);

def Serial.begin(9600);
def mySerial.begin(9600);
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
EEPROM.readBlock(address, flowData,3);
print "Prodigy Calibration"
}

void loop() {

if (Serial.available()) {
c = Serial.read();
print "incoming char: "
// println(c);
if (c==63)
{
print "Prodigy Calibration 001"
print "1,2,3 to start"
print "W to save to eeprom"
print "any char to abort"
} else

if ((c==87)||(c==119))
{
print "Calibration data"
print "one cage: zeroPressure=");
print flowData[0].zeropressure
print flowData[0].deltaP[0]);
for (int i=1;i<51;i++)
{
print ","
print flowData[0].deltaP[i]
}
print " "
print "two cages: zeroPressure="
print (flowData[1].zeropressure)
print (flowData[1].deltaP[0])
for (int i=0;i<51;i++)
{
print ","
print (flowData[1].deltaP[i])
}
print " "
print "three cages: zeroPressure="
Serial.println(flowData[2].zeropressure);
Serial.print( flowData[2].deltaP[0]);
for (int i=0;i<51;i++)
{
print ","
print flowData[2].deltaP[i]
print " "
int iret = EEPROM.writeBlock(address, flowData,3);
print "Saved."


} else

if (c == 49)
{
for (int i=0;i<51;i++)
{
def tdeltaP[i] = 0;
}
def itarget = 50;
def iindex = 0;
def iENDPOINT = 1000;
def ipwm = 0; //start pwm
def Timer1.pwm(PWMPIN, ipwm);
print "Starting one cage calibration."
def SYSTEM_STATE = GASIN;
def TEST_STATE = STEP0;
def ncages = 0;
zeropressure = analogRead(PRESSUREPIN);
flowData[ncages].zeropressure = zeropressure;
} else
if (c == 50)
{
for (int i=0;i<51;i++)
{
tdeltaP[i] = 0;
}
itarget = 50;
iindex = 0;
iENDPOINT = 650;
ipwm = 0; //start pwm
Timer1.pwm(PWMPIN, ipwm);
print "Starting two cage calibration."
SYSTEM_STATE = GASIN;
TEST_STATE = STEP0;
ncages = 1;
zeropressure = analogRead(PRESSUREPIN);
flowData[ncages].zeropressure = zeropressure;

} else
if (c == 51)
{
zeropressure = analogRead(PRESSUREPIN);
for (int i=0;i<51;i++)
{
tdeltaP[i] = 0;
}
itarget = 50;
iindex = 0;
iENDPOINT = 425;
ipwm = 0; //start pwm
Timer1.pwm(PWMPIN, ipwm);
print "Starting three cage calibration."
SYSTEM_STATE = GASIN;
TEST_STATE = STEP0;
ncages = 2;
zeropressure = analogRead(PRESSUREPIN);
flowData[ncages].zeropressure = zeropressure;

} else
{
print "Stopping."
SYSTEM_STATE = FADEOUT;
}
}


long currentMillis = millis();
long ltemp = (unsigned long) (currentMillis - previousMillis);
float flowdifference = (float)setFlow - (newpflow*10.0);

float tp;
int itemp;
if (SYSTEM_STATE==FADEOUT)
{
while (1) {
if (ipwm < 250)
ipwm -= 10;
else
if (ipwm > 500)
ipwm -= fadeOutstep*2;
else
ipwm -= 10;
if (ipwm<=0)
{
ipwm=0;
Timer1.pwm(PWMPIN, ipwm); //10bit
SYSTEM_STATE=SYSTEM_IDLE;
break;

}
Timer1.pwm(PWMPIN, ipwm); //10bit
}

} else
if (SYSTEM_STATE==GASIN)
{
switch (TEST_STATE)
{
// set PWM
case STEP0:
tp = analogRead(PRESSUREPIN);
total = 0;
// tp = ((float)tp*(float)5.0)/(float)1023.0;
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = tp;
total+=tp;
}
// itemp = (int)((total / numReadings)*1000.0);
itemp = (int)((total / numReadings));
print "Start initial p = "
print itemp
readIndex = 0;
startMillis = millis();
TEST_STATE = STEP1;
break;
// set zero offset
case STEP1:
tp = analogRead(PRESSUREPIN);
// tp = ((float)tp*(float)5.0)/(float)1023.0;
print "actualpressure="
print tp

total = total - readings[readIndex];
readings[readIndex] = tp;
total = total + readings[readIndex];
readIndex = readIndex + 1;
if (readIndex >= numReadings) {
readIndex = 0;
}
zeropressure = (int)((total / numReadings));
// zeropressure = (int)((total / numReadings)*1000.0);
print " p0="
print zeropressure
if (((unsigned long) (currentMillis - startMillis))>3000)
{
TEST_STATE = STEP2;
ipwm = PWMSTART;
Timer1.pwm(PWMPIN, ipwm); //10bit
startMillis = millis();
}
break;

// set PWM
case STEP2:
tp = analogRead(PRESSUREPIN);
// tp = ((float)tp*(float)5.0)/(float)1023.0;

total = total - readings[readIndex];
readings[readIndex] = tp;
total = total + readings[readIndex];
readIndex = readIndex + 1;
if (readIndex >= numReadings) {
readIndex = 0;
}
actualpressure = (int)((total / numReadings)*1000.0);
// actualpressure = (int)((tp)*1000.0);
actualpressure = (int)((tp));
if (((unsigned long) (currentMillis - startMillis))>7000) //10000)
{

print "zp="
print zeropressure
print " pressure="
print ","
print actualpressure
print " pwm="
print ","
print ipwm
// tp = analogRead(A5);
// tp = ((float)tp*(float)5.0)/(float)1023.0;
//// Serial.print( " Fv=");
print ","
mySerial.write('F');
mySerial.write('\r');
delay(500);

incomingLen = mySerial.available();
if (incomingLen > 0) {
// Serial.println(" ");
print "newchar: incomingLen="
print incomingLen
print "-"
sblen=0;
bOkNum = false;
bool bcont = true;
for (int i=0;i<incomingLen;i++)
{
c = mySerial.read();
if (c==13)
{
bcont = false;
bOkNum = true;
buf[sblen++]=0;
// break;
} else
if (bcont)
{
buf[sblen++]=c;
print "-"
print c
}

}
// Serial.println("#");
if (bOkNum)
{
Str stemp = String((char *) buf);
tp = stemp.toFloat();
print " flow="
print tp
print "#"
} else tp = -1.00;

print tp
int itemp1 = (int)(tp*100.0);
if (itemp1 >= itarget)
{

print "target found: target="
print itarget
print " deltaP="
print actualpressure
tdeltaP[iindex++] = actualpressure;
if (itarget==iENDPOINT)
{
SYSTEM_STATE=FADEOUT;
print ""
print "Completed. Array is"

for (int i=0;i<51;i++)
{
flowData[ncages].deltaP[i]=tdeltaP[i];
print tdeltaP[i]
print ","
}
print " "

}
itarget+=25;


}
}
// if (((long) (currentMillis - startMillis))>1500)
// {
if (itarget>=600)
PWMSTEP=5;
else
PWMSTEP=2;
ipwm+=PWMSTEP;
if (ipwm > PWMEND){ //changed from 255 for 10bit
SYSTEM_STATE=FADEOUT;
print ""
print "Completed. Array is"

for (int i=0;i<51;i++)
{
flowData[ncages].deltaP[i]=tdeltaP[i];
print tdeltaP[i]
print ","
}
print " "
}
Timer1.pwm(PWMPIN, ipwm); //10bit
startMillis = millis();
}
break;

}

}


}

In: Computer Science

Write a program that will find the smallest, largest, and average values in a collection of...

Write a program that will find the smallest, largest, and average values in a collection of N numbers. Get the value N before scanning each value in the collection of N numbers. b. Modify your program to compute and display both the range of values in the data collection and the standard deviation of the data collections. To compute the standard deviation, accumulate the sum of the squares of the data values (sum squares) in the main loop. After the loop exits, use the formula: Standard Deviation = qsum sqaures N − average2 Use a for or while loop, and scan for each number entered separately. sample run 1 Program Computes Average, Maximum, Minimum,and Standard Deviation of N numbers Enter N: 5 Number 1: 19.3 Number 2: 16.5 Number 3: 11.9 Number 4: 22.3 Number 5: 18.4 Average = 17.680 Maximum = 22.300 Minimum = 11.900 StanDev =3.443 (IN C WITH COMMENTS)

In: Computer Science

Ques: (i) Given an instance of a relation R where A and B are two of...

Ques: (i) Given an instance of a relation R where A and B are two of the attributes in R, describe an algorithm that checks whether a functional dependency A → B holds on R.

(ii) Given a relation with schema R(A, B, C, D, E) and a set of FD's F = {AD → E, AB → C, C → D, E → B} Find a lossless join decomposition to decompose R into collections of relations that are in BCNF

In: Computer Science

i) Show that there is no algorithm for deciding if any two Turing machines M1 and...

i) Show that there is no algorithm for deciding if any two Turing machines M1 and M2 accept the same language.

ii) How is the conclusion of ii affected if M2 is a finite automaton?

In: Computer Science

Discuss on the Design Process: Expands on the steps taken in the design process, the stages...

Discuss on the Design Process: Expands on the steps taken in the design process, the stages of a design process, and give an example, including requirements and specifications. What is included in the design stages for the life cycle of the designed system?

In: Computer Science

In java, implement an animal guessing game. Start with a "Decision Tree", but present the leaves...

In java, implement an animal guessing game. Start with a "Decision Tree", but present the leaves as “Is it a X?” If it wasn't, ask the user what the animal was, and ask for a question that is true for that animal but false for X. For example,
Is it a mammal? Y
Does it have stripes? N
Is it a pig? N
I give up. What is it? A hamster
Please give me a question that is true for a hamster and false for a pig.
Is it small and cuddly?

In this way, the program learns additional facts.

Once complete, add to the program by writing the tree to a file when the program exits. Load the file when the program starts again.

In: Computer Science