Questions
JAVA SHOW YOUR OUTPUT package exampletodo; import java.util.Arrays; import stdlib.*; /** * Edit the sections marked...

JAVA SHOW YOUR OUTPUT

package exampletodo;

import java.util.Arrays;

import stdlib.*;

/**

* Edit the sections marked TODO

*

* Unless specified otherwise, you must not change the declaration of any

* method.

*/

public class example {

       /**

       * valRange returns the difference between the maximum and minimum values in the

       * array; Max-Min. Precondition: the array is nonempty. Your solution must go

       * through the array at most once.

       *

       * Here are some examples (using "==" informally):

       *

       * <pre>

       *    0 == valRange (new double[] { -7 })

       *    10 == valRange (new double[] { 1, 7, 8, 11 })

       *    10 == valRange (new double[] { 11, 7, 8, 1 })

       *    18 == valRange (new double[] { 1, -4, -7, 7, 8, 11 })

       *    24 == valRange (new double[] { -13, -4, -7, 7, 8, 11 })

       *

       * The code below is a stub version, you should replace the line of code

       * labeled TODO with code that achieves the above specification

       * </pre>

       */

       public static double valRange(double[] list) {

             return -1; // TODO 1: fix this code

       }

       /**

       * posOfLargestElementLtOeT returns the position of the largest element in the

       * array that is less than or equal to the limit parameter if all values are

       * greater than limit, return -1;

       *

       * Precondition: the array is nonempty and all elements are unique. Your

       * solution must go through the array exactly once.

       *

       * <pre>

       *   0 == posOfLargestElementLtOeT(3, new double[] { -7 })                      // value:-7 is in pos 0

       *   5 == posOfLargestElementLtOeT(3, new double[] { 11, -4, -7, 7, 8, 1 }),    // value:1 is in pos 5

       * -1 == posOfLargestElementLtOeT(-7, new double[] { 1, -4, -5, 7, 8, 11 }),   // all elements are > -7

       *

       * The code below is a stub version, you should replace the line of code

       * labeled TODO with code that achieves the above specification

       * </pre>

       */

       public static int posOfLargestElementLtOeT(double limit, double[] list) {

             return -2; // TODO 2: fix this code

       }

       /**

       * isPerfectNumber determines (true or false) if a given number is a 'Perfect

       * Number'

       *

       * A perfect number is one that is equal to the sum of its proper divisors.

       * Example 1: 6; the proper divisors are 1, 2, 3 ; 1+ 2 + 3 is 6, so 6 IS a

       * perfect number Example 2: 15; the proper divisors are 1, 3, 5 ; 1 + 3 + 5 is

       * 9, so 15 IS NOT a perfect number Example 3: 28; the proper divisors are 1, 2,

       * 4, 7, 14; 1 + 2 + 4 + 7 + 14 is 28, so 28 IS a perfect number

       *

       * Precondition: number is a positive integer

       *

       * The code below is a stub version, you should replace the line of code labeled

       * TODO with code that achieves the above specification

       *

       * Hint: find the sum of the proper divisors

       */

       public static boolean isPerfectNumber(int number) {

             return false; // TODO 3: fix this code

       }

In: Computer Science

Design the Python GUI to display the temperature & humidity on two gauges. - Use the...

Design the Python GUI to display the temperature & humidity on two gauges.

- Use the Tkinter Canvas Widget.

- The gauge should be in a separate file and can be integrated using the import directive.

- The gauge should have at least two parameters; e.g. the range (scale: min-max) and the fill color of the moving arc. You are free to add more.

You have to design the gauge and not import it

****PYTHON code*****

In: Computer Science

Your HTML document should contain the following elements/features: HTML tags: An <input> tag labeled "Timer Duration"...

Your HTML document should contain the following elements/features:

