Questions
Develop an algorithm for INSERTION SORT. Give the pseudo-code version. Convert your pseudo-code into a Java...

Develop an algorithm for INSERTION SORT. Give the pseudo-code version. Convert your pseudo-code into a Java program.

In: Computer Science

Discuss the importance of having security policies in place.

Discuss the importance of having security policies in place.

In: Computer Science

Define Artificial intelligence and explain that role it could have in healthcare in the future

Define Artificial intelligence and explain that role it could have in healthcare in the future

In: Computer Science

In Java: Write a program that prompts the user to enter a positive number until the...

In Java:

Write a program that prompts the user to enter a positive number until the user input a negative number. In the end, the program outputs the sum of all the positive numbers.

You should use do-while loop (not while, not for). You cannot use break or if statement in the lab.

Hint: if the program adds the last negative number to your sum, you can subtract the last number from the sum after the loop.

In: Computer Science

1- Definition and introduction of its layer 2- Explain the network functions 3- Explain the data...

1- Definition and introduction of its layer
2- Explain the network functions
3- Explain the data transfer method in the network
4- Mention the protocols if there is and explain them
5- Network positives and negatives effect

for

physical layer

data link layer

network layer

transport layer

presentation layer

application layer

and the tcp/ip

In: Computer Science

Changes in the economy have determined that for the EZ shipping company, a surcharge will be...

Changes in the economy have determined that for the EZ shipping company, a surcharge will be assessed on all packages that meet certain criteria. The surcharge is a function of the characteristics of the package and the zip code to which it is sent.

1. The regular charges for shipping are calculated as follows:
     For all weights five pounds and under, the shipping cost is $12.00.

     For weights over five pounds, the charge is calculated as follows:
                        If length * width * height + weight is:

greater than 5 and less than or equal to 15, the shipping cost is 14.00

greater than 15 and less than or equal to 34, the shipping cost is 17.00

greater than 34 and less than or equal to 45, the shipping cost is 21.00

greater than 45 and less than or equal to 60, the shipping cost is 33.00

greater than 60, the shipping cost is 105.00

2. The additional charges are calculated as follows:

            If the first digit of the zip code is a "4" then there is an additional surcharge of 5% on the shipping cost.

If the first digit of the zip code is a "6" then there is an additional surcharge of 9% on the shipping cost.

For all other zip codes there is an additional surcharge of 14% on the shipping cost.

3. Finally, if the zip code is even, then there is an additional surcharge of 2% of the shipping

            cost.

Write a program that allows the user to input (in this order) the zip code, weight, length, width and height of the package then prints out the following:

The zip code and dimensions of the package

The shipping cost

The surcharge

The total shipping cost (shipping cost plus surcharge(s))

I have written out the code and have been able to get it to run but when I added in the 2% for even numbers portion of my code every thing went weird with my outputs. Every thing still compiles and works but I am not recieving the outputs I desire. Any help remedying this would be greatly appreciated.

import java.util.Scanner;
   //allows use of scanner for keyboard inputs
  
