looking for answer in java language week7
Submission Task (Use of ArrayList with Wrapper Double Class): Write a program to add scores of students. Ask the user to keep entering until the user types '0' to stop entering any more. The program should store the scores into an ArrayList. At the end: First display all the scores entered, Then sort the list using Collections.sort(name of the list) Display the sorted list.

Answers

Answer 1

Here is the Java program that adds scores of students and stores them into an ArrayList:

```import java.util.*;public class Main { public static void main(String[] args) { ArrayList scores = new ArrayList(); Scanner input = new Scanner(System.in); double score = 1.0; while (score != 0) { System.out.print("Enter score (type '0' to stop entering): "); score = input.nextDouble(); if (score != 0) { scores.add(score); } } System.out.println("Scores entered: " + scores); Collections.sort(scores); System.out.println("Sorted scores: " + scores); }}```

How to use the above program?

The program will prompt the user to enter scores of students until they type 0. Then, the program will store all the scores into an ArrayList.

Finally, it will display all the scores entered and the sorted list of scores. To use this program, you can simply copy-paste it into an IDE such as Eclipse or NetBeans and run it. You will see the output in the console.

Learn more about public class at

https://brainly.com/question/13102960

#SPJ11


Related Questions

Write ARM assembly code to implement the following
expressions.
(i) y=a+b-c
(ii) y=(a<<3) | (b&15);
(iii) switch (R0) {
case 0: S0; break;
case 1: S1; break;
case 2: S2; break;
default: err;

Answers

Here's an ARM assembly code to implement the following `default: err;`:``` LDR r0, =err BX lr ```

In the code snippet above, the value of `err` is loaded into the `r0` register. Then, the `BX lr` instruction returns control to the calling function.

(i) y=a+b-c

Let us break this expression down in parts:a+b-c can be written as (a+b)-c

Now, let's consider the following ARM assembly code:

ADD r3, r0, r1 ; r3=a+bSUB r3, r3, r2 ; r3 = a+b-c

Here, r0, r1, and r2 are the registers that hold the values of variables a, b, and c, respectively.

(ii) y=(a<<3) | (b&15);To implement this expression, we must first left-shift the value of a by three bits and perform a bitwise OR operation with the least significant four bits of the value of b. Here's the corresponding ARM assembly code: LSL r3, r0, #3 ; r3 = a<<3AND r2, r1, #15 ; r2 = b&15ORR r3, r3, r2 ; r3 = (a<<3) | (b&15)Here, r0, r1, r2, and r3 are the registers that hold the values of variables a, b, and y, respectively.

(iii) switch (R0) {case 0: S0; break;case 1: S1; break;case 2: S2; break;default: err;The given code snippet represents a switch statement.

Depending on the value of the register R0, one of the cases will be executed. If R0 contains the value 0, S0 will be executed. If it contains the value 1, S1 will be executed, and so on. If R0 does not match any of the cases, the default block will be executed.

Learn more about  program code at

https://brainly.com/question/33209067

#SPJ11

To obtain a JTable field's name, the correct statement to use is: A AbstractTableModel getColumnName(Columnindex + 1) 8. ResultSet getColumnName(Columnindex + 1) C JTable getColumnName(Columnindex + 1) D. ResultSetMetaData.columnName(Columnindex +1) E JTable columnName(Columnindex + 1) 10. To notify a JTable that the table has changed, one of the following statements achie A tableDataChanged(?) B. itemStateChanged(?) C. data TableChanged(?) D valueChanged(7) E fire TableStructureChanged() 11. To create a static thread-pool & a pool manager, a programmer would write: A ThreadPool.create(10) B. Executors.newFixed ThreadPool(10) C. ExecutorService.newCachedThreadPool() D. Thread newCachedThreadPool() E. ExecutorService.createCached ThreadPool() 12. How to programmatically enable thread "B" to suspend its execution and wait for thread " assuming that "B" has executed "A"? A. B.notify B.B.wait() C.B.join() DA join() E. Condition await() 13. To release the monitor-lock of an object "A", the following statement should be invoked by t A Condition signall) Condition await) C. Aawait) D. A unlock() E. A notify 14. In order to obtain the result of a task-processing by a thread, a programmer would need to en A Executors 8. Callable C Runnable D. Thread E ExcutorService 15. If a thread attempts to access a "synchronized" method and access to the method can not be the is A Runnable B. Waiting C. Timed Waiting D. Blocked E Suspended 16. Which statement of the following list would schedule the task "long Factorial(int x)" by thread A. A start) B new Thread(A) C. A.call() D. ExecutorService execute(A) E ExecutorService submit(A) 17. How to obtain a remote web client's logical address?: A HttpServletRequest getClientAddress 8. HttpServletRequest getRemoteHost) C.HttpServietRequest getRemoteAddr) D. HitpServletResponse.getClientAddress( E. HttpServletResponse.getRemoteAddr) 2