  1. HTML tags:
    1. An <input> tag labeled "Timer Duration" with the initial value 0
    2. A <button> tag labeled "Start"
  2. Script: When the user presses the button (1b), a function will begin that does the following:
    1. Reads the value from the input field (1a)
    2. Removes the <input> and <button> tags (1a & 1b)
    3. Creates a new <p> tag, initialized to show the input value
    4. Starts a timer that ticks down to zero. For every second that elapses, the paragraph tag (2c) will show the updated timer value (i.e., one less)
    5. When the timer reaches zero, the countdown will stop and the paragraph tag (2c) will be removed and be replaced by a <button> tag labeled "New Timer"
    6. When the <button> tag (2e) is pressed, it will be removed and the <input> and <button> tags (1a, 1b) will be recreated with their original formats

In: Computer Science

Having trouble with the Luhn algorithm for java. Everything works great except for when cthe number...

Having trouble with the Luhn algorithm for java. Everything works great except for when cthe number 5105105105105109 is entered. I'm sure there are other numbers that do this, but this returns check digit as 10 when it should come back as 0. Suggestions? here is the algorithm and then my current code without the prints because my error is in the math. I am not allowed to use break.

Another key part of the credit card number standard is the check digit. The last digit of every credit card number is determined by the previous 15 digits through a simple mathematical formula known the Luhn Algorithm. The Lhun Algorithm can be used to check if a credit card number has been corrupted in its transmission between the vendor reading the card, and the bank which has the account. It can also be used to check to see if a credit card number is valid before transmitting it to the bank.

The Luhn Algorithm is described at the link above, but the basic idea is:

