Without using method size(), write recursive method stackSize(Stack > s1 ) that receives a stack and returns number of elements in the stack. The elements in the stack should not be changed after calling this method. please do it in java
In: Computer Science
Assembly language: please comment on every line of code explaining each part. include head comments describing what your program does.
Assignment 3A - A program that adds and subtracts 32-bit
numbers
After installing the assembler on the computer, enter the following
program, save it, assemble it and run it. Do not forget to add a
comment with your name in it.
You will hand in a listing (e.g., addsum.asm) that should include
your name
________________________________________
TITLE Add and Subtract (AddSum.asm)
;This program adds and subtracts 32-bit integers
; Jonathan Borda
INCLUDE Irvine32.inc
.code
main PROC
mov eax, 10000h ; EAX =
10000h
add eax, 40000h ; EAX =
50000h
sub eax, 20000h ; EAX =
30000h
call DumpRegs ; display
registers
exit
main ENDP
END main
In: Computer Science
Write multiple if statements:
If carYear is before 1967, print "Probably has few safety
features." (without quotes).
If after 1971, print "Probably has head rests.".
If after 1992, print "Probably has anti-lock brakes.".
If after 2000, print "Probably has tire-pressure monitor.".
End each phrase with period and newline. Ex: carYear = 1995
prints:
Probably has head rests. Probably has anti-lock brakes.
public class SafetyFeatures {
public static void main (String [] args) {
int carYear;
carYear = 1968;
In: Computer Science
import java.lang.UnsupportedOperationException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// parse the number of strings
int numStrings = Integer.parseInt(sc.nextLine());
// parse each string
String[] stringsArray = new String[numStrings];
for (int i = 0; i < numStrings; i++) {
stringsArray[i] = sc.nextLine();
}
// print whether there are duplicates
System.out.println(hasDuplicates(stringsArray));
}
private static boolean hasDuplicates(String[] stringsArray) {
// TODO fill this in and remove the below line
int numWords =
}
}
In: Computer Science
**JAVA** Exercise
•Consider an input file of test scores in reverse ABC order:
Yeilding Janet 87
White Steven 84
Todd Kim 52
Tashev Sylvia 95...
•Write code to print the test scores in ABC order using a stack.
–What if we want to further process the tests after printing?
Thank you for any and all help! :)
In: Computer Science
Compare and contrast a fully relational DBMS with Excel in the
following areas.
1 Volume of data (number of rows)
2 Relationships of tables
3 Searching efficiency
4 Normalization
5 Update concurrency
In: Computer Science
22.8 LAB 5 D FALL 19 : Using math functions
This lab problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules.
We have given you some incomplete code; note that the very first line of that code contains an import statement as follows:
import math
This statement enables your program to use a math module. A module is a collection of instructions saved together as a whole. So, in this lab you are using the math module. Any time we choose to use a module, we must use an import statement to bring this module into the program. When we import the math module, all the computer instructions contained in the math module are made available to our program, including any functions that have been defined.
If you are interested in finding out what is in the math module you can always go to the Python docs and take a look: Python Docs
Example of using the math module: print(math.floor(5.4)) will use the floor() function as defined in the math module, and in this case with the argument 5.4, will result in printing the value 5.
Below is the definition of your problem that we are asking you to solve using the math module.
Prompt the user for floating point numbers x, y and z. For the x value your you will the use the following prompt Enter x value:inside of your input statement. Using the same approach you will prompt the user for y and z.
- Given three floating-point numbers x, y, and z,
your job is to output
- the **square root** of x,
- the **absolute value** of (y minus z) , and
- the **factorial** of (the **ceiling** of z).
Example of a sample run:
Enter x value:5 Enter y value:6.5 Enter z value:3.2
Then the expected output from these entries is:
2.23606797749979 3.3 24
Hint: For finding out the square root you will need to use math.sqrt(), you need to use the website recommended above to find out which functions to use in order to solve the rest of the lab problem.
In: Computer Science
16) Define a 3 to 8 active low decoder. Which number is the input and which is the output? Is 8 related to 3? Explain.
17) Define a 8 to 1 multiplexer. Which number is the input and which is the output? Is 8 and 3 are the only numbers or there are other set(s) of numbers? Explain.
20) Design a combinational circuit that has two ASCII inputs and generates “1”only if the two ASCII are equivalent.
8) Define an Overflow condition.
In: Computer Science
use the web to identify the cost of hardware, software, and networking conponents for an RFID sysyem for company?
In: Computer Science
Nested Loops
Problem 3
Write a function called makesentence() that has three parameters: nouns, verbs, and gerunds. Each parameter is a list of strings, where nouns list has noun strings (such as 'homework'), verbs list has veb strings (such as 'enjoy'), and gerunds list has gerund strings (those -ing words, such as 'studying'). The function will go through all these lists in a systematic fashion to create a list of all possible sentences that use all the noun, verb, and gerund strings. The function then returns the list of sentences.
Each sentence has the following format: 'I' followed by a verb, followed by a noun, followed by 'when ', followed by a gerund, exactly in this order.. For example: 'I enjoy homework when studying' uses the noun 'homework', verb 'enjoy', and gerund 'studying'.
Consider that we have the following lists:
some_nouns = ['homework', 'music', 'breaks']
some_verbs = ['enjoy', 'ignore']
some_gerunds = ['studying', 'sleeping', 'hiking']
After we write the function definition, we call the function, save its return value in the variable result, and print out the result:
result = makesentence(some_nouns, some_verbs, some_gerund)
print(result)
The output of obtained from the call above is:
['I enjoy homework when studying', 'I enjoy homework when sleeping', 'I enjoy homework when hiking', 'I enjoy music when studying', 'I enjoy music when sleeping', 'I enjoy music when hiking', 'I enjoy breaks when studying', 'I enjoy breaks when sleeping', 'I enjoy breaks when hiking', 'I ignore homework when studying', 'I ignore homework when sleeping', 'I ignore homework when hiking', 'I ignore music when studying', 'I ignore music when sleeping', 'I ignore music when hiking', 'I ignore breaks when studying', 'I ignore breaks when sleeping', 'I ignore breaks when hiking']
Part A Think about how to solve this problem and the computational steps of your solution BEFORE you write the Python code. Explain (1) what computations you’ll instruct Python and (2) why. Write your explanations in the order in which the computations should occur.
Part B
#1 Using the explanations of the computational steps of your solution, in an Active Code scratchpad, write the implementation. The implementation has the following structure: your function definition, followed by the three list assignments, followed by the function call and print() call, as follows:
[ your function definition goes in here ]
some_nouns = ['homework', 'music', 'breaks']
some_verbs = ['enjoy', 'ignore']
some_gerunds = ['studying', 'sleeping', 'hiking']
result = makesentence(some_nouns, some_verbs, some_gerund)
print(result)
Copy and paste the code of your function definition
Copy and paste the output you get when you run & save your code
Part C
#1 What was the most challenging while solving Problem 3?
#2 Why?
In: Computer Science
Describe a polynomial time algorithm to solve following problem
Input: A boolean function in CNF such that each clause has exactly three literals.
Output: An assignment of the variables such that each clause has all TRUE literals or all FALSE literals.
In: Computer Science
Digital Forensics, Please describe in detail in your own language
Describe Linux their artifacts and their functionalities.
How they might be used by forensic examiners?
In: Computer Science
This maze project assumes that a cell is rectangular, and that there is an entrance into and an exit from the cell. What if the entrance and the exit were closed doors and the user was to choose which door leads to the next cell? What would be some pseudocode for this scenario?
Notice that " switch case " statements are used for this project along with " if " statements. Can they be interchanged and still produce the same results [ i.e., make the switch case statements into if statements, and the if statements into switch case statements ] ? Support your answer!
Reference source code for more information:
public class Maze
{
static Scanner sc = new Scanner(System.in);
// maze movements
static char myMove = '\0';
// cell position
static int currentCell = 0;
static int score = 0;
static boolean advance = true;
static boolean checkThis = false;
public static void main(String args[])
{
// the local variables declared and initialized
char answer = 'Y';
displayMenu();
while(answer == 'Y' || answer == 'y')
{
displayMovement();
makeYourMove();
checkThis = checkYourMove();
mazeStatus();
System.out.println("move again(Y or N)?");
answer = sc.next().charAt(0);
}
System.out.println("***************************");
}// end main() method
static void displayMenu()
{
System.out.println("");
System.out.println("***************************");
System.out.println("----The Maze Strategy---");
System.out.println("");
}// end method
static void displayMovement()
{
if(currentCell == 0)
{
System.out.println("You have entered the maze!!");
System.out.println("There is no turning back!!");
currentCell = 1;
mazeStatus();
advance = true;
}
System.out.println("make your move (W, A, S, D)");
System.out.println("W = up, A = left, S = down, D = right)");
}// end method
static void makeYourMove()
{
myMove = sc.next().charAt(0);
score++;
switch(myMove)
{
case 'W': { MoveUp(); break; }
case 'A': { MoveLeft(); break; }
case 'S': { MoveDown(); break; }
case 'D': { MoveRight(); break; }
}
// end program menu
}// end method
static boolean checkYourMove()
{
if(currentCell == 1 && advance == true)
{
if (myMove == 'W')
{
advance = false;
System.out.println("try again");
return advance;
}
if (myMove == 'A')
{
advance = false;
System.out.println("SORRY, there is no return");
return advance;
}
if (myMove == 'D')
{
currentCell = 2;
advance = true;
System.out.println("continue through the maze");
return advance;
}
if (myMove == 'S')
{
advance = false;
System.out.println("continue through the maze");
return advance;
}
}
return advance;
// end program menu
}// end method
static void MoveLeft()
{
System.out.println("you moved to the left");
}// end method
static void MoveRight()
{
System.out.println("you moved to the right");
}// end method
static void MoveUp()
{
System.out.println("you moved up (forward)");
}// end method
static void MoveDown()
{
System.out.println("you moved down (downward)");
}// end method
static void mazeStatus()
{
System.out.println("current position: cell " + currentCell);
}// end method
}// end class
In: Computer Science
Information Security
-Why are modes of operation needed for block ciphers like AES?
In: Computer Science
If the action is Balance 'B’, use a print balance function to return and print an account balance. You will need to write a function called printbalance.
a. Create a prompt for the user to input the account action. There are three possible actions:
| Code | Action | Function |
|---|---|---|
| D | Deposit | deposit_amount |
| W | Withdrawal | withdrawal_amount |
| B | Account Balance | account_balance |
Create a function to print the account_balance, print the account actions and create the action for outputting the account balance outputting.
Input Information
The following data will be used as input in the test:
userchoice = input ("What would you like to do?")
userchoice = 'B'
Output Information
Your current balance: 500.25
import sys# importing the sys library
# account balance
account_balance = float(500.25)
#PPrint the balance
# This is a custom function, it returns the current balance upto 2
decimal places
def printbalance():
print("Your current balance : %2f" % account_balance)
#the function for deposit
#This is a custom function
def deposit():
deposit_amount = float(input("Enter amount to deposit : ")) # takes
in input for deposit amount
balance = account_balance + deposit_amount #calculates
balance
print("Deposit was $%2f, current balance is $%2f" %(deposit_am
ount,balance)) # prints out the balance
#function for withdraw
#this is a custom function
def withdraw():
withdraw_amount = float(input("Enter amount to withdraw")) # takes
in the withdraw amount
if(withdraw_amount > account_balance): #checks whether the
amount is more than balance or not
print("$%2f is greater than account balance $%2f\n"
%(withdraw_amount,account_balance)) #if yes then
print wd amount greater than balance
else:
balance = account_balance - withdraw_amount
print("$%2f was withdrawn, current balance is $%2f" %
(withdraw_amount, balance))
# User Input goes here, use if/else conditional statement to call
function based on user input
userchoice = input("What would you like to do?\n")
if (userchoice == 'D'):
# here deposit function is called
deposit()
elif userchoice == 'W':
# here withdraw function is called
withdraw()
elif userchoice == 'B':
# here printbalance function is called
printbalance()
else:
# it ends the program execution
sys.exit()
In: Computer Science