Write a MATLAB script in which you initialize the following vector:

ANIMALS = ["cow", "cat", "dog", "fox", "lion", "bear", "sea lion", "deer", "dolphin"];

a. In the script, use logical indexing to create a vector called C_ANIMALS that is comprised of the animals from the above ANIMALS vector starting with the letter c. This should be done with just one line of code. HINT: MATLAB provides a built-in function that checks whether a string starts with a specified letter. Feel free to research and use this built-in function.

b. In the script, use logical indexing to create a vector called LETTERS_3 that is comprised of the animals from the above ANIMALS vector that are three letters long. This should be done with just one line of code. HINT: MATLAB provides a built-in function that checks whether a string’s length is equal to a certain number. Feel free to research and use this built-in function.

c. In the script, use logical indexing to create a vector called D_GREATER_3 that is comprised of the animals from the above ANIMALS vector that are greater than three letters long and start with the letter d. This should be done with just one line of code.

d. Display all the vectors created in this script: ANIMALS, C_ANIMALS, LETTERS_3, and D_GREATER_3.

Answers

Answer 1

Answer:

ANIMALS = ["cow", "cat", "dog", "fox", "lion", "bear", "sea lion", "deer", "dolphin"];

C_ANIMALS = ANIMALS(startsWith(ANIMALS,"c"));

LETTERS_3 = ANIMALS(strlength(ANIMALS)==3);

D_GREATER_3 = ANIMALS(strlength(ANIMALS)>3 & startsWith(ANIMALS,"d"));

disp(ANIMALS)

disp(C_ANIMALS)

disp(LETTERS_3)

disp(D_GREATER_3


Related Questions

1- (8 point) The following questions relate to an array called numfrc. a) Define the size of the array to 25 by using a constant macro SIZE. b) Declare the array to be of type double and initialize the elements to 0. c) Assign the value of 6.666 to the 14 th element of the array from beginning. d) Refer to array element index 14 and assign the value of -6.666 to it. e) Assign the value 1.667 to array element index nine. f) Assign the value 3.333 to the seventh element of the array from beginning. g) Print array elements index 14 and 9 with two digits of precision to the right of the decimal point, and show the output that is displayed on the screen. h) Print all the elements of the array, using a for repetition statement. Assume the variable i has been defined as a counter control variable for the loop. Show the output as a table with index number and element value.

Answers

Answer:

Explanation:

Note: Alphabets refers to respective problem in question

Program:

#include<stdio.h>

#define SIZE 25

int main()

{

  double numfrc[SIZE];                                   // (a)

  for(int i=0;i<SIZE;i++)                                   // (b)

      numfrc[i]=0;

 

  numfrc[13]=6.666;                                       // (c)

  numfrc[14]=-6.666;                                       // (d)

  numfrc[9]=1.667;                                       // (e)

  numfrc[6]=3.333;                                       // (f)

 

  for(int i=14;i>=9;i--)

      printf("%2d ---> %.2lf\n",i,numfrc[i]);               // (g)

     

  printf("\n");

 

  for(int i=0;i<SIZE;i++)

      printf("%2d ---> %.2lf\n",i,numfrc[i]);               // (h)

     

}

Output:

What is technology??

Answers

Answer:

Technology is the skills, methods, and processes used to achieve goals. People can use technology to: Produce goods or services. Carry out goals, such as scientific investigation or sending a spaceship to the moon. Solve problems, such as disease or famine.

Explanation:

Good Luck!

Technology refers to the application of scientific knowledge, tools, and techniques for practical purposes.

Technology involves the creation, development, and utilization of various systems, methods, processes, and devices to solve problems, improve efficiency, enhance productivity, and achieve specific goals in different domains.

Technology encompasses a wide range of fields and disciplines, including engineering, computer science, electronics, telecommunications, biotechnology, information technology, and more. It involves the design, production, and utilization of tangible and intangible artifacts, such as machinery, software, infrastructure, systems, algorithms, and networks.

Technology is constantly evolving and advancing, driven by research, innovation, and human creativity. It plays a significant role in shaping societies, economies, and cultures, influencing various aspects of our lives.

Overall, technology encompasses the tools, knowledge, and systems that enable the practical application of scientific understanding to address challenges, improve efficiency, and enhance human experiences in the modern world.

Learn more about Technology here:

https://brainly.com/question/9171028

#SPJ6

Using a text editor, create a file that contains a list of at least 15 six-digit account numbers. Read in each account number and display whether it is valid. An account number is valid only if the last digit is equal to the remainder when the sum of the first five digits is divided by 10. For example, the number 223355 is valid because the sum of the first five digits is 15, the remainder when 15 is divided by 10 is 5, and the last digit is 5. Write only valid account numbers to an output file, each on its own line. Note that the contents of the file AcctNumsIn.txt will change when the test is run to test the program against different input. Grading Write your Java code in the area on the right. Use the Run button to compile and run the code. Clicking the Run Checks button will run pre-configured tests against your code to calculate a grade. Once you are happy with your results, click the Submit button to record your score. AcctNumsIn.txt ValidateCheckDigits.java

Answers

Answer:

See explaination

Explanation:

/File: ValidateCheckDigits.java

import java.io.BufferedWriter;

import java.io.File;

import java.io.FileWriter;

import java.io.IOException;

import java.util.Scanner;

public class ValidateCheckDigits {

public static void main(String[] args) {

String fileName = "numbers.txt"; //input file name

String validFileName = "valid_numbers.txt"; // file name of the output file

//Open the input file for reading and output file for writing

try(Scanner fileScanner = new Scanner( new File(fileName));

BufferedWriter fileWriter = new BufferedWriter( new FileWriter(validFileName))) {

//Until we have lines to be read in the input file

while(fileScanner.hasNextLine()) {

//Read each line

String line = fileScanner.nextLine().trim();

//calculate the sum of first 5 digits

int sum = 0;

for(int i = 0; i < 5; i++) {

sum += Integer.parseInt( line.charAt(i) + "");

}

//Get the last digit

int lastDigit = Integer.parseInt(line.charAt(5)+"");

//Check if the remainder of the sum when divided by 10 is equal to last digit

if(sum%10 == lastDigit) {

//write the number in each line

fileWriter.write(line);

fileWriter.newLine();

System.out.println("Writing valid number to file: " + line);

}

}

System.out.println("Verifying valid numbers completed.");

} catch(IOException ex ) {

System.err.println("Error: Unable to read or write to the file. Check if the input file exists in the same directory.");

}

}

}

Check attachment for output and screenshot

Final answer:

The process involves reading six-digit account numbers, summing the first five digits, and validating if the last digit matches the remainder of the sum modulo 10, outputting only the verified numbers to a file.

Explanation:

The goal is to validate six-digit account numbers to ensure their authenticity. The last digit of each account number must match the remainder when the sum of the first five digits is divided by 10. This concept utilizes simple mathematical operations like addition and modulo in conjunction with programming to accomplish the task of validation. Here's an outline of the procedure:

Read account numbers from a file.Add the first five digits of each number.Take the sum and perform a modulo operation by 10.Compare the result to the sixth digit of the account number.If they match, write the account number to an output file.

