Questions
Please Why do we need a dynamic stack? How to implement a dynamic array stack?(JAVA)

Please

Why do we need a dynamic stack? How to implement a dynamic array stack?(JAVA)

In: Computer Science

In Python Dividing by zero is an example of which type of error? a. runtime b....

In Python

Dividing by zero is an example of which type of error?

a.

runtime

b.

syntax

c.

logic

d.

None of the previous

In the statement:age = input('Enter your age: '), the string 'Enter your age: ' is called a(n) _____.

a.

prompt

b.

prefix

c.

variable

d.

assignment

e.

None of the above

Fill in the blank so that the loop displays all odd numbers from 1 to 100.

i = 1
while i <= 100:
    print(i)
    i = _____

a.

1

b.

i + 1

c.

2

d.

i + 2

e.

None of the above

How many times does the following loop iterate?

i = 5
while i < 10:
    print(i)
    i = i + 1

a.

0

b.

4

c.

5

d.

6

e.

None of the above

In: Computer Science

Using the data structure concept of topological ordering,demonstrate using pseudocode how you can implement an operation...

Using the data structure concept of topological ordering,demonstrate using pseudocode how you can implement an operation to schedule picking during a delivery process in a warehouse.

In: Computer Science

Design a class named Person and its two subclasses named Student and Employee. Make Faculty and...

Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff subclasses of Employee. A person has a name, address, phone number, and e-mail address. A student has a class status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office, salary, and date hired. A faculty member has office hours and a rank. A staff member has a title. Override the toString method in each class to display the class name and the person’s name.

Write a test program that creates objects of Person, Student, Employee, Faculty, and Staff, and invoke their toString() methods.                  

In: Computer Science

Consider the following description of an enterprise. An auction Web site has items for sale that...

Consider the following description of an enterprise.

An auction Web site has items for sale that are provided by sellers. Each item has an opening price, a description, and ending time. Customers submit bids. The highest earliest bid submitted before the ending time is the winning bid and the item is sold to the bidder. Each seller must pay 5% of the winning bid. The auction company wants to be able to analyze the sales behavior of its customers and sellers and so must keep track of all bids and sales.

  1. What entity classes are mentioned in the description?
  2. List seven attributes that will be used in a data model for the auction company.
  3. What relationship types exist between the entity classes of part a?
  4. Give three example entities of each class listed in part a.

In: Computer Science

Is there any idea that what is the R formula for next ten days of weather...

Is there any idea that what is the R formula for next ten days of weather if you can advice

In: Computer Science

(To be written in Java code) A personal phone directory contains room for first names and...

(To be written in Java code)

A personal phone directory contains room for first names and phone numbers for 30 people. Assign names and phone numbers for the first 10 people. Prompt the user for a name, and if the name is found in the list, display the corresponding phone number. If the name is not found in the list, prompt the user for a phone number, and add the new name and phone number to the list.

Continue to prompt the user for names until the user enters quit. After the arrays are full (containing 30 names), do not allow the user to add new entries.

Use the following names and phone numbers:

Name Phone #
Gina (847) 341-0912
Marcia (847) 341-2392
Rita (847) 354-0654
Jennifer (414) 234-0912
Fred (414) 435-6567
Neil (608) 123-0904
Judy (608) 435-0434
Arlene (608) 123-0312
LaWanda (920) 787-9813
Deepak (930) 412-0991

This code was provided to start with:

import java.util.*;
class PhoneNumbers
{

public static void main (String[] args)

{

// write code here

}

}

In: Computer Science

The bits transmitted by four stations A, B, C and D are multiplexed using Code Division...

The bits transmitted by four stations A, B, C and D are multiplexed using Code Division Multiplexing (CDMA). Assume A transmits a 1 bit, B transmits a 0 bit, C transmits a 1 bit, and D is silent. Assume the following are the chip sequences of the four stations, answer below questions: SA = (-1 -1 -1 +1 +1 -1 +1 +1); SC = (-1 -1 +1 -1 +1 +1 +1 -1) SB = (-1 +1 -1 +1 +1 +1 -1 -1); SD = (-1 +1 -1 -1 -1 -1 +1 -1)

i) What is the transmitted sequence?