Answers

To obtain a JTable field's name, the correct statement to use is: C. JTable getColumnName(Columnindex + 1)To notify a JTable that the table has changed, one of the following statements achieves:

A. To create a static thread-pool & a pool manager, a programmer would write: B. Executors.newFixedThreadPool(10)How to programmatically enable thread "B" to suspend its execution and wait for thread "A" assuming that "B" has executed "A"?B. B.wait()To release the monitor-lock of an object "A", the following statement should be invoked by the thread that acquired it: D. A unlock()In order to obtain the result of a task-processing by a thread, a programmer would need to employ:

B. CallableIf a thread attempts to access a "synchronized" method and access to the method cannot be obtained, the thread is: D. BlockedThe statement that would schedule the task "long Factorial(int x)" by thread is: D. ExecutorService execute(A)To obtain a remote web client's logical address, HttpServletRequest getRemoteAddr() should be used. Answer: C. HttpServletRequest getRemoteAddr)

To know more about monitor-lock visit:

https://brainly.com/question/32420716

#SPJ11

Must at least read or write to a file • Must utilize at least a list or dictionary • Must incorporate user input • Must utilize functions to make code organized and efficient • Must utilize at least ifs or loops

Answers

An example of a Python program that incorporates the mentioned requirements to take login information (username and password) from the user -

def read_credentials():

   credentials = {}

   with open('login_info.txt', 'r') as file:

       for line in file:

           username, password = line.strip().split(',')

           credentials[username] = password

   return credentials

def write_credentials(username, password):

   with open('login_info.txt', 'a') as file:

       file.write(f'{username},{password}\n')

def login():

   credentials = read_credentials()

   username = input("Enter your username: ")

   password = input("Enter your password: ")

   

   if username in credentials and credentials[username] == password:

       print("Login successful!")

   else:

       print("Invalid credentials.")

def register():

   username = input("Enter a username: ")

   password = input("Enter a password: ")

   

   write_credentials(username, password)

   print("Registration successful!")

# Main program

while True:

   choice = input("Choose an option (login/register/exit): ")

   

   if choice == "login":

       login()

   elif choice == "register":

       register()

   elif choice == "exit":

       break

   else:

       print("Invalid choice. Please try again.")

How does this work?

- The login information is stored in a file called "login_info.txt" in the format `username,password`.

- The `read_credentials()` function reads the credentials from the file and returns them as a dictionary.

- The `write_credentials()` function appends new credentials to the file.

- The `login()` function asks the user for their username and password and checks if they match the stored credentials.

- The `register()` function asks the user to enter a new username and password and saves them to the file.

- The main program uses a while loop to repeatedly prompt the user for options (login, register, or exit) and calls the respective functions based on the choice.

Learn more about User Input at:

https://brainly.com/question/30195673

#SPJ4

Full Question:

Although part of your question is missing, you might be referring to this full question:

In Python Create A Program That Takes Login Information (Username And Password) Please Make Sure All In The Picture Below Is Utilized

in python create a program that takes login information (username and password) please make sure all in the picture below is utilized

Must at least read or write to a file • Must utilize at least a list or dictionary • Must incorporate user input • Must utilize functions to make code organized and efficient • Must utilize at least ifs or loops

Assume a String variable named linel has been declared. Write a statement that declares a Scanner object associated with a file named "poem". Then, write another statement that uses the Scanner object to read the first line from the file and stores it in line1. (Do not use a try statement here. Simply write the two lines of code.)

Answers

The code declares a `Scanner` object associated with a file named "poem" and reads the first line from the file into a `String` variable named `line1`.

Scanner scanner = new Scanner(new File("poem"));

String line1 = scanner.nextLine();

The code initializes a `Scanner` object by passing the `File` object representing the "poem" file to its constructor. The `File` object represents a file on the system. Then, the `nextLine()` method is called on the `Scanner` object to read the next line from the file, and the returned line is stored in the `line1` variable of type `String`. This allows access to the content of the first line of the file for further processing or display.

To know more about String variable, click here: brainly.com/question/31751660

#SPJ11

What are the best data structures to create the following items? And why?
1. Designing a Card Game with 52 cards.
2. Online shopping cart (Amazon, eBay, Walmart, Cosco, Safeway....)
3. Online waiting list (De Anza College class waiting list, ...)
4. Purchasing online Tickets (Flight tickets, concert tickets, ...) (=> Fixed-size <=)

Answers

For designing a card game with 52 cards, the best data structure is a stack, For an online shopping cart, the best data structure is a list,  For an online waiting list, the best data structure is a queue, For purchasing online tickets with a fixed size, the best data structure is an array.