This process highlights the importance of validating data and using programming to automate otherwise time-consuming tasks.

Write a complete program that declares an array of 1000 integers and initializes each element in the array to have a value equal to the index of that element. That is, the value at index 0 should be 0, the value at index 1 should be 1, the value at index 2 should be 2, and so on. Then, ask the * user for a single integer input. Triple the value of each element in the * array whose value is divisible by that user input. You do not need to print out the array or anything else except for the user input prompt. You can assume that the user will input an integer when prompted.

Answers

Answer:

see explaination

Explanation:

import java.util.Scanner;

class Main

{

public static void main (String[] args)

{

int []A = new int[1000]; // Declaration of array which will store 1000 integers

for( int i = 0; i<1000; i++ )

A[i] = i; // will initialise elements of array equal to their index

System.out.print("Enter a value: ");

Scanner sc = new Scanner(System.in);

int num = sc.nextInt(); // Prompts the user to enter value

for( int i = 0; i<1000; i++ )

{

if( A[i]%num==0 ) //checks if the element is divisible by the entered value

A[i] = 3*A[i]; // Triples the value and reassigns to the same element

}

}

}

Write a code segment that uses a loop to create and place nine labels into a 3-by-3 grid. The text of each label should be its coordinates in the grid, starting with (0, 0) in the upper left corner. Each label should be centered in its grid cell. You should use a nested for loop in your code.

Answers

Answer:

Check the explanation

Explanation:

# List to store text values

grid=list()

# LOOP FOR 3 ROWS

for i in range(3):

   # LIST TO STORE COLUMN

   row = list()

   # LOOP FOR 3 COLUMNS

   for j in range(3):

       # CREATING TEXT WITH

       # COORDINATES FORMAT

       text = "({},{})".format(i,j)

       # APPEND TEXT TO ROW

       row.append(text)

   # APPEND ROW TO GRID

   grid.append(row)

# AFTER THE ABOVE LOOP

# GRID WILL BE CREATED IN TO

# 3 X 3 GRID

# PRINTING GRID

# FOR ALL ROWS

for i in grid:

   # FOR ALL COLUMNS

   for j in i:

       # PRINTING VALUE AT

       # ROW I, COLUMN J

       print(j,end=" ")

   print()

Kindly check the screenshot and output below.

