Serial.flush() and Delay() are the two built-in functions. Place them in the following code to remove the garbage data printing as discussed in class.
Code:
char data;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
while(Serial.available()==NULL){
data = Serial.read();
Serial.print("given character is: ");
Serial.println(data);
}
Serial.end();
}
In: Computer Science
Programming Activity 7 - Guidance =================================
This assignment uses a built-in Python dictionary. It does not use a dictionary implementation from the textbook collections framework. It does not require any imports/files from the textbook collections framework. This week's "examplePythonDictionary.py" example uses a built-in Python dictionary. Note that the mode() function begins by creating an empty Python dictionary. You must use this dictionary in the following parts.
Part 1 ------ In this part you will add entries to the dictionary. Use a "for" loop to iterate through the values in the data list. For each value, use it as a dictionary key to see if it is already in the dictionary. If it is already in the dictionary, add one to that dictionary entries value. Each dictionary value contains the number of times that value occurs in the data. You reference the current value for a key via dictionary[key]. If it is not in the dictionary, add it by assigning an entry for it with a value of 1.
Part 2 ------ Python has a built-in max() function that finds the maximum in any iterable object. Use max() on the list of dictionary values to obtain the maximum number of times a value occurs. Assign this to a variable called maxTimes. You will make use of maxTimes in part 3.
Part 3 ------ Note that this part begins by creating an empty modes list. Use a "for" loop to loop through the dictionary keys. The default "for" iterator for a Python dictionary iterates through its keys. For each key, see if its associated dictionary value is equal to maxTimes. If it is equal, append that key to the modes list.
Part 4 ------ If no item in the data set is repeated, then your modes list at this point will be the same as your starting data list. However, this case actually should mean there is no mode. Actually, every item is a mode with a frequency of 1. But, we want to return an empty modes list for this case. If the modes list and the data list have the same length, reset modes to an empty list. Note that modes is already being returned at the end of the function.
=============================================================================================================================
useDictionary.py
# This program uses a Python dictionary to find the mode(s) of a data set.
# The mode of a data set is its most frequently occurring
value.
# A data set may have more than one mode.
# Examples:
# mode of [1,2,3,4,5,6,7] is none
# mode of [1,2,3,4,5,6,7,7] is 7
# modes of [1,2,2,2,3,3,4,5,6,7,7,7] are 2 and 7
# Replace any "<your code>" comments with your own code
statement(s)
# to accomplish the specified task.
# Do not change any other code.
# This function returns a list containing the mode or modes of
the data set.
# Input:
# data - a list of data values.
# Output:
# returns a list with the value or values that are the mode of
data.
# If there is no mode, the returned list is empty.
def mode(data):
dictionary = {}
# Part 1:
# Update dictionary so that each dictionary key is a value in data
and
# each dictionary value is the correspinding number of times that
value occurs:
# <your code>
# Part 2:
# Find the maximum of the dictionary values:
# <your code>
# Part 3:
# Create a list of the keys that have the maximum value:
modes = []
# <your code>
# Part 4:
# If no item occurs more than the others, then there is no
mode:
# <your code>
return modes
data1 = [1,2,3,4,5,6,7]
print(data1)
print("mode:", mode(data1))
print()
data2 = [1,2,3,4,5,6,7,7]
print(data2)
print("mode:", mode(data2))
print()
data3 = [1,2,2,2,3,3,4,5,6,7,7,7]
print(data3)
print("mode:", mode(data3))
print()
data4 = ["blue", "red", "green", "blue", "orange", "yellow",
"green"]
print(data4)
print("mode:", mode(data4))
print()
In: Computer Science
In: Computer Science
The purpose of this assignment is to build the business calculator using supporting files built inTopics 4 and 5.Create a Java application file named RPN.java containing a main method by using the ForthStack.java and associated files from Topic 5.The application should have one text box for numeric data entry, one text box for numeric display, one text box for error display, and buttons labeled "+", "-", "*", "/","dup", "2dup", "clr", "pop" and "push." The actions of the controls should be as follows.oThe text box for numeric display should display the top element of the stack, or blank if the stack is empty.oThe text box for numeric data entry should allow the user to type in a valid numeric value.oThe text box for error display should display an error message from the previous operation (if any), or be blank if the last operation was successful.oThe buttons labeled "+", "-", "*", "/", "dup", "2dup", "clr", and pop should invoke the corresponding methods in ForthStack; "pop" should remove and discard the top item on the stack, and "push" should push the numeric value in the numeric data entry box onto the stack and clear the numeric data entry box.oAll button operations should update the display of the top of the stack.The size of the stack used should be four, no more or less, in order to standardize testing.After thoroughly testing the program, submit the AbstractStack.java, ArrayStack.java,Forth.java, ForthStack.java, TestForthStack.java, and RPN.java
STACK CODE:
ArrayStack.java
import java.util.Arrays;
public class ArrayStack extends AbstractStack {
//Attributes
private double[] array;
private int size;
private int num;
//Default constructor
public ArrayStack() {
array = new double[3];
size = 3;
num = 0;
}
//Parametrized Constructor
public ArrayStack(int a){
array = new double[a];
size = a;
num = 0;
}
//Insert a new element
public void push(double a){
if (num < size) {
array[num] = a;
num++;
System.out.println("Success");
}
else {
throw new ArrayIndexOutOfBoundsException("Failure! Stack is
full");
}
}
//Take out last inserted value
public double pop(){
if (num > 0){
num--;
return array[num];
}
else {
throw new ArrayIndexOutOfBoundsException("Stack is empty");
}
}
//Check stack empty or not
public boolean isEmpty(){
return (num == 0);
}
//Get top element from stack
public double peek() {
return peek(num-1);
}
//Get specified index element
public double peek(int n){
try
{
if (num > 0){
if (n < 0 || n >= num)
return -1;
else
return array[n];
}
else{
System.out.println("Stack is empty");
return -1;
}
}catch(Exception e ){
e.printStackTrace();
}
return 0;
}
//Number of elements in stack
public int count(){
return num;
}
public void clear() {
size=0;;
num=0;
}
}
public class FourthStack extends ArrayStack implements
Fourth{
//Parameterized constructor
public FourthStack(int sz) {
super(sz);
}
@Override
//Pop 2 elements from stack and add values
//Push into stack
public void add() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.pop()+super.pop());
}
}
@Override
//Pop 2 elements from stack and subtract second from first
//Push into stack
public void sub() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.pop()-super.pop());
}
}
@Override
//Pop 2 elements from stack and multiply values
//Push into stack
public void mul() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.pop()*super.pop());
}
}
@Override
//Pop 2 elements from stack and divide second from first
values
//Push into stack
public void div() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.pop()/super.pop());
}
}
@Override
//peek an element and make duplicate
//Push into stack
public void dup() {
if(super.count()<1) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
super.push(super.peek());
}
}
//Peek 2 elements from stack and make their duplicate
//Push into stack in same order
@Override
public void twoDup() {
if(super.count()<2) {
throw new ArrayIndexOutOfBoundsException("Not enough elements to
pop");
}
else {
double first=super.peek();
double second=super.peek(super.count()-2);
super.push(second);
super.push(first);
}
}
}
import java.util.Scanner;
/**
* Test implemented functions
* @author deept
*
*/
public class TestFourthStack {
public static void main(String [] args){
//Variables for input
int choice;
int pek;
double val,poped;
boolean empty;
//Keyboard read
Scanner sc =new Scanner(System.in);
FourthStack as = new FourthStack(20);
//Loop until exit
while(true){
//User choices
System.out.println("1. Enter a Value in stack");
System.out.println("2. Pop a Value");
System.out.println("3. Check If array is Empty");
System.out.println("4. Peek Function");
System.out.println("5. Clear Stack");
System.out.println("6. Add Function");
System.out.println("7. Sub Function");
System.out.println("8. Mul Function");
System.out.println("9. Div Function");
System.out.println("10. Dup Function");
System.out.println("11. TwoDup Function");
System.out.println("0. Exit\n");
choice = sc.nextInt();
//Execute each choice
switch(choice){
case 1:
System.out.print("Enter a value To push : ");
val = sc.nextDouble();
as.push(val);
break;
case 2:
poped = as.pop();
System.out.println("Popped : "+poped);
break;
case 3:
empty = as.isEmpty();
System.out.println("Empty ? "+empty);
break;
case 4:
poped = as.peek();
if(poped != -1)
System.out.println("Peeked Value : "+poped);
else
System.out.println("Oops it was not a valid index this place is
empty");
break;
case 5:
as.clear();
break;
case 6:
as.add();
break;
case 7:
as.sub();
break;
case 8:
as.mul();
break;
case 9:
as.div();
break;
case 10:
as.dup();
break;
case 11:
as.twoDup();
break;
case 0:
System.exit(0);
}
}
}
}
/*
* Pure abstract class without implementation
*/
public abstract class AbstractStack {
public abstract void push(double item);
public abstract double pop();
public abstract boolean isEmpty();
public abstract double peek();
public abstract void clear();
}
/*
* Interface to generate sum additional functions using stack
*/
public interface Fourth {
public void add();
public void sub();
public void mul();
public void div();
public void dup();
public void twoDup();
}
I PROVIDED THE FIVE PREVIOUS STACKS THAT I USED ON MY PREVIOUS WORK... LET ME KNOW IF THERE'S ANYTHING ELSE
In: Computer Science
I need a flow chart built in raptor and the Java source code in the source folder (src)
Please fully document the program: add comments to describe all major parts of the solution. SO that I can understand how and why the code was built that way.
Problem specifications:
-The TSA want you to design and code a program that will be used to screen travelers through AirportX. When a traveler arrives at the airport, he/she is required to go through a checkpoint for COVID-19. The traveler temperature is checked and a recommendation is made for the traveler to be quarantined or not.
A traveler will be quarantined if all of the following conditions are met:
-the temperature read for the traveler is 100.4 or more degrees Fahrenheit.
-the traveler is coughing.
-the traveler is experiencing a shortness of breath.
What need to be collected about a traveler?
Beside collecting all of the above information about a traveler, the first name and last name and passport number of the traveler are collected only if the traveler is to be quarantined.
What to do?
-develop a full solution made up of a short analysis of the problem, a flowchart using Raptor, another flowcharting program, or even by hands, and a full Java program.
In: Computer Science
For this assignment, we will learn to use Python's built in set type. It's a great collection class that allows you to get intersections, unions, differences, etc between different sets of values or objects.
1. Create a function named common_letters(strings) that returns the intersection of letters among a list of strings. The parameter is a list of strings.
For example, you can find the common letter in the domains/words statistics, computer science, and biology. You might easily see it, but you need to write Python code to compute the answer. In order to pass the tests you must use the set api.
In: Computer Science
Some monkey flowers (Mimulus guttatus) living near the sites of copper mines can grow in soil containing high concentrations of copper, which is toxic to most plants. Copper tolerance is a heritable trait.
The map below shows the area near an old copper mine, which contaminated the nearby soil with copper. A stream flows past the mine toward the lake at the bottom right of the map.

| The population that existed before mining must have included both copper-tolerant and copper-intolerant plants. | |
| Nearly 100% of monkey flowers growing in copper-contaminated soil are copper tolerant. | |
| Natural selection favors copper tolerance in all soils near the old mine, not only in the contaminated soils. | |
| Copper contamination in the soil created copper-tolerant plants. | |
| Copper-tolerant plants are found only in contaminated soils. | |
| If you were to test monkey flowers growing on the shore of the lake, you would expect nearly 100% of them to be copper tolerant. |
In: Biology
A student desires to know if two-bedroom apartments for rent near
the BRCC campus in Baton Rouge are significantly different, on
average, than one-bedroom apartments for rent near the BRCC campus
in Baton Rouge. The student collects data for a random sample of
ten (10) advertisements for each of one-bedroom and two-bedroom
apartments for rent near the BRCC campus in Baton Rouge. The data
below shows the advertised rents (in dollars per month) for the
selected apartments.
1 Bedroom
550
695
640
580
595
600
495
675
595
525
2 Bedroom
645
725
580
750
575
635
695
650
655
575
Set up and carry out an appropriate test to determine whether there
is convincing evidence that drinking coffee improves memory. Be
sure to provide the type of test used, the correct hypotheses, the
test statistic, the P-value, assumptions necessary (if any), and
the conclusions in context. Assume unequal variances in the
populations.
Then, provide and interpret a 99% confidence interval for the
hypotheses that you test in (a). What conclusion(s) do you make in
context?
In: Statistics and Probability
In: Operations Management
You are a manager of a sales team that travels often. Your responsibility is to approve expenses accrued during the trip.
Your job is to draft a travel expense policy that covers what employees can or cannot expense. Please draft a document that covers the following:
In: Operations Management