1.

The stack data structure is used here.

A stack is a data structure that operates on the principle of Last In First Out (LIFO). In a card game, the deck of cards is shuffled, and then each player takes turns drawing a card from the top of the deck. In order to simulate this, we can use a stack where each card is pushed onto the top of the stack and each player pops a card from the top of the stack.

2.

Here list data structure is used.

A list is a dynamic collection of elements that maintains their order and allows for the addition or removal of elements as needed.In an online shopping cart, items are added to the cart and then the user can choose to remove them or proceed to checkout. A list can easily handle these operations.

3.

Here queue data structure is used.

A queue is a data structure that operates based on the principle of First In First Out (FIFO). In an online waiting list, users are added to the list in the order that they joined, and are served in that order as well. A queue is the ideal data structure for this.

4.

Here array data structure is used.

An array is a data structure that stores elements of the same type in a sequence, occupying adjacent memory locations.Since the number of tickets is fixed, an array can be used to store information about each ticket, such as the ticket type, price, and availability.

To learn more about data structure: https://brainly.com/question/29585513

#SPJ11

PYTHON LIST OF DICTIONARIES PROBLEM
I've been having trouble extracting multiple specific key:value pairs from a list of dictionaries in my code. I will write an example code below:
data_set = [{'diet': 'fruit': 'Apple', 'vegetable': 'Carrot', 'meat': 'Steak', 'starch': 'Rice, 'date': '2022-03-26', 'count': '50'}]
Lets say I would like to:
1. extract the key:value pairs for diet, fruit, meat, count
2. add those key:value pairs to a new dictionary
3. print the new dictionary
4. extract and print the value of 'diet' if the value of 'count' is >= 25 from the new dictionary
How would I code for this?

Answers

The Python code has been written in the space that we have below

How to write the python code

data_set = [

   {'diet': 'fruit', 'fruit': 'Apple', 'vegetable': 'Carrot', 'meat': 'Steak', 'starch': 'Rice', 'date': '2022-03-26', 'count': '50'}

]

# Step 1: Extract specific key-value pairs

keys_to_extract = ['diet', 'fruit', 'meat', 'count']

new_dict = {key: data_set[0][key] for key in keys_to_extract}

# Step 2: Print the new dictionary

print("New Dictionary:")

print(new_dict)

# Step 3: Extract and print the value of 'diet' if the value of 'count' is >= 25

if int(new_dict['count']) >= 25:

   print("\nValue of 'diet' when count is >= 25:")

   print(new_dict['diet'])

Read mroe on Python codes here https://brainly.com/question/26497128

#SPJ4

Write a C++ program that calls a function to print out hello world ten times using a for loop

Answers

To write a C++ program that calls a function to print out hello world ten times using a for loop, we can follow the steps below:Step 1: First, we create a function named printHello() which will print "Hello World" on the console window.

To print "Hello World" ten times, we can use a for loop inside the function. The function will be as follows: void printHello() { for(int i = 1; i <= 10; i++) { std::cout << "Hello World" << std::endl; } }

Step 2: Next, we create the main function which will call the printHello() function ten times using another for loop. The main function will be as follows: int main() { for(int i = 1; i <= 10; i++) { printHello(); } return 0; }

Step 3: Finally, we compile and run the program to see the output. Here's the complete C++ program that calls a function to print out hello world ten times using a for loop.

In the above program, the printHello() function is used to print "Hello World" ten times using a for loop. The main function is used to call the printHello() function ten times using another for loop. This program will print "Hello World" ten times on the console window.

To know more about program visit:-

https://brainly.com/question/30613605

#SPJ11

Briefly answer:
b) Explain why genetic algorithm does not guarantee that a global optimal solution will be found.
c) But, why is genetic algorithm useful? In other words, describe in general situations in which a genetic algorithm may be better than nonlinear or integer programming.
d) In general why cant a genetic algorithm cope with a large number of constraint?

Answers

The genetic algorithm does not guarantee finding a global optimal solution due to its reliance on random variations and selection processes, which can result in suboptimal solutions or getting stuck in local optima. However, it remains useful in complex optimization problems, especially when dealing with nonlinearities, combinatorial optimization, and situations where traditional approaches like nonlinear or integer programming may be less effective.

b) Genetic algorithms do not guarantee finding a global optimal solution because they work based on the principles of natural evolution, using random variations and selection processes that may lead to suboptimal solutions or get stuck in local optima.

c) Despite not guaranteeing a global optimal solution, genetic algorithms are useful in various situations. They excel in complex, nonlinear, and combinatorial optimization problems where traditional approaches like nonlinear or integer programming may struggle. Genetic algorithms can handle large solution spaces, diverse constraints, and nonlinearity effectively, making them suitable for problems with multiple objectives or when the search space is not well-defined.