1. An integer in C (int) is represented by 4 bytes (1 byte = 8 bits). Find the largest integer that can be handled by C. Verify that number by computer (try to printf that number, and printf that number +1). No programming is required for this. Hint: (a) Conversion from binary to decimal: 3 2 1 0 2 1101 =1 2 + 0 2 +1 2 +1 2 = 8 + 0 + 2 +1 10 =11 (b) If an integer is represented by 1 byte (8 bits), the maximum integer number is 1111111 (Seven 1's as one bit must be reserved for a sign). 6 5 0 2 1111111 =1 2 +1 2 ++1 2 1 2 1 7 =  − =128 −1 (c) The number looks like a telephone number in Dallas.

Answers

Answer:

Check the explanation

Explanation:

In C, int requires 4 butes to sotre a integer number. that means it requires 4*8 = 32 bits. The maximum number can be stored using 32 bits is

[tex](11111111111111111111111111111111)_2[/tex]

The first digit is used for sign. decimal equivalent to this number can be computed as

[tex](1111111111111111111111111111111)_2= 1\times2^{30}+1\times2^{29}+...+1\times2^0[/tex]

=[tex]1\times2^{31}-1[/tex]

= [tex]2147483647-1=2147483646[/tex]

That means int can store a up to 2147483646.

                      Testing with C code

#include<stdio.h>

int main()

{

  int a = 2147483647; // a with max number

  printf("%d\n",a);// printing max number

  a = a+1;// adding one to the number

  printf("%d\n",a);// printing the number after adding one

  return 0;

}

                THE OUTPUT

$ ./a.out

2147483647

-2147483648

Final answer:

The largest integer that can be represented by an int in C is 2,147,483,647. Adding 1 to this maximum value leads to an integer overflow, resulting in the smallest possible integer that can be handled in C, which is -2,147,483,648.

Explanation:

In C, an integer (int) is typically represented using 4 bytes, or 32 bits. However, one bit is reserved for indicating the sign of the integer (positive or negative), leaving 31 bits for the numerical value. In binary notation, the maximum number that can be represented with 31 bits all set to 1 is 231-1. By direct calculation, this is 2,147,483,647. Therefore, the largest integer that can be represented by an int in C is 2,147,483,647.

When you try to add 1 to this maximum value (e.g., printf the number 2,147,483,647 + 1), the result will not be as expected because it leads to an integer overflow. Instead, it would give you the smallest possible integer that can be handled in C, which is -2,147,483,648.

Learn more about C Programming here:

https://brainly.com/question/34799304

#SPJ3

This programming project is to simulate a few CPU scheduling policies discussed in the class. You willwrite a C program to implement a simulator with different scheduling algorithms. The simulator selects atask to run from ready queue based on the scheduling algorithm. Since the project intends to simulate aCPU scheduler, so it does not require any actual process creation or execution. When a task is scheduled,the simulator will simply print out what task is selected to run at a time. It outputs the way similar to Ganttchart style.

Answers

Answer:

FCFS Scheduling Algorithm:-

// C++ program for implementation of FCFS

// scheduling

#include<iostream>

using namespace std;

// Function to find the waiting time for all

// processes

void findWaitingTime(int processes[], int n,

int bt[], int wt[])

{

// waiting time for first process is 0

wt[0] = 0;

// calculating waiting time

for (int i = 1; i < n ; i++ )

wt[i] = bt[i-1] + wt[i-1] ;

}

// Function to calculate turn around time

void findTurnAroundTime( int processes[], int n,

int bt[], int wt[], int tat[])

{

// calculating turnaround time by adding

// bt[i] + wt[i]

for (int i = 0; i < n ; i++)

tat[i] = bt[i] + wt[i];

}

//Function to calculate average time

void findavgTime( int processes[], int n, int bt[])

{

int wt[n], tat[n], total_wt = 0, total_tat = 0;

//Function to find waiting time of all processes

findWaitingTime(processes, n, bt, wt);

//Function to find turn around time for all processes

findTurnAroundTime(processes, n, bt, wt, tat);

//Display processes along with all details

cout << "Processes "<< " Burst time "

<< " Waiting time " << " Turn around time\n";

// Calculate total waiting time and total turn

// around time

for (int i=0; i<n; i++)

{

total_wt = total_wt + wt[i];

total_tat = total_tat + tat[i];

cout << " " << i+1 << "\t\t" << bt[i] <<"\t "

<< wt[i] <<"\t\t " << tat[i] <<endl;

}

cout << "Average waiting time = "

<< (float)total_wt / (float)n;

cout << "\nAverage turn around time = "

<< (float)total_tat / (float)n;

}

// Driver code

int main()

{

//process id's

int processes[] = { 1, 2, 3};

int n = sizeof processes / sizeof processes[0];

//Burst time of all processes

int burst_time[] = {10, 5, 8};

findavgTime(processes, n, burst_time);

return 0;

}

Explanation:

See output

Three batch jobs, A through E, arrive at a computer center at almost the same time. They have estimated running times of 10, 6, 2, 4 and 8 minutes. Their priorities are 3, 5, 2, 1 and 4 respectively, with 5 being the highest priority.
(a) For each of the following scheduling algorithms, determine the mean turnaround time. Ignore any process switching overhead.
1. Round Robin
2. Priority scheduling
3. First come, First served (run in order 10, 6, 2, 4, 8)
4. Shortest job first
For (a), assume that the system is multiprogrammed, and that each job gets its fair share of the CPU. For (b) through (d) assume that only one job runs at a time, until it finishes. All jobs are completely CPU bound.

Answers

Answer:

1. The average turn around time is 21.2 minute using round robin scheduling algorithm with a quantum time of 1 minute.

2. The average turn around time is 20 minute using Priority scheduling algorithm.

3. The average turn around time is 19.2 minute using First Come First Serve scheduling algorithm.

4. The average turn around time is 14 minute using Shortest Job First scheduling algorithm.

Explanation:

Gantt chart was used to solve the scheduling problem.

Image showing the Gantt chart and working solution is attached.

Round Robin scheduling algorithm is a type of scheduling that uses a time slice for each process/job. Once the time slice is complete, the process leave to join the queue again if it has not finished execution.

Priority scheduling algorithm is a type of scheduling algorithm that allows a process/job to execute/complete based on the order of priority. In this case, the higher the number, the higher the priority. With 5 having the highest priority.

First Come First Serve scheduling algorithm is a type of scheduling algorithm that allows execution of a process/job based on first come first server i.e based on order of arrival time. In this case the order is ABCDE.

Shortest Job First scheduling algorithm is a type of scheduling algorithm that allocate the CPU to the process/job having the shortest completion time first. In this case, Job C has the shortest completion time.

The major objective of this lab is to practice class and object-oriented programming (OOP), and separate files: 1. We will reuse lab 6, a direct current simulator with extensions to let you practice OOP. Pay special attention to the difference between procedural programming and OOP. 2. This is the first time you break a program into several files such that you do not need to have all functions included in one program. The idea of breaking a program into several files has many benefits that will be explained in lecture notes and ZyBook reading assignment. It is NOT the purpose of this lab to train your logical thinking capability. We select a simple problem to help you fully understand OOP and separate files in an efficient manner.

Answers

Answer:

Implementation of resistor.cpp

#include "resistor.h"

Ohms::Ohm()

{

// default constructor

voltage=0;

}

Ohms::Ohm( double x) // parameterised constructor

{

voltage = x; // voltage x set to the supply voltage in the private data field called voltage

}

Ohms:: setVoltage(double a)

{

voltage = a;// to set supply voltage in private data field called voltage

}

Ohms::setOneResistance( String s, double p)

{

cin>>p; //enter the resistance value

if(p<=0) // if resistance is less than or equals to 0

return false

else // if re

cin.getline(s);

}

Ohms::getVoltage()

{

return voltage; //return voltage of ckt

}

Ohms::getCurrent()

{

return current; //return current of ckt

}

Ohms:: getNode()

{

return resistors; //return resistors of ckt

}

Ohms::sumResist()

{

double tot_resist = accumulate(resistors.begin(),resistors.end(),0); //std::accumulate function for calculating sum //of vectors and following are the starting and ending points

return tot_resist;

}

Ohms::calcCurrent()

{

if(current <=0) // if current is less than or equal to 0

return false;

else   // if current is greater than 0

return true;

}

Ohms:: calcVoltageAcross()

{

if(voltage<=0) // if voltage is less than or equal to 0

return false;

else //if voltage greater than 0

return true;

}

Explanation:

in the case of main.cpp its simple just make a class object and remember to include resistors.cpp with it for which the second last picture describes the process precisely. (Hint: Use theunit test case functions in the main.cpp).

As you can see node is a structure consisting of member variables, followed by a class Ohms representing a DC circuit.

By looking at these pictures, it is needed to implement the main.cpp and resistor.cpp files. The user defined header file resistor.h already consists of all contents of Class Ohm, struct node. You don't need to modify it in anyway in such case.

JAVA
In this exercise, you are given a phrase that starts with ‘A’. If the word after ‘A’ begins with a vowel, add an ‘n’ after the ‘A’, otherwise, return the phrase as is.

Example:

grammer("A word") --> "A word"
grammer("A excellent word") --> "An excellent word"


public String grammar(String phrase)
{
}

Answers

Answer:

Answer is provided in the attached screenshot

Explanation:

The character in the 2nd position will be always be the one we need to check. We then check if that character is a vowel, and replace the string as required.

Final answer:

To modify a phrase that starts with 'A' followed by a word that starts with a vowel by adding an 'n', one must write a Java function that checks the following character and adjusts the string accordingly.

Explanation:

The student's question pertains to a programming exercise in Java where the user needs to modify a string based on whether the word following an 'A' begins with a vowel or not. To solve this, you would need to check the character after the 'A ' for a vowel. If it's a vowel, an 'n' should be added to form 'An'. The Java function would use conditionals to check this and then return the modified or original phrase accordingly.

Here is an example of how the grammar function can be implemented:

public String grammar(String phrase) {
   if(phrase.length() > 2 && phrase.substring(0, 2).equalsIgnoreCase("A ")) {
       char nextChar = phrase.charAt(2);
       if(nextChar == 'a' || nextChar == 'e' || nextChar == 'i' || nextChar == 'o' || nextChar == 'u') {
           return "An " + phrase.substring(2);
       }
   }
   return phrase;
}

A technician needs to be prepared to launch programs even when utility windows or the Windows desktop cannot load. What is the program name for the System Information utility?

Answers

Answer:

Windows includes a tool called Microsoft System Information (Msinfo32.exe). This tool gathers information about your computer and displays a comprehensive view of your hardware, system components, and software environment, which you can use to diagnose computer issues.

Explanation:

Consider a one-way authentication technique based on asymmetric encryption: A --> B: IDA B --> A: R1 A --> B: E(PRa, R1) Explain the protocol. What type of attack is this protocol susceptible to?

Answers

Answer:

See explaination

Explanation:

A protocol in computing can be defined as a standard set of rules that allow electronic devices to communicate with each other. These rules include what type of data may be transmitted, what commands are used to send and receive data, and how data transfers are confirmed. You can think of a protocol as a spoken language.

Please kindly check attachment for for the details of the answer.

 (a) Protocol working

Here, A-->B : ID means protocol is issued authentic A to B.

Then B--> A : R1 here, R1 take care about only A can encrypt R1 ensure that only A can take authentication challenge.Last A--> B : E (PRa, R1) here, A's public key is take care to decrypt.

(b). According to the question it is based on asymmetric key encryption technique, Let us assume any third-party K could use the given below assumption:

Let us suppose A sign a message, and this message, K show to any other party D.so, in this case if A used public or private key for authentication and signature.Then, in this case attacks occurrence chance is happen, so man middle attack will be happen.

Learn more about:

https://brainly.com/question/17495888

Consider a Web form that a student would use to input student information and rèsumè information into a career services application at your university. Sketch out how this form would look and identify the fields that the form would include. What types of validity checks would you use to make sure that the correct information is entered into the system?

Answers

Answer:

valid check: Completeness check, Format check, Range check, Consistency check

Explanation:

Form validations required are:

Completeness check:-all fields are filled accordingly

Format check:-Each field entered data is correct format or not

Range check:-Range of data min or max

Consistency check:-Entering consistent data

Database check

Fields are:

Text Boxes,Drop down list box,radio button,check box,button,slider(if you want to rate or show interest of a subject),combo box(group together radio buttons/check boxes/sliders).

See attachment please for the sketch

JAVA
Write a method that takes the last two values of a String and adds those two values three more times on to the end of the String.

For example, repeatTwo("karel") would return "karelelelel".

public static String repeatTwo(String word){
}

Answers

Answer:

Is in the provided screenshot

Explanation:

Get the last two characters and concatenate.

Final answer:

To solve the task, a method in Java is written that appends the last two characters of the input string three additional times to the end, using the substring method.

Explanation:

The task is to write a method in Java that takes a given string and appends the last two characters of that string three more times onto the end of it. This operation modifies the original string by repeatedly adding a substring that consists of its last two characters.

Method Implementation:

Here is how you can write the method:

public static String repeatTwo(String word) {
   if (word == null || word.length() < 2) {
       return word; // handle null and short strings
   }
   String lastTwoChars = word.substring(word.length() - 2);
   return word + lastTwoChars + lastTwoChars + lastTwoChars;
}

This method first checks if the input string is null or shorter than two characters. If it isn't, it proceeds to use the substring method to extract the last two characters and concatenates this substring three times to the end of the original string.

A Musician class has been built that takes the name, number of albums sold, and number of weeks that artist has been on the Top40 list. The Musician class also has a boolean instance variable isPlatinum that determines if the musician has gone platinum, meaning they’ve sold over a million copies of the same record. The Billboard class currently has a top10 ArrayList that will store the top 10 musicians as a list. In the Billboard class, create an add method that will add a musician to the list if there are less than 10 musicians in the list, and if the musician has Platinum status. If there are 10 musicians in the list, then the method should call the replace method. Otherwise, a message should be displayed to the user that the musician could not be added to the top10 list. The replace method compares the total number of weeks that the musician has been on the top40 list. If the musician with the lowest number of weeks on the top40 is lower than the number of weeks on the top40 of the new musician, then the old musician is replaced by the new one. There should be a message to the user that the old musician has been replaced by the new one. Otherwise, the user should be notified that the new musician cannot be added because they don’t have enough weeks on the top40. This method should be created in the Billboard class. Use the BillboardTester class to test if the new musicians being added are being correctly replaced, or omitted from the Top 10.

Answers

Answer:

See explaination for program code

Explanation:

Java code below:

Musician.java :

public class Musician {

private String name;

private int weeksInTop40;

private int albumsSold;

private boolean isPlatinum;

public Musician(String name, int weeksInTop40, int albumsSold) {

this.name = name;

this.weeksInTop40 = weeksInTop40;

this.albumsSold = albumsSold;

setPlatinum(albumsSold);

}

public void setPlatinum(int albumsSold) {

if(albumsSold >= 1000000) {

isPlatinum = true;

}else {

isPlatinum = false;

}

}

public int getWeeksInTop40() {

return this.weeksInTop40;

}

public String getName() {

return this.name;

}

public boolean getIsPlatinum() {

return this.isPlatinum;

}

public String toString() {

return this.name;

}

}

Billboard.java :

import java.util.ArrayList;

public class Billboard {

private ArrayList<Musician> top10 = new ArrayList<Musician>();

public void add(Musician newMusician) {

if(this.top10.size()<10 && newMusician.getIsPlatinum()==true) {

/**

* Less than 10 musician are present in the list currently

* And also the newMusician is platinum

* */

this.top10.add(newMusician);

}else {

if(newMusician.getIsPlatinum()==false) {

System.out.println("The new musician "+newMusician+" cannot be added because not enough records are sold");

}else {

/**

* We need to call the replace method

* */

replace(newMusician);

}

}

}

public void replace(Musician newMusician) {

/**

* First we need to find what is the lowest number of weeks

* an musician was there in top40.

* */

int lowestOnTop40 = Integer.MAX_VALUE;

int index=-1;

for(int i=0;i<this.top10.size();i++) {

if(this.top10.get(i).getWeeksInTop40()<lowestOnTop40) {

lowestOnTop40 = this.top10.get(i).getWeeksInTop40();

index = i;

}

}

/**

* We have at what position the lowest number of week on top value in variable

* lowestOnTop40 at index

* We need to compare this value with newMusician's number of weeks on top 40

* */

if(lowestOnTop40 < newMusician.getWeeksInTop40()) {

System.out.println("The old musician "+this.top10.get(index)+" has been replaced by new musician "+newMusician);

this.top10.set(index, newMusician);

}else {

System.out.println("The new musician "+newMusician+" cannot be added because not enough weeks on top40.");

}

}

public void printTop10() {

System.out.println(top10);

}

}

BillboardTester.java :

public class BillboardTester {

public static void main(String[] args) {

Billboard top10 = new Billboard();

top10.add(new Musician("Beyonce", 316, 100000000));

top10.add(new Musician("The Beatles", 365, 600000000));

top10.add(new Musician("Drake", 425, 150000000));

top10.add(new Musician("Pink Floyd", 34, 250000000));

top10.add(new Musician("Mariah Carey", 287, 200000000));

top10.add(new Musician("Rihanna", 688, 250000000));

top10.add(new Musician("Queen", 327, 170000000));

top10.add(new Musician("Ed Sheeran", 536, 150000000));

top10.add(new Musician("Katy Perry", 317, 143000000));

top10.add(new Musician("Justin Bieber", 398, 140000000));

//This musician should not be added to the top10 because they don't have enough records sold

top10.add(new Musician("Karel the Dog", 332, 60));

//This musician should replace the artist

top10.add(new Musician("Tracy the Turtle", 332, 150000000));

//This musician should not replace an artist, but is a Platinum artist

top10.add(new Musician("Alex Eacker", 100, 23400000));

top10.printTop10();

}

}

Write a CREATE TABLE statement for the DEPARTMENT table. Save and Run this statement. 2. Write a CREATE TABLE statement for the EMPLOYEE table including constraints. Email is required and is an alternate key Cascade updates but not deletions from DEPARTMENT to EMPLOYEE. Save and Run this statement. 3. Write a CREATE TABLE statement for PROJECT table. - Cascade updates but not deletions from DEPARTMENT to PROJECT

Answers

Answer:

Check the explanation

Explanation:

Please find the sql statements (as numbered in the question) below:

1. DEPARTMENT TABLE

CREATE TABLE DEPARTMENT (

DepartmentName varchar (50),

BudgetCode varchar (50),

OfficeNumber varchar (50),

OfficeNumber varchar (50),

Phone varchar (50)

);

2. EMPLOYEE TABLE

CREATE TABLE EMPLOYEE (

EmployeeNumber varchar (50),

FirstName varchar (50),

LastName varchar (50),

Phone varchar (50),

Email varchar (50) NOT NULL UNIQUE,

DepartmentName varchar (50) FOREIGN KEY REFERENCES DEPARTMENT(DepartmentName) ON UPDATE CASCADE

);

3. PROJECT TABLE

CREATE TABLE PROJECT (

ProjectID varchar (50),

Name varchar (50),

MaxHours FLOAT,

Date() AS StartDate,

Date() AS EndDate,

DepartmentName varchar (50) FOREIGN KEY REFERENCES DEPARTMENT(DepartmentName) ON UPDATE CASCADE

);

A professor wants to know if students are getting enough sleep. Each day, the professor observes whether the students sleep in class, and whether they have red eyes. The professor has the following domain theory:

• The prior probability of getting enough sleep, with no observations, is 0.7.
• The probability of getting enough sleep on night t is 0.8 given that the student got enough sleep the previous night, and 0.3 if not.
• The probability of having red eyes is 0.2 if the student got enough sleep, and 0.7 if not.
• The probability of sleeping in class is 0.1 if the student got enough sleep, and 0.3 if not.

Answers

Answer:

Each day, the professor observes whether the students sleep in class, and whether they have red eyes. The professor has the following domain theory: • The prior probability of getting enough sleep, with ... The probability of having red eyes if the student did not get enough sleep. • The probability of sleeping in class is if the ...

Explanation:

Create a class CitiesAndCountries with at least three methods: class CitiesAndCountries: def add_country(self, country_name): """ :param country_name: name of new country :return: True if added, False if duplicate """ def add_city(self, country_name, city_name): """ :param country_name: must be a country in the already defined countries :param city_name: name of new city. :return: True if added, False if not added """ def find_city(self, city_name): """ :param city_name: get all cities with that name, in all different countries :return: list of countries which have a city with that name, empty list if none """

Answers

Answer:

Check the explanation

Explanation:

class CitiesAndCountries:

   """

   This is the class which maintains a dictionary of the Countries with the cites in them.

   """

   def __init__(self):

       """

       Constructor for the class CitiesAndCountries.

       It defines a dictionary to store the names of the countries and a list of the cities which are in them

       Example of the the following dictionary when it is populated:

       citiesandcountries = {"india":["bhopal", "mumbai", "nagpur"], "usa":["new york", "seatlle"]

       Keeping the names in lowercase helps in search

       """

       self.citiesandcountries = {}  # This is the dictionary which stores the information

   def add_country(self, country_name):

       """

       The add_country function to add countries to our list.

       :param country_name: Name of the country to add to the dictionary

       :return: True if added to the dictionary, False if it is already present in the dictionary

       """

       if country_name.lower() not in self.citiesandcountries.keys():

           self.citiesandcountries[country_name.lower()] = [] # Storing the country name in lower case helps in

           # searching

           return True

       else:  # You could omit the else statement and directly return False, but it adds to readability.

           return False

   def add_city(self, country_name, city_name):

       """

       This function adds the cities names to the dictionary corresponding to their countries.

       :param country_name: Country to which the city belongs

       :param city_name:  Name of the city to be added

       :return: True if the country is present in the dictionary and the city is added to the list, else False

       """

       if country_name.lower() in self.citiesandcountries.keys():

           self.citiesandcountries[country_name.lower()].append(city_name.lower())

           return True

       else:

           return False

   def find_city(self, city_name):

       """

       This function is used to retrive a list of countries where the city with the given name is present

       :param city_name: Name of the city.

       :return: A list of all the countries where the city if present.

       """

       countries_with_city = []

       for country in self.citiesandcountries.keys():

           if city_name.lower() in self.citiesandcountries[country]:

               countries_with_city.append(country.title())

       return countries_with_city

Write a program with functions that accepts a string as an argument and returns the number of vowels that the string contains. The application should have another function that accepts a string as an argument and return the number of consonants that the string contains. The application should let the user enter a string and should display the number of vowels and the number of consonants it contains.

Answers

Answer:

import java.util.Scanner;

public class num11 {

   public static void main(String[] args) {

   Scanner in = new Scanner(System.in);

       System.out.println("Enter a word or phrase");

       String word = in.nextLine();

       //Calling the methods

       System.out.println("Total vowels in "+word+" are "+numVowels(word));

       System.out.println("Total consonants in "+word+" are "+numConsonants(word));

   }

   public static int numVowels(String word){

       //Remove spaces and convert to lowercase

       //Assume that only correct character a-z are entered

       String newWord = word.toLowerCase().replaceAll(" ","");

       int vowelCount = 0;

       for(int i = 0; i <= newWord.length()-1; i++){

           if(newWord.charAt(i)=='a'||newWord.charAt(i)=='e'||newWord.charAt(i)=='i'

                   ||newWord.charAt(i)=='o'||newWord.charAt(i)=='u'){

               vowelCount++;

           }

       }

       return vowelCount;

   }

   public static int numConsonants(String word){

       //Remove spaces and convert to lowercase

       //Assume that only correct character a-z are entered

       String newWord = word.toLowerCase().replaceAll(" ","");

       int consonantCount = 0;

       //Substract total vowels from the length of the word to get the consonants

       consonantCount = newWord.length()-numVowels(word);

       return consonantCount;

   }

}

Explanation:

Create two methods vowelCount() and consonantCount() both accepts a string parameter and returns an intvowelCount() Uses a for loop to count the occurrence of the vowels (a,e,i,o,u) in the string and returns the count.consonantCount calls vowelCount and subtracts the vowelCount from the string lengthIn the main Method the user is prompted to enter a stringThe two methods are called to return the number of vowels and consonantsObserve also that it is assumed that user entered only strings containing the character a-Z. Observe also that the string is converted to all lower cases and whitespaces removed.

a. Assume a computer has a physical memory organized into 64-bit words. Give the word address and offset within the word for each of the following byte addresses:

0, 9, 27, 31,120, and 256.

b. Extend the above exercise by writing a computer program that computes the answer. The program should take a series of inputs that each consist of two values: a word size specified in bits and a byte address. For each input, the program should generate a word address and offset within the word. Note: although it is specified in bits, the word size must be a power of two bytes.

Answers

Answer:

Check the explanation

Explanation:

For 9th byte , it is from 8*8 bit to 9"8th bit so each word consists of 64 bits , to find word address u have to divide 8*8 by 64.

Offset within word = 9*8modulo 64.

For 27th byte , word address = 8*27/64.

Offset within word = 27* 8 modulo 64

For 21th byte , word address = 8*31/64

Offset within the word = 31*8 modulo 64

For 120 , word address = 8*120/64

Offset within the word = 120*8 modulo 64.

Tiny College wants to keep track of the history of all its administrative appointments, including dates of appointment and dates of termination. (Hint: Time- variant data is at work.) The Tiny College chancellor may want to know how many deans worked in the College of Business between January 1, 1960, and January 1, 2018, or who the dean of the College of Education was in 1990. Given that information, create the complete ERD that contains all primary keys, foreign keys, and main attributes. To upload and submit your assignment, click the Choose File button below to find and select your saved document. Make sure that the file is saved with your last name in the file name. (Example: ch5_problem1_Jones.doc)

Answers

Answer:

Explanation:

check below for the answer in d attached file

Privacy laws in other countries are an important concern when performing cloud forensics and investigations. You've been assigned a case involving PII data stored on a cloud in Australia. Before you start any data acquisition from this cloud, you need to research what you can access under Australian law. For this project, look for information on Australia's Privacy Principles (APP), particularly Chapter 8: APP 8 – Cross-border disclosure of personal information. Write a 2 to 3 page paper (not including title and reference pages) using APA format summarizing disclosure requirements for getting consent from data owners, and any exceptions allowed by this law. Writing Requirements

Answers

Answer:

See the explanation for the answer.

Explanation:

Australian regulations makes extremely difficult for the enterprises to move organizations sensitive data to the cloud which is storing outside the Australian network. These are all managed by the Office of Australian Information Commissioner(OAIC) which provides oversight on the data privacy regulations designed to govern the dissemination of the sensitive information.

One rule they applied under this is The Australian National Privacy Act 1988 which tells how the organizations collect, use, secure, store the information. The National Privacy Principles in the Act tells how organizations should use the people's personal information. The NPP has a rule that An organization must take the responsibility to hold the information without misuse or modified by unauthorized access. They require enterprises to put security service level agreements with the cloud service providers that define audit rights, data location, access rights when there is cross border disclosure of information.

In later time they introduced a new principle called The Privacy Amendment Act 2012. This principle gives set of new rules along with the changes in the many rules in the previous act and also this is having a set of new principles those are called Australian Privacy Principles (APP).

In this there is principle for cross border disclosure of personal information which is APP8. This rule regulates the disclosure or transfer of personal information by an agency or company to a different location outside the country.

Before disclosure the information outside they have to take responsible steps that the company outside the Australia must not breach the APP 's.

Obtain a file name from the user, which will contain data pertaining to a 2D array Create a file for each of the following: averages.txt : contains the overall average of the entire array, then the average of each row reverse.txt : contains the original values but each row is reversed flipped.txt : contains the original values but is flipped top to bottom (first row is now the last row etc.) If the dimensions of array are symmetric (NxN), create a diagonal.txt: contains the array mirrored on the diagonal

Answers

Answer:

see explaination

Explanation:

#include <iostream>

#include <fstream>

#include <iomanip>

using namespace std;

int main()

{

string filename, file1, file2, file3, file4;

cout << "Enter the filename : ";

getline(cin, filename);

int row, col;

ifstream ifile;

ifile.open(filename.c_str());

if(!ifile)

{

cout << "File does not exist." << endl;

}

else

{

ifile >> row >> col;

float mat[row][col], diag[row][col];

for(int i=0; i<row; i++)

{

for(int j=0; j<col; j++)

ifile >> mat[i][j];

}

cout << "Enter the filename to save averages : ";

getline(cin, file1);

ofstream avgFile(file1.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);

float t_avg = 0, avg = 0;

for(int i=0; i<row; i++)

{

avg = 0;

for(int j=0; j<col; j++)

{

avg += mat[i][j];

}

t_avg += avg;

avg = avg/col;

avgFile << std::fixed << std::setprecision(1) << "Row " << i+1 << " average: " << avg << endl;

}

t_avg = t_avg / (row*col);

avgFile << std::fixed << std::setprecision(1) << "Total average: " << t_avg << endl;

cout << "Enter the filename to store reverse matrix : ";

getline(cin, file2);

ofstream revFile(file2.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);

for(int i=0; i<row; i++)

{

for(int j=col-1; j>=0; j--)

{

revFile << std::fixed << std::setprecision(1) << mat[i][j] << " ";

}

revFile << endl;

}

cout << "Enter the filename to store flipped matrix : ";

getline(cin, file3);

ofstream flipFile(file3.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);

for(int i=row-1; i>=0; i--)

{

for(int j=0; j<col; j++)

{

flipFile << std::fixed << std::setprecision(1) << mat[i][j] << " ";

}

flipFile << endl;

}

cout << "Enter the filename to store diagonal matrix : ";

getline(cin, file4);

ofstream diagFile(file4.c_str(), std::fstream::in | std::fstream::out | std::fstream::app);

for(int i=0; i<row; i++)

{

for(int j=0; j<col; j++)

{

diag[j][i] = mat[i][j];

}

}

for(int i=0; i<col; i++)

{

for(int j=0; j<row; j++)

{

diagFile << std::fixed << std::setprecision(1) << diag[i][j] << " ";

}

diagFile << endl;

}

}

return 0;

}

public class Test { public static void main(String[] args) { try { method(); System.out.println("After the method call"); } catch (ArithmeticException ex) { System.out.println("ArithmeticException"); } catch (RuntimeException ex) { System.out.println("RuntimeException"); } catch (Exception e) { System.out.println("Exception"); } } static void method() throws Exception { System.out.println(1 / 0); } }

Answers

Answer:

"ArithmeticException" is the correct answer for the above question.

Explanation:

Missing Information : The above question does not hold that "what is the output of the program".

The above question has a class that holds the two functions one function is the main function which calls the other function in a try-catch block.The method function holds one run time exception which is 1/0 which is an arithmetic exception.It can be handle by the help of an arithmetic class object which is defined in the first catch block.Hence the print function of this catch is executed and prints "ArithmeticException".

5. Assume a computer has a physical memory organized into 64-bit words. Give the word address and offset within the word for each of the following byte addresses: 0, 9, 27, 31,120, and 256.

6. Extend the above exercise by writing a computer program that computes the answer. The program should take a series of inputs that each consist of two values: a word size specified in bits and a byte address. For each input, the program should generate a word address and offset within the word. Note: although it is specified in bits, the word size must be a power of two bytes.

Answers

Answer:

see explaination and attachment

Explanation:

5.

To convert any byte address, By, to word address, Wo, first divide By by No, the no. of bytes/word, and ignores the remainder. To calculate a byte offset, O, in word, calculate the remainder of By divided by No.

i) 0 : word address = 0/8 = 0 and offset, O = 0 mod 8 = 0