  1. From the right-to-left, double the value of each digit that is in an even-numbered position (with the check-digit at position 1). If this doubling gives you a two-digit value for any of the numbers, then subtract 9 from the value (which is easier than adding the digits together but gets you the same result). Leave the odd-valued positions as is.
  2. Sum together all of the values except the check digit.
  3. Take the digit in the one's position of the sum. If the value of that digit is 0, then it stays as 0. If the value is greater than zero, subtract that value from 10. That value should be the check digit (note that the special case for 0 is required since "10" is not a single digit).

For example, suppose the card you want to validate is: 5457623898234113. In this case the check-digit is 3 and the remaining digits are the 15-digit account number. We can confirm that we likely have a good card number by validating the check digit as follows:

Position 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
Original Value 5 4 5 7 6 2 3 8 9 8 2 3 4 1 1 3
Doubled value 10 10 12 6 18 4 8 2
Doubled-value adjusted 1 1 3 6 9 4 8 2
Sum of values = 67 1 4 1 7 3 2 6 8 9 8 4 3 8 1 2
Check digit is 3 (10 - 7 = 3)

You can read more about credit card numbers, as well as how the Luhn Algorithm is used in other areas of Computer Science, in this article from the Data Genetics blog (where the above example was taken from).

For this lab you will write a Java program that checks credit card strings to see if they are valid. Your program should first prompt the user to enter a string of numbers as a credit card number, or enter a blank line to quit the program. If the user doesn't quit, your program should ensure that this string is exactly 16 characters in length. If the user enters a string that is not 16 characters in length, your program should print an error message and ask again for a valid string. Your program should use the Luhn Algorithm above to compute what the check digit should be and then compare it to the actual value in the provided string and report whether the credit card number is valid or wrong. If it is wrong, your program should report what the correct check digit should be for the input value. Your program should keep asking for new values until the user enters a blank line to quit the program.

Create a new project named LuhnAlgorithm and a new Java program in that project folder named LuhnAlgorithm.java for this project. You can find a selection of valid-but-fake credit card numbers courtesy of PayPal at this link. Change the check digit on any of them to get an invalid number (note that your code should only use the 16 digit numbers and does not have to account for any of the card numbers that have any number of digits other than 16).

NOTE: You do NOT need to use arrays to solve this problem - this problem can be solved just with nested loops. Solutions that use an array where it isn't needed will be penalized in two ways: First, you're making the problem much harder than it needs to be, and second there will be a point deduction for use of an unnecessary array in the solution.

Sample Output: This is a sample transcript of what your program should do. Items in bold are user input and should not be put on the screen by your program.

Enter a credit card number (enter a blank line to quit): 5457623898234112
Check digit should be: 3
Check digit is: 2
Number is not valid.

Enter a credit card number (enter a blank line to quit): 5457623898234113
Check digit should be: 3
Check digit is: 3
Number is valid.

Enter a credit card number (enter a blank line to quit): 5555555555554
ERROR! Number MUST have exactly 16 digits.

Enter a credit card number (enter a blank line to quit): 5555555555554445
Check digit should be: 4
Check digit is: 5
Number is not valid.

Enter a credit card number (enter a blank line to quit): 
Goodbye!

import java.util.Scanner;

public class LuhnAlgorithm {

public static int Luhn(String credNum) {

int sum = 0;

for(int i = 15; i >= 0; i--) {

/* initializing i as 15, making sure the number is greater than 0, decrementing i */

if(i % 2 == 0) {

/* if int i is even */

int credDigit = 2*(credNum.charAt(i) - '0');

/*int credDigit is 2 times the number at the index listed */

if(credDigit > 9)

/* if the number doubled is in the double digits */

credDigit = ((credDigit % 10) - 9);

sum += credDigit;

/* subtract credDigit by 9 */

}

else

sum += (credNum.charAt(i) - '0');

/* Otherwise, add the number at the index listed to the sum */

}

sum -= (credNum.charAt(15) - '0');

return (10 - sum % 10);

/* returns the check digit */

}

In: Computer Science

Question 4 [25 marks] [25 marks] Downloaded Bitmap files or images have lower resolutions when downloaded...

Question 4
[25 marks]
[25 marks]
Downloaded Bitmap files or images have lower resolutions when downloaded from the internet. Discuss into details how such files or images can be resolved and printed on a large format printer without losing its quality.

In: Computer Science

i could use the flowchart and pseudocode solutions for the following: 1.       1.  Draw a structured flowchart describing...

i could use the flowchart and pseudocode solutions for the following:

1.       1.  Draw a structured flowchart describing the steps you would take to bake pancakes in a pan.  Include at least one decision.

2.       2.  Create the pseudocode to go along with the flowchart created in question above.

In: Computer Science

How can stakeholders and departments be involved during the cybersecurity policy life cycle?

How can stakeholders and departments be involved during the cybersecurity policy life cycle?

In: Computer Science

C language you are to write a a program that will first read in the heights...

C language
you are to write a a program that will first read in
the heights and weights of a series of people from a file named 
values.dat.  Create this file using your editor so that each line
contains a height and corresponding weight.  For instance, it might look likea:

69.0  125.0
44.0  100.0
60.0  155.0
49.0  190.0
65.0  115.0
50.0  80.0
30.0  129.0
72.0  99.0
68.0  122.0
50.0  105.0
and so on.
The formula for the standard deviation of a series of numbers x[0], x[1] ... x[n] is

std = sqrt( sum( (x[i] - xbar)**2 ) / (n) )

where xbar is the average value of x, n is the number of people,
and **2 means squared.

------header file------

#define MAXNUM 100

typedef struct person

{

double height;

double weight;

} Person;

//prototypes follow:

int getData(FILE *input, Person people[]);

void getAverages(Person people[], double *aveHeight, double *aveWeight, int

numPeople);

void getStandardDevs(Person people[], double aveHeight, double aveWeight,

double *stdHeight, double *stdWeight, int numPeople);

--------main template ----------

#include <stdio.h>

#include <stdlib.h>

#include <math.h>

#define MAXNUM 100

#include "stats.h"

void main( void )

{

FILE *input;

Person people[MAXNUM];

int numPeople = 0;

double aveHeight = 0.0, aveWeight = 0.0, stdHeight = 0.0, stdWeight = 0.0;

numPeople = getData(input, people);

getAverages(people, &aveHeight, &aveWeight, numPeople);

getStandardDevs(people, aveHeight, aveWeight, &stdHeight, &stdWeight, numPeople);

printf("\n\n\n\n\n\nThe average height is %lf\n", aveHeight);

printf("The average weight is %lf\n", aveWeight);

printf("The standard deviation of the heights is %lf\n", stdHeight);

printf("The standard deviation of the weights is %lf\n\n\n\n\n\n", stdWeight);

}

int getData( FILE* input, Person people[])

{

int numPeople = 0;

input = fopen( "values.dat", "r" ); // How to read file

if ( input == NULL )

{

printf( "\"values.dat\" does not exist!!\n" );

}

/*

your code here

*/

fclose(input);

return numPeople;

} // getData()

void getAverages( Person people[], double* aveHeight, double* aveWeight, int

numPeople)

{

/*

your code here

*/

} // getAverages()

void getStandardDevs( Person people[], double aveHeight, double aveWeight, double*

stdHeight, double* stdWeight, int numPeople )

{

/*

your code here

*/

} // getStandardDevs()

In: Computer Science

Ting, D. S., Liu, Y., Burlina, P., Xu, X., Bressler, N. M., & Wong, T. Y....

Ting, D. S., Liu, Y., Burlina, P., Xu, X., Bressler, N. M., & Wong, T. Y. (2018). AI for medical imaging goes deep. Nature medicine, 24(5), 539-540.

2. Pesapane, F., Codari, M., & Sardanelli, F. (2018). Artificial intelligence in medical imaging: threat or opportunity? Radiologists again at the forefront of innovation in medicine. European radiology experimental, 2(1), 35.

3. Lewis, S. J., Gandomkar, Z., & Brennan, P. C. (2019). Artificial Intelligence in medical imaging practice: looking to the future. Journal of Medical Radiation Sciences, 66(4), 292-295.

4. Alexander, A., Jiang, A., Ferreira, C., & Zurkiya, D. (2020). An intelligent future for medical imaging: a market outlook on artificial intelligence for medical imaging. Journal of the American College of Radiology, 17(1), 165-170.

5. Ranschaert, E. R., Morozov, S., & Algra, P. R. (Eds.). (2019). Artificial Intelligence in Medical Imaging: Opportunities, Applications and Risks. Springer.

Please write short summary for each link around 15-20 lines (paragraph)

In: Computer Science

Explain why has information visualization nowadays become a key element in business intelligence and business analytics....

Explain why has information visualization nowadays become a key element in business intelligence and business analytics. What is the difference between information visualization and visual analytics?

In: Computer Science

Can someone write very similar code to this but have it read the Absolute value, Cos,...

Can someone write very similar code to this but have it read the Absolute value, Cos, Sin, and Tan. Also, have it pass from the main method.

import java.util.Scanner;
public class Manymethods{
public void Max ()
  

{
Scanner scan = new Scanner( System.in);
int [] arr = new int [4];
arr = new int [4];
int i = 0, s = 0;
for (i = 0; i < 4; i++)
{
arr[i] = scan.nextInt ();
if(arr[i] > s)
s=arr[i];
System.out.println(arr[i] + " " + s);
}
}
public void Min ()
  

{
Scanner scan = new Scanner( System.in);
int [] arr = new int [4];
arr = new int [4];
int i = 0, s = 0;
for (i = 0; i < 4; i++)
{
arr[i] = scan.nextInt ();
if(arr[i] < s)
s=arr[i];
System.out.println(arr[i] + " " + s);
}
}
public void Add ()
  

{
Scanner scan = new Scanner( System.in);
int [] arr = new int [4];
arr = new int [4];
int i = 0, s = 0;
for (i = 0; i < 4; i++)
{
arr[i] = scan.nextInt ();
if(arr[i] > s)
s=arr[i] +s;
System.out.println(arr[i] + " " + s);
}
}
public void Multi ()
  

{
Scanner scan = new Scanner( System.in);
int [] arr = new int [4];
arr = new int [4];
int i = 0, s = 1;
for (i = 0; i < 4; i++)
{
arr[i] = scan.nextInt ();
s = arr[i] * s;
System.out.println(arr[i] + " " + s);
}
}
public static void main(String[] args) {
Manymethods m = new Manymethods();
System.out.println("We will call Maxmethod now");

m.Max();
System.out.println("We will call Minmethod now");
m.Min();
System.out.println("We will call Additionmethod now");
m.Add();
System.out.println("We will call Multimethod now");
m.Multi();
}
  
}

In: Computer Science

How does a IS or cybersecurity policy differ from a traditional organizational policy?

How does a IS or cybersecurity policy differ from a traditional organizational policy?

In: Computer Science

Write a member function named deleteItemAtIndex(). You will need to search till you get to the...

Write a member function named deleteItemAtIndex(). You will need to search till you get to the index'thed node in the list. But at that point you should remove the node (and don't forget to delete it, to free up its memory). If the asked for index does not exist, as usual you should thow a LinkedListItemNotFound exception. Here is the main and LinkedList cpp - https://paste.ofcode.org/37gZg5p7fiR243AD4sD5ttU

Any help is appreciated, I don't have much time left

In: Computer Science

How should the IS or Cybersecurity Policy align with the corporate culture and strategy?

How should the IS or Cybersecurity Policy align with the corporate culture and strategy?

In: Computer Science

convert the code to the flow chart char counter; void wait() { delay_ms(1000); } void main()...

convert the code to the flow chart

char counter;

void wait() {

delay_ms(1000);

}

void main() {

TRISB=0x00; // set direction to be output

PORTA=0x00; // turn off the PORTA leds

PORTB=0x00; // turn off the PORTB leds

PORTC=0x00; // turn off the PORTC leds

PORTD=0x00; // turn off the PORTD leds

while (1){

for (counter = 15; counter>0 ; counter= --) {

PORTB = counter;

wait();

}

}

}

In: Computer Science