ii) Show how the receiver determines station B’s transmission.

In: Computer Science

In.java In this program write a method called upDown that takes three integers as arguments and...

In.java

In this program write a method called upDown that takes three integers as arguments and returns one of these 3 strings:

  • "increasing" if they are in strictly increasing order (note that 3,3,4 - are not strictly increasing),
  • "decreasing" if they are in strictly decreasing order.
  • "none" otherwise.
    I recommend you use a complex condition to check for this (that is, have a single if statement with one big question).

In the main method do the following:

  • read three integers from the user and call upDown for those integers, save the result in a variable, res1, and then print it.
  • read again three integers from the user and call upDown for those integers, save the result in another variable, res2, and then print it.
  • compare res1 and res2 and print "same" or "different"

read three integers from the user and call upDown for those integers, save the result in a variable, res1, and then print it.

---------- Sample run 1:
Enter three integers separated by spaces: 2 0 9
These numbers are in order: none
Enter three integers separated by spaces: 17 90 567
These numbers are in order: increasing
different

---------- Sample run 2:
Enter three integers separated by spaces: 90 9 1
These numbers are in order: decreasing
Enter three integers separated by spaces: 7 3 1
These numbers are in order: decreasing
same

---------- Sample run 3:
Enter three integers separated by spaces: 3 3 4
These numbers are in order: none
Enter three integers separated by spaces: 8 1 16
These numbers are in order: none
same

In: Computer Science

List two differences between Multi-Way Array Aggregation method and BUC method.

List two differences between Multi-Way Array Aggregation method and BUC method.

In: Computer Science