ii) 9 : word address = 9/8 = 1 and offset, O = 9 mod 8 = 1

iii) 27 : word address = 27/8 = 3 and offset, O = 27 mod 8 = 3

iv) 31 : word address = 31/8 = 3 and offset, O = 31 mod 8 = 7

v) 120 : word address = 120/8 = 15 and offset, O = 120 mod 8 = 0

vi) 256 :word address = 256/8 = 32 and offset, O = 256 mod 8 = 0

6. see attachment for the python programming screen shot and output

The word address is the integer division of the physical address by 8, while the offset is the remainder of the physical address divided by 8.

(a) Calculate the word address and offset

The number of bit is given as 64.

So, we have:

[tex]2^n = 64[/tex]

Express 64 as a base of 2

[tex]2^n = 2^8[/tex]

Cancel out the base of 2

[tex]n = 8[/tex]

So, we have:

(i) Physical address: 0

Word address = 0\8 = 0Offset = 0 mod 8 = 0

(ii) Physical address: 9

Word address = 9\8 = 1Offset = 9 mod 8 = 1

(iii) Physical address: 27

Word address = 27/8 = 3Offset = 27 mod 8 = 3

(iv) Physical address: 31

Word address = 31/8 = 3Offset = 31 mod 8 = 7

(v) Physical address: 120