public class Shipping
   // Class titling
{


public static void main(String[] args)

   {

{
int zip;
double weight;
double length;
double width;
double height;
double surcharge;
double surcharge2;
double shippingCost;
  
   //Variables that will need defining for the shipping process
  
Scanner keyboard = new Scanner(System.in);
System.out.println("Hello, Welcome to EZ Shipping services! \n Please input the important details of your shipment when prompted");
System.out.println("What is the weight of your package? ");
weight = keyboard.nextDouble();
System.out.println("What is the length of your package? ");
length = keyboard.nextDouble();
System.out.println("What is the width of your package? ");
width = keyboard.nextDouble();
System.out.println("What is the height of youre package? ");
height = keyboard.nextDouble();
  
//Print outs for package detail inputs

double packages=length*width*height+weight;
//Package variables combined and stored
   {
shippingCost = 12;
//Stock sipping cost 12$

   }
  
if (weight >5)
   {
if (packages >=5.1 || packages <= 15)
   {
shippingCost= 14;
// if the package weight is above 5 but less than 15 the cost is increased to 14$
   }
else if (packages >= 15.1 || packages <= 34 )
   {
shippingCost= 17;
// if the package weight is above 15 but less than 34 the cost is increased to 17$
   }
else if (packages >= 34.1 || packages <= 45)
   {
shippingCost= 21;
// if the package weight is above 34 but less than 45 the cost is increased to 21$

   }
else if (packages >= 45.1|| packages <= 60)
   {
shippingCost= 33;
// if the package weight is above 45 but less than 60 the cost is increased to 33$

   }
else if (packages > 60)
   {
shippingCost= 105;
// if the package weight is above 60 cost is increased to a flat 105$

   }
}
System.out.println("What is your zip code? ");
zip = keyboard.nextInt();
  
if(zip == 4)
   {
surcharge = shippingCost*0.05;
// if the zip code starts with a 4 a 5% surcharge is added
   }
   else if(zip == 6)
   {
surcharge = shippingCost*0.09;
// if the zip code starts with a 6 a 9% surcharge is added
   }
   else
   {
surcharge = shippingCost*0.14;
// all other zip codes have a 14% surcharge added
   }
  
{
  
   if (zip % 2 == 0 );
surcharge2 = shippingCost*.02;
// calculation for if package is even zip code or not, if even add surcharge of 2%
}
double cost = shippingCost + surcharge + surcharge2;
// calculation for cost
double total;
total = shippingCost + surcharge + surcharge2 + packages;
// calculation for total

System.out.print("The Shipping Cost $"+ cost);
System.out.print(" Total with charges $"+ total);
// Final read out
   }
}
}

In: Computer Science

Write a program in C that sorts 3 given numbers, defined as (a,b,c) from highest to...

Write a program in C that sorts 3 given numbers, defined as (a,b,c) from highest to lowest.

I already have this code finding the maximum. Need to just add the sorting code onto it.

int A, B, C;

A = 4;

B=3;

C=7;

Max = A

If (B > max)

{

Max = B;

}

Else if (c > max)

{

Max = c;

}

In: Computer Science

Write the header and the implementation files (.h and .cpp separately) for a class called Course,...

  1. Write the header and the implementation files (.h and .cpp separately) for a class called Course, and a simple program to test it (C++), according to the following specifications:                   
  1. Your class has 3 member data: an integer pointer that will be used to create a dynamic variable to represent the number of students, an integer pointer that will be used to create a dynamic array representing students’ ids, and a double pointer that will be used to create a dynamic array to represent the GPAs of each student.
  1. Your class has the following member functions:

       

  1. a constructor with an int parameter representing the number of students; the constructor creates the dynamic variable and sets it to the int parameter, creates the two dynamic arrays and sets everything to zero.

  1. a function which reads in all the ids and the GPAs into the appropriate arrays.
  1. a function called print_info which, for each student, does all of the

                following:

                It prints the student’s id and GPA. If the student’s GPA is greater than or equal to 3.8, it prints “an honor student”.

  1. a destructor (hint: delete array)
  2. create 5 random instances of Course objects to represents 5 sessons of CSC211, each session includes 20 students, assign random score to each student, calculate the average GPA of all 100 students.

In: Computer Science

1. Consider the loop from Section 8.3 of your textbook. prefixes = 'JKLMNOPQ' suffix = 'ack'...

1. Consider the loop from Section 8.3 of your textbook.


prefixes = 'JKLMNOPQ'
suffix = 'ack'

for letter in prefixes:
print(letter + suffix)

Put this code into a Python script and run it. Notice that it prints the names "Oack" and "Qack".

Modify the program so that it prints "Ouack" and "Quack" but leaves the other names the same.

Include the modified Python code and the output in your submission.

2. Give at least three examples that show different features of string slices. Describe the feature illustrated by each example. Invent your own examples. Do not copy them for the textbook .

In: Computer Science

DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table as...

DBMS Create/Insert/Update SQL