d) However, genetic algorithms may face challenges when dealing with a large number of constraints. As the number of constraints increases, it becomes more difficult to find feasible solutions that satisfy all the constraints simultaneously. The search space expands, making it harder for the algorithm to explore and converge towards valid solutions efficiently.

This can lead to longer computation times and lower success rates in finding feasible solutions for highly constrained problems. Therefore, alternative optimization methods or techniques that specifically address constraint handling may be more suitable in such cases.

To learn more about Genetic algorithms, visit:

https://brainly.com/question/28566003

#SPJ11

Please change this code's "if" and "ands" statements and make the code as different as possible without the code loosing it's functionality.
// include the library code:
#include
// Initialize library by way of pin interface
// Elego uno pin number
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
int adl_switch = 6; //switch 6
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
Serial.begin(9600);
lcd.begin(16, 2); // thisn is the LCD's number of columns and row:
pinMode(adl_switch, INPUT_PULLUP); //this indicates internal plug rssitor
}
void loop() {
//Switch on
if (digitalRead (adl_switch) == LOW)
{
lcd.setCursor(0, 0);
lcd.print("Adl Switch");
lcd.setCursor(6, 0);
lcd.print("Adl switch ON ");
}
//code for button inputs when off
if (digitalRead (adl_switch) == HIGH)
{
lcd.setCursor(0, 0);
lcd.print("Switch");
lcd.setCursor(6, 0);
lcd.print(" Off");
}
//this is where my pot is connected, analog pin:
int sensorValue = analogRead(A0);
//equation to convert the input from 0-1023 to a voltage value
float voltage = sensorValue * (5.0/1023.0);
lcd.setCursor(0, 1);
lcd.print("V= V");
lcd.setCursor(2, 1);
lcd.print(voltage);
//this section is to print the position of the switch
if (digitalRead (adl_switch) == HIGH){
Serial.print("digital = 0");
}else{
Serial.print("digital = 1");
}
Serial.print(" ");
Serial.print("analog = ");
Serial.println(voltage);
delay(50);
}

Answers

The given code can be modified by modifying the if and else if statements of the given code. The modification of if and else if statement will make the code different but the functionality of the code will remain the same.

The modified code is as follows:Modifying the code by changing "if" and "else if" statements:#include const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;int adl_switch = 6;LiquidCrystal lcd(rs, en, d4, d5, d6, d7);void setup() {Serial.begin(9600);lcd.begin(16, 2);pinMode(adl_switch, INPUT_PULLUP);}void loop() {//Switch onswitch(digitalRead(adl_switch)){case LOW:lcd.setCursor(0, 0);lcd.print("Adl Switch");lcd.setCursor(6, 0);lcd.print("Adl switch ON ");break;case HIGH:lcd.setCursor(0, 0);lcd.print("Switch");lcd.setCursor(6, 0);lcd.print("

Off");break;default:break;}int sensorValue = analogRead(A0);float voltage = sensorValue * (5.0 / 1023.0);lcd.setCursor(0, 1);lcd.print("V= V");lcd.setCursor(2, 1);lcd.print(voltage);if(digitalRead(adl_switch) == HIGH){Serial.print("digital = 0");}else{Serial.print("digital = 1");}Serial.print(" ");Serial.print("analog = ");Serial.println(voltage);delay(50);}The above given modified code is functionally same as the original code but the statements used are different and unique.

To know more about code visit:-

https://brainly.com/question/17204194

#SPJ11

The YOLO network detects bounding boxes. Some objects can appear large in the image while others appear small. The loss function for YOLO appears below. How does this ensure that large bounding boxes do not get excessive emphasis compared to those for small bounding boxes? Are there any shortcomings of this solution? [3 marks] s² B Acoord ΣΣ¹% [(x₁ − âi)² + (yi − ŷi)²] i=0 j=0 + Acmet Σ ≤ 1″ [(√wi – √wi)² + (√ñ – √ñ)²] s2 B obj +ΣΣ1%j (c-c)* i=0 j=0 s² B noobj + Anocbj 1 (C₁-C₁) ² ΣΣ1" Fij i=0 j=0 82 obj + Σ1 Σ (pi(c) – pi(c))2 ΣΕΣ i=0 ceclasses

Answers

The loss value of YOLO involves multiple terms that jointly impact the loss function.

What is the  loss function?

Bounding Box Coordinates Loss: In the loss function, the initial component is responsible for measuring the disparity between the anticipated and actual bounding box coordinates (x, y) and (â, ŷ), respectively.