Word address = 120/8 = 15Offset = 120 mod 8 = 0

(v) Physical address: 256

Word address = 256/8 = 32Offset = 256 mod 8 = 0

(b) The program

The program written in Python, where comments are used to explain each line is as follows:

#This creates a list of physical address

pA = [0, 9, 27, 31,120, 256]

#This iterates through the list

for i in range(len(pA)):

   #This prints the word address

   print("Word Address:",(pA[i]//8))

   #This prints the offset

   print("Offset:",(pA[i]%8))

Read more about word address at:

https://brainly.com/question/17493537

For the description below, develop an E-R diagram:

A book is identified by its ISBN number, and it has a title, a price, and a date of publication. It is published by a publisher, each of which has its own ID number and a name. Each book has exactly one publisher, but one publisher typically publishes multiple books over time. A book is written by one or multiple authors. Each author is identified by an author number and has a name and date of birth. Each author has either one or multiple books; in addition, occasionally data are needed also regarding prospective authors who have not yet published any books. A book can be part of a series, which is also identified as a book and has its own 2 ISBN number. One book can belong to several sets and a set consists of at least one but potentially many books.

Answers

An E-R diagram for a library database would include entities for books, publishers, authors, and series, with relationships defined between them. A many-to-many relationship between authors and books, as well as books and series, requires the use of Junction Tables to effectively manage these complex relationships.

Development of an E-R Diagram Based on a Description

A book is identified by its ISBN number, and it has a title, price, and date of publication. Each book is published by a publisher that has a unique ID number and name. There is a one-to-many relationship between publishers and books since each book has exactly one publisher, but a publisher can publish multiple books. Conversely, a book is written by authors, and each author has an author number, name, and date of birth, indicating a many-to-many relationship between authors and books. To address this, we introduce a Junction Table to split the many-to-many into two one-to-many relationships. Each author could have written multiple books, and each book could have multiple authors.

Furthermore, books can be part of a series, with a series being identified as a book with its own ISBN number. A single book can belong to multiple series, creating a many-to-many relationship between books and series. Again, a Junction Table is needed to properly manage this relationship. The database also includes information about prospective authors who haven't published books yet, signifying the importance of having an authors' table regardless of publication status.

The Entity Relationship Modeling (ERM) process begins with determining the purpose of the database and listing all the necessary entities. These entities are then connected through relationships, with Junction Tables being used to resolve many-to-many relationships. Important attributes and keys for each entity are identified, ensuring that adequate information is recorded and can be retrieved effectively.

1) The program reads an integer, that must be changed to read a floating point. 2) You will need to move that number into a floating point register and then that number must be copied into an integer register. 3) You will need to extract the exponent from the integer register and stored in another register. 4) You will need to insert the Implied b