import java.util.Scanner; public class Lab5 { public static void main(String[] args) { final char SIDE_SYMB =...

import java.util.Scanner;

public class Lab5 {

public static void main(String[] args) {

final char SIDE_SYMB = '-';

final char MID_SYMB = '*';

Scanner scanner = new Scanner(System.in);

String inputStr = "";

char choice = ' ';

int numSymbols = -1, sideWidth = -1, midWidth = -1;

do {

displayMenu();

inputStr = scanner.nextLine();

if (inputStr.length() > 0) {

choice = inputStr.charAt(0);

}

switch (choice) {

case 'r':

System.out.println("Width of the sides?");

sideWidth = scanner.nextInt();

System.out.println("Width of the middle?");

midWidth = scanner.nextInt();

scanner.nextLine(); // Flush junk newline symbols

System.out.println();

System.out.println(buildRow(SIDE_SYMB, sideWidth, MID_SYMB,

midWidth));

break;

case 'p':

System.out.println("Number of symbols on the lowest layer?");

numSymbols = scanner.nextInt();

scanner.nextLine(); // Flush junk newline symbols

System.out.println();

System.out.println(buildPyramid(SIDE_SYMB, MID_SYMB, numSymbols));

break;

case 'd':

System.out.println("Number of symbols on the middle layer?");

numSymbols = scanner.nextInt();

scanner.nextLine(); // Flush junk newline symbols

System.out.println();

System.out.println(buildDiamond('*', ' ', numSymbols));

break;

case 'q':

System.out.println("Bye");

break;

default:

System.out.println("Please choose a valid option from the menu.");

break;

}

System.out.println();

} while (choice != 'q');

scanner.close();

}

/**

* Build a row of symbols (pattern) with the given parameters.

*

* For example, -----*****----- can be built by the parameters

*

* sideWidth = 5, midWidth = 5, sideSymb = '-', midSymb = '*'

*

* @param sideSymb A char to be repeated on both sides

* @param sideWidth Number of symbols on each side

* @param midSymb A char to be repeated in the middle

* @param midWidth Number of symbols in the middle

* @return A String of a row of the designed pattern

*/

private static String buildRow(

char sideSymb, int sideWidth, char midSymb, int midWidth) {

String result = "";

// YOUR CODE HERE

// Make one side

// -->

// Make the middle part

// -->

// Combine side + middle + side, save into "result"

// -->

return result;

} // End of buildRow

/**

* Build a pyramid pattern with the given parameters.

*

* For example, the following pattern

*

* -----*-----

* ----***----

* ---*****---

* --*******--

* -*********-

* ***********

*

* can be built by sideSymb = '-', midSymb = '*', numSymbols = 11

*

* When ptnHeight is not an odd integer, replace it by the closest

* even integer below. For example, if numSymbols is 10, use 9 instead.

*

* When ptnHeight is 0, return an empty String.

*

* @param sideSymb A char to be repeated on both sides

* @param midSymb A char to be repeated in the middle

* @param numSymbols The number of symbols on the lowest layer

* @return A String of the pyramid pattern.

*/

private static String buildPyramid(

char sideSymb, char midSymb, int numSymbols) {

String result = "";

int sideWidth = -1, midWidth = -1;

// YOUR CODE HERE

// If numSymbols is 0, return an empty string

// -->

// If numSymbols is not an odd number, find the

// odd number less than numSymbols and replace it

// -->

// Make a loop to iterate the pyramid's levels

for (????????????) {

// Compute the number of middle symbols

// -->

// Compute the number of symbols on one side

// -->

// Use the "buildRow" method to make a row, then

// add the row to the variable "result".

// You may need to add a linebreak char "\n".

// -->

}

return result;

}

/**

* Build a diamond pattern. The parameters are the same

* as {@link #buildPyramid(char, char, int)}.

*

* @param sideSymb A char to be repeated on both sides

* @param midSymb A char to be repeated in the middle

* @param numSymbols The height of a pyramid

* @return A String of the inverted diamond pattern.

*/

private static String buildDiamond(

char sideSymb, char midSymb, int numSymbols) {

String result = "";

// YOUR CODE HERE

// -->

return result;

}

/**

* Display the menu

*/

private static void displayMenu() {

System.out.println("Please choose one pattern from the list:");

System.out.println("r) Row");

System.out.println("p) Pyramid");

System.out.println("d) Shallow diamond");

System.out.println("q) Quit");

} // End of displayMenu

} // End of Lab5

Annotations

In: Computer Science

Consider the following Python function definition and determine what value will be returned by the 24....

Consider the following Python function definition and determine what value will be returned by the 24. function call that follows.

def calculate(value, src):

result = 0

val_string = str(value)

size = len(val_string)

mult = src ** (size - 1)

for digit in val_string:

d = int(digit)

result += d * mult

mult = mult // src

return result

calculate(93, 2)

In: Computer Science

Now we want to display which error was thrown in our voting program. Add the appropriate...

Now we want to display which error was thrown in our voting program.

Add the appropriate code to the try/except statement so the exception is displayed.
Run the program and, when prompted, enter the word 'old' so your output matches the output under Desired Output.

# Set the variable
age = input("What is your age?")

# Insert a try/except statement
# here when you convert the input
# to a number using int()
try:
age = int(age)
if age >= 18:
print("Go vote!")

except:
print("Please enter a valid age!")

Output :

invalid literal for int() with base 10: 'old'
Please enter a valid age!

We're still working with pie. Now we want to use the finally clause to display a message no matter what happens with our code.

Add the appropriate code to the try/except statement so that the message "Enjoy your pie!" is displayed regardless of the error caught (or not caught).
Run the program and, when prompted, enter the number 3 so your output matches the output under Desired Output.

# Get Input
pieces = input("How many pieces of pie do you want? ")

# Attempt to convert to integer
try:
percentage = 1/int(pieces)
except ValueError:
print("You need to enter a number!")
except:
print("Something went wrong!")
else:
print("You get", format(percentage, ".2%"), "of the pie!")

Output:

Enjoy your pie!
You get 33.33% of the pie!

both problems are python

In: Computer Science

In IOS store data. Each method has its strengths and weaknesses. Compare and contrast methods, and...

In IOS store data. Each method has its strengths and weaknesses. Compare and contrast methods, and give an example of an app (it doesn’t have to be a particular app, just an “app type”) that is appropriate for each type

In: Computer Science

Find L and U Using python3 programming language( using Doolittle's Decomposition method) 3X3 Matrices [4,-1,0],[-1,4,-1],[0,-1,4]

Find L and U Using python3 programming language( using Doolittle's Decomposition method)

3X3 Matrices

[4,-1,0],[-1,4,-1],[0,-1,4]

In: Computer Science