The method utilizes the square of the Euclidean distance [(x₁ - âi)² + (yi - ŷi)²] to estimate the difference in the anticipated and actual positions. The overall loss calculation accounts for the total differences of all bounding boxes, which is expressed as the sum of squared deviations of horizontal and vertical coordinates (ΣΣ¹%[(x₁ - âi)² + (yi - ŷi)²])

Learn more about  loss function  from

https://brainly.com/question/32616739

#SPJ4

For the following CFG, perform CKY-parsing and derive ALL possible parse trees for the string "baaaaba".
S -> AB | BC
A -> BA | a
B -> CC | b
C -> AB | a

Answers

The CKY-parsing algorithm is a type of bottom-up parsing. It uses a dynamic programming approach to discover if a string belongs to a particular context-free language, and if so, it discovers the syntactic structure of the string.

Here are the steps to perform CKY-parsing:

1: Create a chart with cells representing all possible substrings of the input string and nonterminals that can generate each substring. Initialize the cells on the diagonal with the nonterminals that generate the corresponding input symbol. 2: Fill in the cells on the chart in a diagonal order, starting from the top-right and working your way to the bottom-left. 3: If the top-right cell contains the start symbol of the grammar, then the input string is accepted. Otherwise, it is not

.For the given context-free grammar, here is how we can perform CKY-parsing:

1: Create the chart and fill in the diagonal cells with the nonterminals that generate the corresponding input symbols: 2: Fill in the rest of the cells using the CKY algorithm: 3: The top-right cell contains the start symbol "S", which means that the input string "baaaaba" is generated by the grammar.

Learn more about parse trees at

https://brainly.com/question/31429003

#SPJ11

All employees are to pay 15 % of their gross as INCOME TAX and 5% towards the NHIS. An employee has to pay 2 cedis per towards GETFUND. Draw the flow chart and write a C++ software solution that accept the appropriate input and also output an employee's gross pay, various deduction (INCOME TAX, NHIS, GETFUND) and the NET PAY with appropriate caption. (You are required to use user-defined functions for all the outputs and the deductions). CR(20) b) Using flowcharts explain the structure of a loop block in computer programming EV(5) TOTAL(25) Question 2 a). Draw the flow chart and write a C++ software for a solution that can solve the problem.below. Σ1 α, n Where a = {a1,2,3,...an} CR( 15 marks b) Convert the following while loops into for loops i. int i = 1; while (i <= 10) { if (i <5 && i !=2) cout<< "X": i++; } ii. int i = 1; while (i <= 10) { cout<<"X": i = i +3; } c) Using flow charts and syntaxes only, identify and explain the i. Difference between the do while and the while loop control structures or block ii. Similarities between the cascaded if statement and the switch statement EV(5) O TOTAL [25] )

Answers

The given task requires the development of a C++ software solution that calculates an employee's gross pay, deductions for income tax, NHIS, and GETFUND, and provides the net pay.

The solution should use user-defined functions for the calculations and incorporate flowcharts for visual representation. Additionally, the question includes converting while loops into for loops and explaining the differences and similarities between the do-while loop and the while loop control structures, as well as the cascaded if statement and the switch statement.

To complete the task, a C++ program needs to be developed that accepts inputs for the employee's gross pay, calculates the deductions for income tax (15%), NHIS (5%), and GETFUND (2 cedis), and outputs the gross pay, deductions, and net pay. User-defined functions can be created to handle the calculations and return the results. Flowcharts can be used to represent the program's structure and flow of execution.

For the second part of the question, while loops can be converted into for loops by defining the initialization, condition, and increment/decrement statements within the for loop syntax. The given while loops can be rewritten accordingly.

In terms of explaining the differences between the do-while and while loop control structures, and the similarities between the cascaded if statement and the switch statement, flowcharts can be used to illustrate the flow of control and decision-making processes in each structure. The syntax and functionalities of these structures can be explained to highlight their similarities and differences.


To learn more about software click here: brainly.com/question/32393976

#SPJ11

I'm not sure how to code this, the person in the previous question which connects to this says to draw code from the textbook and etc but i'm not sure which one. Can I get help coding this?

Answers

Some general tips on how to approach coding problems:

1. Start by breaking the problem down into smaller steps or tasks. This will make it easier to tackle the problem one piece at a time and ensure that you don't miss anything important.