Answers

Answer:

1. Get the number

2. Declare a variable to store the sum and set it to 0

3. Repeat the next two steps till the number is not 0

4. Get the rightmost digit of the number with help of remainder ‘%’ operator by dividing it with 10 and add it to sum.

5. Divide the number by 10 with help of ‘/’ operator

6. Print or return the sum

# include<iostream>

using namespace std;

/* Function to get sum of digits */

class gfg

{

   public:

   int getSum(float n)

   {

   float sum = 0 ;

   while (n != 0)

   {

    sum = sum + n % 10;

    n = n/10;

   }

return sum;

}

};

//driver code

int main()

{

gfg g;

float n = 687;  

cout<< g.getSum(n);

return 0;

}

Explanation:

We are interested in creating a grid of n boxes by n boxes. Each box in the grid is 5 x 5 pixels and the surrounding black border is 1 pixel thick. The second last row and the second last column of the boxes are of cyan color (RGB = [0, 255, 255]), rest all are white. Write a program which displays such a grid based on the number of boxes given by the user. Assume that the user will always input a value greater than 4.

Answers

Answer:

clc

clear

size = input('Enter the number of boxes in a row : ');

for i=1:size

for j=1:size

if i==size-1 || j==2

rectangle('Position',[i*size,j*size,size,size],'FaceColor',[0,1,1],'EdgeColor','black',...

'LineWidth',3)