I need the create, insert, and update SQL statement for this table as if it were being added to MySQL (please give explanations for each line of SQL code and a copy of the code as it would be entered into the query by itself:

Customer
PK Customer ID Text
Phone Number int
name text
address ID int
email text
FK vendor ID int

Vendor is the name of the table the FK comes from.

In: Computer Science

Similar to in HW1, you'll implement a left shift of decimals in a string, with combining...

Similar to in HW1, you'll implement a left shift of decimals in a string, with combining of multiple like digits into a single digit of double the value. The main difference between HW1 and this is that now the string representing a row in 2048 can be of any length! You'll implement a Combine class in a comparable .java file.

As before, the input string can only include the characters '_', '2', and '4'. Unlike before, it can be of any length (including length 0). Any '2's that have no other characters or any number of '_'s between them combine to become a '4'(i.e. two '2's disappear, and a '4' is left in one of their space). Likewise, '4's become '8's. Any digit that is the result of a combination cannot be combined with another digit. All digits are combined in this way and shifted to the far left so that any '_' appear on the right of the string. The length of the string remains unchanged.

Your classes will implement the Combinable interface. Note that we're attaching an updated version so be sure to use the new one. You will implement multiple methods from the interface Combinable:

  • public boolean validateChar(char ch)

    The requirements remain unchanged from HW1.

  • public boolean validateRow(String s)

    The string must include only the characters discussed above, but it can be of any length. Return true if it includes only valid characters, false otherwise. You must invoke validateChar to determine validity of each character.

  • public String repeat(char ch, int num)

    Create a string that consists of num, ch characters.

  • public String eliminateUnderscores(String s)

    Given a String s, return a new String that has all '_' characters removed. You cannot use the replace method in the String Class. Note that the returned string will be of the same or lesser length than the argument.

  • public String moveLeft(String s)

    All non-'_' characters in the input string are shifted to the left of the string, leaving only '_'s on the right-hand side of the string. The resulting "left-shifted" String is returned. It is highly suggested that you first use eliminateUnderscores to cluster all the non-'_' characters, and then to use repeat to concatenate the appropriate number of '_' on to the right of the String that is returned. Most other ways to implement this method are far more complicated.

    You must invoke the validateRow method to test if
    the input String is valid. If it is not, return the input string directly without change.

  • public String combineLeft(String s)

    Given the input string, the output should be a string of the same length, with all '_'s removed from the left side of the string, and with all pairs of like digits with only '_'s in between them, combined into a digit of twice the value. Return the resulting String.

    It is highly suggested that you use the moveLeft method to help you with this implementation. When generating your new string, it is much easier to be able to ignore all '_' between digits.

    You must invoke the validateRow method to test if the input String is valid. If it is not, return the input string directly without change.

Some example assertions:

assert validateChar('_');
assert !validateChar(' ');

assert validateRow("2222");
assert validateRow("_24_");
assert !validateRow("2234_");
assert validateRow("");
assert !validateRow("*");

assert "***".equals(repeat('*', 3));
assert "".equals(repeat('*', 0));
assert "44444444".equals(repeat('4', 8));

assert "4".equals(eliminateUnderscores("__4__"));
assert "244".equals(eliminateUnderscores("2_4_4_"));
assert "".equals(eliminateUnderscores("___"));
assert "242442".equals(eliminateUnderscores("242442"));

assert "4____".equals(moveLeft("__4__"));
assert "244___".equals(moveLeft("2_4_4_"));
assert "___".equals(moveLeft("___"));
assert "_3_".equals(moveLeft("_3_")); 
assert "242442".equals(moveLeft("242442"));

assert "484___".equals(combineLeft("224422"));
assert "484________".equals(combineLeft("2_2_4_4_2_2"));
assert "242424__".equals(combineLeft("242_42_4"));
assert "828____".equals(combineLeft("__44244"));
assert "".equals(combineLeft(""));
assert "22344".equals(combineLeft("22344"));

assert "88__________".equals(combineLeft(combineLeft("_2_22_222_4_")));

Here is the first code:

public class Combine implements Combinable {

   public boolean validateChar(char ch)
   {
//Write your Code Here
       return true;
   }
  
   public boolean validateRow(String row)
{
//Write your Code Here
       return true;
   }
  
   public String repeat(char ch, int num)
{
//Write your Code Here
        return "";
   }

   public String eliminateUnderscores(String row)
{
//Write your Code Here
return "";  
}

   public String moveLeft(String row)
{
//Write your Code Here
       return "";
   }

   public String combineLeft(String row)
{
//Write your Code Here
       return "";
   }
  
    public static void main(String[] args)
{
Combine CM=new Combine();
       assert CM.validateChar('_');
       assert !CM.validateChar(' ');

       assert CM.validateRow("2222");
       assert CM.validateRow("_24_");
       assert !CM.validateRow("2234_");
       assert CM.validateRow("");
       assert !CM.validateRow("*");

       assert "***".equals(CM.repeat('*', 3));
       assert "".equals(CM.repeat('*', 0));
       assert "44444444".equals(CM.repeat('4', 8));

       assert "4".equals(CM.eliminateUnderscores("__4__"));
       assert "244".equals(CM.eliminateUnderscores("2_4_4_"));
       assert "".equals(CM.eliminateUnderscores("___"));
       assert "242442".equals(CM.eliminateUnderscores("242442"));

       assert "4____".equals(CM.moveLeft("__4__"));
       assert "244___".equals(CM.moveLeft("2_4_4_"));
       assert "___".equals(CM.moveLeft("___"));
       assert "_3_".equals(CM.moveLeft("_3_"));
       assert "242442".equals(CM.moveLeft("242442"));

       assert "484___".equals(CM.combineLeft("224422"));
       assert "484________".equals(CM.combineLeft("2_2_4_4_2_2"));
       assert "242424__".equals(CM.combineLeft("242_42_4"));
       assert "828____".equals(CM.combineLeft("__44244"));
       assert "".equals(CM.combineLeft(""));
       assert "22344".equals(CM.combineLeft("22344"));

       assert "88__________".equals(CM.combineLeft(CM.combineLeft("_2_22_222_4_")));

       System.out.println("All tests passed.");
   }
}

Here is the second code:

public interface Combinable {
//checking if the character is a valid character
   public boolean validateChar(char ch);
  
//checking if a row contains the correct set of characters
   public boolean validateRow(String row) ;

//Create a string that consists of num, ch characters.
   public String repeat(char ch, int num) ;
  
//Removing the undescore from the row
   public String eliminateUnderscores(String row) ;
  
//Shifting the numbers to the left if there is any open spance
   public String moveLeft(String row) ;

//Combining the equal numbers in the row 22_ > 4__
   public String combineLeft(String row) ;

}

In: Computer Science

Some of the encoding techniques used over fiber are Manchester, 4B5B, and 8B10B. What are these...

  1. Some of the encoding techniques used over fiber are Manchester, 4B5B, and 8B10B. What are these encoding methods?

In: Computer Science

Bus ticket reservation project in java using class ,inheritance,interface

Bus ticket reservation project in java using class ,inheritance,interface

In: Computer Science

Lab 3.1 Create your objects in the stack (not on the heap). Add a friend function,...

Lab 3.1

Create your objects in the stack (not on the heap). Add a friend function, kilotopound, which will convert kilograms to pounds. Change your weight mutator to ask whether weight is input in kilograms or pounds. If it is kilograms, call the friend function kilotopound to convert it to pounds and return pounds.

There are 2.2 pounds in one kilogram.

Create an object on the stack with the following information:

   

uld – Container

abbreviation - AYK

uldid – AYK68943IB

aircraft - 737

weight – 1654 Kilograms

destination – PDX

Output the contents of your object.

-------------------------------------------------------------------------------------------------------------------------------------

Lab 3.2

Utilizing Lab 3.1 code, add a copy constructor.

Create an object on the stack using the following data:

uld – Container

abbreviation - ABB

uldid – ABB31545IB

aircraft - 737

weight – 1156

destination – BUR

Copy the first object using a copy constructor. Output the contents of both objects.

In: Computer Science

Discuss how to use R programming to solve the following problem. You’re not just writing the...

Discuss how to use R programming to solve the following problem. You’re not just writing the R code, you are also discussing the process.

  1. Given a person’s full name in the format of firstName middleName lastName such as Michael Carlos Dumas,
    1. write R code(s) to convert it to the format of lastName, middleInitial, firstName.

      In the case of Michael Carlos Dumas, the converted name is Dumas, C. Michael. Your solution should work with any names that comply with the format.
      (Hint: use str_split in stringr library to parse the full name).

In: Computer Science