2. Use pseudocode to outline your approach before you start coding. Pseudocode is like a rough draft of your code that you write in plain English (or any language you're comfortable with). It should include all the steps or tasks you identified in step 1.

3. Use comments in your code to explain what you're doing at each step. This will make it easier for someone else (or your future self) to understand your code.

4. Test your code frequently as you write it. Don't wait until you've finished writing the entire program to test it. Test each section or module of code as you write it to make sure it's working as expected.

5. If you get stuck or are unsure how to proceed, consult your textbook or other resources for examples or guidance. Don't be afraid to ask for help from your instructor or classmates.

When you're not sure how to code something, start by breaking the problem down into smaller steps, use pseudocode to outline your approach, use comments in your code, test your code frequently, and consult your textbook or other resources when you need help.

To know more about coding problems visit:-

https://brainly.com/question/27274441

#SPJ11

What type of database does Netflix use? Why was this type of storage used? What challenges did they face? Use other resources along with the case study. Did other streaming services have the same challenges (Hulu, Amazon, HBO, etc.)?

Answers

Netflix uses a distributed database that is managed by Apache Cassandra, an open-source, NoSQL, column-family-based storage system. The company chose Cassandra as its storage platform to support its massive volumes of data and to be able to scale horizontally while keeping costs low.

Cassandra allows Netflix to maintain a large volume of data spread across several servers, ensuring quick read and write operations. It is also highly available, fault-tolerant, and can handle large data sizes while ensuring the system’s stability. Netflix can also use Cassandra to maintain a seamless experience for customers by eliminating downtime and enabling zero-downtime operations. Netflix also relies on Amazon Web Services (AWS) to maintain the necessary infrastructure for Cassandra, including database replication and backups. As Netflix grew, it faced several challenges, such as maintaining the consistency of the database, dealing with frequent outages, and managing data at scale.

To address these challenges, the company began to use automated failover systems, developed its own toolkits for backups, and implemented a data pipeline to handle the ingestion and processing of large data sets. Other streaming services have faced similar challenges, but not all of them use Cassandra. For example, Hulu uses Amazon’s Relational Database Service (RDS) for MySQL and PostgreSQL to store its data, while Amazon Prime Video relies on its own NoSQL-based storage system, Amazon DynamoDB.

To know more about database visit:-

https://brainly.com/question/6447559

#SPJ11

Your computer has some files. For this problem, it is confirmed that all filenames are of equal length and will be in lowercase.
You have to write a program to find a common pattern of these filenames.
A pattern can contain letters ('a'-'z'), '.' character, and '?' character only, and nothing else.
Each '?' matches any single character (including '.'), and all other characters match themselves only. For example, the pattern "conte?t.info" matches the filenames "contest.info" and "content.info", but not "contemn.info" or "contests.nfo".
Two Sample Inputs
contest.txt context.txt
config.sys config.inf configures
Two Sample Outputs
conte?t.txt
config????

Answers

The following is the Python program to find the common pattern of filenames provided that they are of equal length and in lowercase:

filenameList = input().split()filenameLength = len(filenameList[0])result = ""for i in range(filenameLength): currentChar = filenameList[0][i] for j in range(1, len(filenameList)): if currentChar != filenameList[j][i]: result += "?" break else: result += currentCharif "." in result: result = result.replace(".", "\.") if "?" in result: result = result.replace("?", ".")print(result)

The program starts by taking the input filenames as a string and splits them using the space character as the delimiter. The program then gets the length of the first filename and initializes the result string.The program then loops through each character in the first filename and assigns the current character to the variable currentChar.

The program then loops through the other filenames and checks if the current character is the same as the corresponding character in the other filenames. If the current character is the same in all filenames, the program appends it to the result string. Otherwise, it appends the "?" character to the result string.

The program then checks if the result string contains the "." character. If it does, it replaces it with "\." using the replace() function. If the result string contains the "?" character, it replaces it with "." using the replace() function.The program then prints the final result, which is the common pattern of the filenames.

Learn more about python code at

https://brainly.com/question/33209106

#SPJ11

23. By first calculating the CRC required, show how a 4b CRC based on the polynomial x¹+x+1 would protect the data string 0101101000111100 from a 2bit error (you may pick any two bits to be in error)

Answers

To protect it from a 2-bit error, we need to use a 4-bit cyclic redundancy check (CRC) based on the polynomial x¹+x+1.

The first step is to append a 4-bit zero string (0000) to the end of the original data string, as the degree of the CRC is 4.

So, the augmented message is 01011010001111000000.

The polynomial generator is x^4+x^3+x+1.

This is because the degree of the generator polynomial is 4. Therefore, it has four terms. To find the CRC, we need to perform modulo-2 division. The divisor is the generator polynomial. In this example, the dividend is the augmented message and the divisor is x^4+x^3+x+1. The dividend should be divided by the divisor.

The remainder is the CRC.

To start the modulo-2 division, we should align the highest term of the dividend with the highest term of the divisor, as shown below.

01011010001111000000|x^4+x^3+x+1

We perform the first division by bringing the divisor down to the dividend, multiplying it by 0, and writing it down below the dividend. Then, we XOR the dividend and the partial remainder, as shown below.

01011010001111000000|x^4+x^3+x+1 0100 (partial remainder) 0000

The XOR of the dividend and the partial remainder is 0101001000111100. We bring down the next term (0) and append it to the partial remainder to make it 01000.

We then perform another division, as shown below.

0101001000111100|x^4+x^3+x+1 01000 (partial remainder) 01011 10101 10001 11000 11011

The remainder of the last division is 11011, which is the CRC. Therefore, the transmitted message is 0101101000111100110110.

Learn more about generator polynomial at

https://brainly.com/question/32088024

#SPJ11

Instructions: Using an array, enhance the program that you have performed in the previous exercise. The program should accept multiple entries and iteratively perform the following operations. Submit the source code and screenshot of output. Using a user-defined function and appropriate conditional and looping statements, create a program that will: (a) ask the item price from the user (b) ask how many items to purchase for a specific item price (c) ask if there are other items to purchase, if yes, repeat the first step, proceed to the next step if otherwise (d) compute and display for the total amount to pay (e) ask for the payment from the user (f) accepts only enough amount of payment, ask another payment if otherwise (g) compute and display change

Answers

Here is the code in Python which accepts multiple entries and iteratively perform the following operations: (a) ask the item price from the user (b) ask how many items to purchase for a specific item price (c) ask if there are other items to purchase, if yes, repeat the first step, proceed to the next step if otherwise (d) compute and display for the total amount to pay (e) ask for the payment from the user (f) accepts only enough amount of payment, ask another payment if otherwise

(g) compute and display change: Code:```def total amount(items):    total = 0    for i in items:        total += i    return totaldef change(amount, paid):    return paid - amountitems = []while True:    item_price = float(input("Enter the item price: "))    item_quantity = int(input("Enter the quantity of the item: "))    items.append(item price * item_quantity)    choice = input("Do you have another item to purchase? (y/n)")  

if choice.lower() == "n":        breaktotal = total amount(items)print("Total Amount: PHP", total)while True:    paid_amount = float(input("Enter the amount paid: PHP "))    if paid_amount >= total:        break    else:        print("Insufficient amount paid, please try again!")change_amount = change(total, paid_amount)print("Change amount: PHP", change_amount)```

To know more about Python  visit:-

https://brainly.com/question/30391554

#SPJ11

Other Questions
A customer service department receives on average 150 calls per day and the number of calls received is Poisson distributed. What is the standard deviation of the calls received per day? Convert the given unit of weight to the unit indicated. 620 mg to g Explain why the system need to continuously scan the Input Output devices? (e) Describe why there is a need to synchronize the data from Input Output device with processor. (f) Suppose that a processor waiting for a very long time to access the Input Output device. How will the system act to solve this problem? Q30 A processor with clocking rate of 8MHz need to execute 3 instruction, where for each instruction the microprocessor need to scan the Input or Output device at every 12 clock cycle. (a) Calculate the time taken to perform 1 clock cycle. (b) Calculate the time taken to scan the Input Output device for each instruction. (c) Calculate the time taken to execute 3 instructions. (Compound interest with nonannual periods) a. Calculate the future sum of $3,000, given that it will be held in the bank for 8 years at an APR of 5 percent. b. Recalculate part a using compounding periods that are (1) semiannual and (2) bimonthly (every two months). c. Recalculate parts a and b for an APR of 10 percent. d. Recalculate part a using a time horizon of 16 years (the APR is still 5 percent). e. With respect to the effect of changes in the stated interest rate and holding periods on future sums in parts c and d, what conclusions do vou draw when vou compare these ficures with the answers found in parts a and b? Mard w Hereased ra-1) Poont to tre nowed weres Thiard bate keweed iet. An aircraft is coming in for a landing at 320. meters height when the propeller falls off. The aircraft is flying at 46.0 m/s horizontally. The propeller has a rotation rate of 23.0 rev/s, a moment of inertia of 66.0 kg.m2, and a mass of 212 kg. Neglect air resistance. With what translational velocity does the propeller hit the ground? 91.6 m/s What is the rotation rate of the propeller at impact? (You do not need to enter any units.)If air resistance is present and reduces the propeller's rotational kinetic energy at impact by 33.0%, what is the propeller's rotation rate at impact? (You do not need to enter any units.) Question 4 (coder) Refer to page five of the Coders and Tracers sheet for sample runs. You are to write the code for the int method getDifference. This method receives a single int value, n. When the computer runs the code of this method it solicits n values from the user and returns the difference between the highest and lowest values entered. Question 4 Sample Calls and RunsCall: result = getDifference(2): System.out.printf("Result -%d\n", result); Run: Enter 2 integers: 49 Display: Result - 5 Call: result = getDifference(4); System.out.printf("Result =%d\n", result); Run: Enter 4 integers: 7 2 96 Display: Result - 7 Call: result = getDifference(7); = System.out.printf("Result =%d n", result); Run: Enter 7 integers: 27 26 13 19 32 25 16 Display: Result = 19 Call: result = getDifference(10); System.out.printf"Result-%d\n", result); Run: Enter 2 integers: 31 26 87 42 76 45 22 89 65 47 Display: Result - 67 Problem 3. : (a). : Express a function in function notation that has a vertical asymptote and that passes through the point \( (2,3) \). policy in which the marginal costs of undertaking the policy equal the marginal benefits of that policy is best called an: Multiple Choice equality policy. incentive policy optimal policy. opportunity policy. The population of a particular type of fish in a lake would grow logistically according to the differential equation (where t is measured in years) absent harvesting. dtdy=0.05y(1 3500yy(0)=1390 If this lake is opening to fishing, determine how many fish can be harvested each year to maintain the population in equilibrium. Hint: How fast is the fish population growing initially? :) fish per year Give your answer to the nearest whole fish Find a reduced residue system (mod20) and give (20). 2. Find a reduced residue system (mod30) and give (30). Helen's preferences over food (F) and clothing (C) are given by U(F,C)=FC+10C If the price of a food is $5 and the price of clothing is $4, and Helen can spend a combined total of 520 each day on these goods, find Helen's optimal consumption basket. If you wanted a median time to flood of at least 50 years, what probability of flooding could you accept?Please show work. A sample was done, collecting the data below. Calculate the standard deviation, to one decimal place.X 2 29 27 20 9 "Determine the point groups and symmetry factors for each substancebelow" NHCI, CO2-3, SiF4, HCN, SIFCLBrl, BF 4 2. Design an active highpass filter with a gain of 10, a corner frequency of 2 kHz, and a gain roll-off rate of 40 dB/decade. Rt = R = 10 kQ. R = 100 KQ. Convert the following Pseudo-code to actual coding in any of your preferred programming Language(C/C++/Java will be preferable from my side!)Declare variables named as i, j, r, c, VALPrint "Enter the value of r: "Input a positive integer from the terminal and set it as the value of rPrint "Enter the value of c: "Input a positive integer from the terminal and set it as the value of cDeclare a 2D matrix named as CM using 2D array such that its dimension will be r x cInput an integer number (>0) for each cell of CM from terminal and store it into the 2D arrayPrint the whole 2D matrix CMSet VAL to CM[0][0]Set both i and j to 0While i doesnt get equal to r minus 1 OR j doesnt get equal to c minus 1Print "(i, j) " // i means the value of i and j means the value of jIf i is less than r minus 1 and j is less than c minus 1If CM[ i ] [ j + 1 ] is less than or equal to CM[ i + 1 ][ j ], then increment j by 1 onlyElse increment i by 1 onlyElse if i equals to r minus 1, then increment j by 1 onlyElse increment i by 1 onlyPrint "(i, j)" // i means the value of i and j means the value of jIncrement VAL by CM[ i ][ j ]Print a newlinePrint the last updated value of VALThe above Pseudo-code gives solution to of one of the well-known problems we have discussed inthis course. Can you guess which problem it is? Also, can you say to which approach the abovePseudo-code does indicate? Is it Dynamic Programming or Greedy? Justify your answer withproper short explanation.Convert the following Pseudo-code to actual coding in any of your preferred programming Language(C/C++/Java will be preferab The average is a measure of the center of a data set. True False Question 2 3 pts The Standard Deviation is a measure of how spread out a Data Set is. True False Question 3 2 pts The Empirical Rule says that about 99% of the data is within one standard deviation of the average. True False PYTHON LIST OF DICTIONARIES PROBLEMI've been having trouble extracting multiple specific key:value pairs from a list of dictionaries in my code. I will write an example code below:data_set = [{'diet': 'fruit': 'Apple', 'vegetable': 'Carrot', 'meat': 'Steak', 'starch': 'Rice, 'date': '2022-03-26', 'count': '50'}]Lets say I would like to:1. extract the key:value pairs for diet, fruit, meat, count2. add those key:value pairs to a new dictionary3. print the new dictionary4. extract and print the value of 'diet' if the value of 'count' is >= 25 from the new dictionaryHow would I code for this? A cousin did not live with the taxpayer all year, but the taxpayer provided more than half of the cousins support. The cousin was unmarried, had no income, and meets the three general dependency tests. Which is the test that disqualifies the taxpayer from claiming the cousin as a dependent?A. Gross incomeB. Joint return testC. Member of household or relationshipD. Support The value chain assesses the value of the company's competitive advantage vs. the competition. True False