else

rectangle('Position',[i*size,j*size,size,size],'FaceColor',[1 1 1],'EdgeColor','black',...

'LineWidth',3)

end

end

end

Explanation:

1) Your program must contain functions to: deposit, withdraw, balance inquiry and quit. 2) Based on the selection made by the user the functions must be called with the following criteria: a. A user can deposit any amount of money in their account. The function must display the new balance after depositing. by. A person can withdraw an amount as long as it is lower than or equal to his current balance. The function must also display a warning if the new balance is below $100. Must not allow the user to withdraw if amount is great than current balance. Before this function ends - the new balance must be displayed. c. Balance inquiry function must display the balance.

Answers

Answer:

import java.util.Scanner;

public class num6 {

   static double balance = 10000.5; //Current Balance

   //The main Method

   public static void main(String[] args) {

       //Request User Input

       System.out.println("Enter 1 for deposit \nEnter 2 for Withdraw\nEnter 3 for Balance Enquiry\n0 to quit ");

       Scanner in = new Scanner(System.in);

       int op = in.nextInt();

       //Check to determine the Operation the user wants

       if(op == 1){

           System.out.println("Enter amount to deposit");

           double depositeAmount = in.nextDouble();

           deposit(depositeAmount); //Call the deposit method

       }

       if(op == 2){

           System.out.println("Enter amount to Withdraw");

           double withdrawAmount = in.nextDouble();

           //validate the withdraw amount

           if(withdrawAmount > balance){

               System.out.println("Insuffucient fund");

               System.out.println("Your current balance is "+balance);

           }

           else {

               withdraw(withdrawAmount);//Call withdraw Method

           }

           }

       if(op == 3){

           balanceEnquiry();

       }

   }

   //Deposit Method

   public static double deposit(double depositAmount){

       double newBalance = balance + depositAmount;

       System.out.println("You deposited "+depositAmount+"Your new balance is "+newBalance);

       return newBalance;

   }

   //Withdraw Method

   public static double withdraw(double withdrawAmount){

           double newBalance = balance - withdrawAmount;

       System.out.println("You Withdrew "+withdrawAmount+"Your new balance is "+newBalance);

           if(newBalance < 100){

           System.out.println("Your Balance is low");

       }

       return  newBalance;

   }

   //Balance Enquiry Method

   public static void balanceEnquiry(){

       System.out.println("Your current balance is "+balance);

   }

}

Explanation:

This is solved in Java programming language

See code explation provided as comments

2. Using the Enhanced for Statement, write an application that uses an enhanced for statement to sum the double values passed by the command-line arguments. [Hint: Use the static method parseDouble of class Double to convert a String to a double value.] This is sample run of your program: The·sum·of·the·double·values·passed·in·from·the·command·line·is·0.0↵

Answers

Answer:

Here is the program:

public class DoubleValue

{ public static void main(String[] args) { //start of the main function

 double sum = 0.0;  // initialize double type sum by 0.0

//for statement to sum the double values passed by the command-line //arguments

       for (String str : args)        {  

         sum += Double.parseDouble(str);  

//returns double representation of the passed str argument and takes the //sum of these double values         }

       System.out.printf("The sum of the double values passed in from the command line is %.1f\n", sum);  }  }      

//prints the above message with output 0.0                                  

Explanation:

The above program has a static method parseDouble of class Double to convert a string str to a double value and the for statement is used to sum the double values passed by command line arguments. This sum is stored in sum variable and is displayed in the output. The program along with its output is attached.

If you want to get the input from the user you can use the following code. Just use the Scanner class to take input from the user.

import java.util.Scanner;

public class DoubleValue

{ public static void main(String[] args) {

//two string type variables

 String str1;

               String str2;

//scans and reads input from user

Scanner input = new Scanner(System.in);

System.out.println("Enter value of str1: ");

str1 = input.next();

System.out.println("Enter value of str2: ");

str2 = input.next();

double sum = 0.0;

//sum double values and parseDouble function is used to convert string to //double value

sum += Double.parseDouble(str1) + Double.parseDouble(str2);

System.out.printf("The sum of the double values passed in from the command line is %.1f\n", sum); } }  //prints result of the sum

Final answer:

The code provided illustrates how to sum double values passed through command-line arguments in Java, using Double.parseDouble and an enhanced for loop, demonstrating important concepts in parsing and arithmetic operations in programming.

Explanation:

The question involves writing a Java application to sum double values passed through command-line arguments using an enhanced for loop, illustrating a practical application in parsing and arithmetic operations in programming. This task requires knowledge of Java's Double.parseDouble method and the enhanced for loop. To accomplish this, a main method is created where the command-line arguments are accessed. Each argument, which is initially a String, is converted to a double using Double.parseDouble, and then summed in an enhanced for loop. Here is a simple implementation:

public class SumDoubles {
   public static void main(String[] args) {
       double sum = 0.0;
       for (String arg : args) {
           sum += Double.parseDouble(arg);
       }
       System.out.println("The sum of the double values passed in from the command line is " + sum);
   }
}

This code snippet effectively addresses the task by converting command-line arguments from String to double and summing them. It demonstrates the use of command-line arguments, Double.parseDouble, and an enhanced for loop in Java.

Other Questions
Firms continue to produce (illegally) counterfeit computer software and documentation. Some of the illegal copies are Microsoft products, though Microsoft still has a large share of the market for its products. The presence of enforced copyright protection laws indicates that the market for Microsoft software cannot be considered a competitive market because: Susan is a partner of Andrusian Consulting, a consulting partnership. Susan agrees with Mimms Company that Andrusian will provide management consulting services for $75,000 to Mimms, if Mimms agrees to pay Susan $5,000 personally. What fiduciary duty will Susan breach, if Mimms pays her $5,000? A child with Duchenne muscular dystrophy is to receive prednisone as part of his treatment plan. After teaching the child's parents about this drug, which statement by the parents indicates the need for additional teaching?A) "We should give this drug before he eats anything."B) "We need to keep a close eye for possible infection."C) "The drug should not be stopped suddenly."D) "He might gain some weight with this drug." -12 = 4 is equivalent to? which sentence uses active voice?a. The bill was vetoed by the governor.b. the mechanic replaced the air filter.c. the celebrity was hounded by photographers.d. the decision was made by the whole committee. What percent of 125 is 25? Swifty Company has been having difficulty obtaining key raw materials for its manufacturing process. The company therefore signed a long-term noncancelable purchase commitment with its largest supplier of this raw material on November 30, 2017, at an agreed price of $382, 800. At December 31, 2017, the raw material had declined in price to $346, 730. What entry would you make on December 31, 2017, to recognize these facts? (Credit account titles are automatically indented when amount is entered. Do not indent manually. If no entry is required, select "No entry" for the account titles and enter 0 for the amounts.) 1.is the census a good way to gather demographic information about a place or country? explain why or why not2.explain what governments do with census information, or how it can be beneficial for a government to keep track of this data. A science teacher is unsure about the scores for the second batch of tests. Student scores on this last test are not at all similar to their scores on the test conducted two weeks ago. What problem with testing is the teacher confronted with I need help please! :v What do readers learn about Paul's father from indirectcharacterization in this passage?oHe acts cruelly toward his son.He believes he knows best.He is easily influenced by others.He is not sure of his son's abilities.When Ray Sutcliffe left us, I said to my daddy, "Youdidn't ask me if I wanted to ride that man's horse.""No, I didn't.""Well, why not? Maybe I wanted to ride for him.""Well, if you did or you didn't, I know better about thesethings," said my daddy. "Some of these horses aroundhere aren't half trained, some of them are skittish, andsome of them are just plain mean. Now, I've seen some ofthat man's horses, and maybe you could ride that grey hewas talking about if there were training time, but not juston a first ride. Not all folks train their horses same as wedo, and you riding a stranger's horse is just asking fortrouble. You could get thrown, you could get run over; ineither case possibly get yourself seriously hurt. No, I'mnot about to let you ride any horses except the ones webrought here."- The Land, Things Fall Apart- When Okonkwo insults Osugo for having no titles, the tribe reminds him to be humble. Why does Okonkwo believe he does not need to be humble? In cats, being awesome (A) is dominant to being average (a), and being bashful (B) is dominant to being boring (b). A male cat that is homozygous dominant for the A trait and heterozygous for the B trait is mated with a female cat that is homozygous recessive for both. Both the A and B traits assort independently from one another. What is the probability that they will have an offspring who is heterozygous for both traits? Choose 1 answer:(Choice A)50%(Choice B)100%(Choice C)0%(Choice D)25% Eva pumps up her bicycle tire until it has a gauge pressure of 413 kilopascals. If the surrounding air is at standard pressure, what is the absolute pressure in the bicycle tire?A.33.9 kPaB.49.7 kPaC.312 kPaD.514 kPa using the frequency table below find how many students receive a score of 70 or better on a mathematics test score and viral 50 mm are in 59 60-69 577-395-8897 1999 to Why were Navajos not allowed to speak their native language for many years starting inthe 1860s? low art or low culture music, tattoo, kitsch art critics maintain that these are sentimental works that are viewed as tasteless decoration.Are they? QUESTIONING STRATEGIESIf a cone shares a base with a cylinder, and thevolume of the cylinder is given, along with theheights of the cylinder and of the cone, how couldyou find the volume of the cone? Adding some substance to the cycle of violence idea, Lonnie Athens coined the phrase violentization process to describe the whole process an individual must go through to end up as a violent offender later in life. What are the four components to the violentization process? A certain circle can be represented by the following equation. x2 + y2 + 10x + 12y + 25 = 0. What is the center of this circle? What is the radius of this circle? Please help!