Questions
Question about Java ArrayList: how to delet congestive number: eg : [1 2 2 3 2...

Question about Java ArrayList:

how to delet congestive number:

eg : [1 2 2 3 2 2 1] -----> [1 2 3 2 1]

how to get the number that only in one list:

eg:

[2 2 1], [ 4 4 2 2], [8 8 4 4 2] -------->[1,8]

[8 8 4 4 2], [4 4 2 2], [2 2 1] --------->[1,8]

Thanks in advance

In: Computer Science

Java. Complete the methods for infixToPostfix, postfixToInfix, solvePostfix. import java.util.Stack; public class B1Work {    /*...

Java. Complete the methods for infixToPostfix, postfixToInfix, solvePostfix.

import java.util.Stack;

public class B1Work {
   /*
   * Grading:
   * Correctly converts infix to postfix - 3pts
   */
   public static String infixToPostfix(String infix) {
       /*
       * Convert an infix math formula to postfix format
       * Infix format will always include parens around any two values and a symbol
       * You will not need to imply any PEMDAS rules besides parens
       * EXAMPLES:
       * infix: (1+2) postfix: 12+
       * infix: (1+(2-3)) postfix: 123-+
       * infix: ((1+2)-3) postfix: 12+3-
       * infix: ((1+2)-(3*4)) postfix: 12+34*-
       */
       return null;
   }
   /*
   * Grading:
   * Correctly converts postfix to infix - 2pts
   */
   public static String postfixToInfix(String postfix) {
       /*
       * Convert a postfix math formula to an infix format
       * See above for conversion examples
       * Make sure to include parens in the infix format
       */
       return null;
   }
   /*
   * Grading:
   * Correctly solves postfix formulas with +-/* - 1pt
   */
   public static double solvePostfix(String postfix) {
       Stack<Integer> stack = new Stack<>();
       /*
       * Use a Stack to help solve a postfix format formula for the numeric answer
       * Order of operations is implied by where symbols/numbers exist
       * EXAMPLES
       * postfix: 12+ = 3
       * postfix: 123-+ = 0 :: 2-3 = -1 :: 1 + (-1) = 0
       */
       return 0;
   }
}

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

import java.util.Scanner;

public class B1Driver {

   public static void main(String[] args) {
       Scanner s = new Scanner(System.in);
       String format = "";
       do {
           System.out.print("What format will your formula be in (infix/postfix):");
           format = s.nextLine().toLowerCase();
       }while(!(format.equals("infix") || format.equals("postfix")));
       System.out.print("Enter your formula:");
       String formula = s.nextLine().replaceAll(" ", "");//removes whitespace
       String infix, postfix;
       switch(format) {
       case "infix":
           infix = formula;
           postfix = B1Work.infixToPostfix(infix);
           System.out.println("Infix:"+infix);
           System.out.println("Postfix:"+postfix);
           System.out.println("Answer:"+B1Work.solvePostfix(postfix));
           break;
       case "postfix":
           postfix = formula;
           infix = B1Work.postfixToInfix(postfix);
           System.out.println("Infix:"+infix);
           System.out.println("Postfix:"+postfix);
           System.out.println("Answer:"+B1Work.solvePostfix(postfix));
           break;
       }
   }

}

In: Computer Science

Java queue linked list /* * Complete the enqueue(E val) method * Complete the dequeue() method...

Java queue linked list

/*
* Complete the enqueue(E val) method
* Complete the dequeue() method
* Complete the peek() method
* No other methods/variables should be added/modified
*/
public class A3Queue {
   /*
   * Grading:
   * Correctly adds an item to the queue - 1pt
   */
   public void enqueue(E val) {
       /*
       * Add a node to the list
       */
   }
   /*
   * Grading:
   * Correctly removes an item from the queue - 1pt
   * Handles special cases - 0.5pt
   */
   public E dequeue() {
       /*
       * Remove a node from the list and return it
       */
       return null;
   }
   /*
   * Grading:
   * Correctly shows an item from the queue - 1pt
   * Handles special cases - 0.5pt
   */
   public E peek() {
       /*
       * Show a node from the list
       */
       return null;
   }
  
   private Node front, end;
   private int length;
   public A3Queue() {
       front = end = null;
       length = 0;
   }
   private class Node {
       E value;
       Node next, prev;
       public Node(E v) {
           value = v;
           next = prev = null;
       }
   }
}

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


public class A3Driver {
  
   public static void main(String[] args) {
      
  
       A3Queue queue = new A3Queue<>();
       queue.enqueue(5);
       queue.enqueue(20);
       queue.enqueue(15);
       System.out.println(queue.peek()+":5");
       System.out.println(queue.dequeue()+":5");
       queue.enqueue(25);
       System.out.println(queue.dequeue()+":20");
       System.out.println(queue.dequeue()+":15");

   }
}

In: Computer Science

Indexing Arrays & Scalar Operations Create a new array called “myShortArray” that contains the 1st, 3rd,...

Indexing Arrays & Scalar Operations

Create a new array called “myShortArray” that contains the 1st, 3rd, and 5th elements of the array “myArray” as defined below using the indexing method.

     myArray = [1, 2, 3, 4, 5, 6];

In: Computer Science

Insert the following data into an AVL tree and show the steps 10, 20, 30, 25,...

Insert the following data into an AVL tree and show the steps 10, 20, 30, 25, 40, 50, 35, 33, 37, 60, 38.

In: Computer Science

5 html files minimum (does not include css file) Use of all three methods of css...

  • 5 html files minimum (does not include css file)
  • Use of all three methods of css (inline, internal, external). Have inline and internal css on all 5 html files and use one external css file that styles all 5 html pages
  • Use div tags to section off part of the pages and add border radius the divs
  • 1 paragraph on at least 5 html pages (1 paragraph must have at least 6 sentences)
  • The following CSS properties must be used somewhere in your css styles (use classes and IDs)
    • border
    • float
    • color
    • background-color for html page
    • background-color for divs
    • :hover (use on multiple divs and links)
    • margin
    • padding
    • width
    • height
    • font-size
    • font-family
  • Picture tags
  • hyperlinks on text, and at least one hyperlink on an element (like how I made a div a link in the video or make an image a link)

In: Computer Science

So currently I am working on some SQL with python which is linked to my database...

So currently I am working on some SQL with python which is linked to my database and I am stuck on a split problem. So in the program it connects to the database and then next you input either list, add, update, remove or allocate. So lets say I want to add a new data into the database you just need to write: update -name='Ava - #2' -class=2.

After you type this there is a variable called val which does the strip and split.

So as of right now what I have done is:

val = input('> ').strip().lower()
parts = val.split(' ')
print(parts)

So if I input the following: update -name="Nile Adam" -class=2

I expect the following output: ['update', '-name="Nile Adam"', '-class=2']

However the output I get is: ['update', '-name="Nile', 'Adam"', '-class=2']

In: Computer Science

Draw a flow chart for a program that will get the name and final exam results...

Draw a flow chart for a program that will get the name and final exam results for all FBTOO15 students (474); and calculate the total scores for all students. After all results were entered, the average results would be calculated and displayed on screen.

In: Computer Science

Create a Web Page that has the name of at least 10 brands of dog food,...

Create a Web Page that has the name of at least 10 brands of dog food, as well as an image of each dog food.
Essentially your Web Page should have 10 names and 10 Images.
Start by putting a Title (ex.Good Dog Eats) at the top, and use a line separator. Then add the dog food brand names and images.
You will need to “borrow” the images from some other websites like https://www.petsmart.com/ or so. Use CSS padding property around the brand names. Use a color of your choice for the text and add some background color too.

CIST 1510 Web Development

In: Computer Science

C++ Program : You are working as a programmer designing a space ship weapon system for...

C++ Program : You are working as a programmer designing a space ship weapon system for the newly

forced Space Force. The weapon system is a generic weapon housing that can t a number

of dierent weapons that are all controlled by a ship pilot in the same way. Most im-

portantly, is the emphasis on safety. During combat, the weapon systems cannot become

unreliable or fail lest the pilots be put in unnecessary danger. Therefore you will need to

provide mechanisms to combat this.

2.2.1 weaponMount

This is the mounting system for the weapons. It can store a number of weapons and

control them as well as handle problems. It is dened as follows:

weaponMount

-weapons:weapon **

-numWeapons: int

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

+weaponMount(numWeapons:int, weaponList: string *)

+~weaponMount()

+accessWeapon(i:int):weapon *

The class variables are as follows:

weapons: A 1D array of weapon pointers. It must be able to accept any type of

weapon dened in the hierarchy.

numWeapons: The number of weapons that are mounted into the system.

The class methods are as follows:

weaponMount: This is the constructor. It will receive a list of weapons as a string

array plus the number of weapons. It must allocate memory for the weapons variable

and create a weapon based on the information provided by the string array. Create

one weapon of the type indicated at each index of the array. For example ["Doom

Cannon","Ion Cannon"] means create a doomCannon weapon at index 0 and so on.

The default strength for an ion cannon is 5.

weaponMount: The class destructor. It must deallocate all of the memory assigned

to the class.

accessWeapon: This receives an int which provides an index in the weapons list. It

will return the weapon that is stored at that position. If no such weapon is found

there, then throw a weaponFailure exception.

2.2.2 weaponFailure

This is a custom exception class used in the context of this system. It will inherit publicly

from the exception class. You will need to override specically the what method to return

the statement "Weapon System Failure!" without the quotation marks. The name of this

class is weaponFailure. This exception will be used to indicate a failure of the weapon

system. You will implement this exception in the weaponMount class as a struct with

public access. You will need to research how to specify exceptions due to the potential

for a "loose throw specier error" and what clashes this might have with a compiler.

Remember that implementations of classes and structs must be done in .cpp les.

2.2.3 ammoOut

This is a custom exception class used in the context of this system. It will inherit publicly

from the exception class. You will need to override specically the what method to

return the statement "Ammo Depleted!" without the quotation marks. The name of this

class is ammoOut. This exception will be used to indicate a depletion of ammunition

for a weapon. You will implement this exception in the weapon class as a struct with

public access. You will need to research how to specify exceptions due to the potential

for a "loose throw specier error" and what clashes this might have with a compiler.

Remember that implementations of classes and structs must be done in .cpp les.

2.2.4 Weapon Parent Class

This is the parent class of ionCannon and doomCannon. Both of these classes inherit

publicly from it. It is dened according to the following UML diagram:

weapon

-ammo:int

-type:string

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

+weapon()

+weapon(a:int, t:string)

+getAmmo():int

+getType():string

+setAmmo(s:int):void

+setType(s:string):void

+weapon()

+fire()=0:string

The class variables are as follows:

ammo: The amount of ammo stored in the weapon. As it is red, this will deplete.

type: The type of the weapon as a string. Examples include: "Rail Ri

Cannon","Doom Cannon", "Missile Launcher" and "Ion Cannon".

The class methods are as follows:

weapon: The default class constructor.

weapon(a:int, t:string): The constructor. It will take two arguments and instantiate

the class variables accordingly.

getAmmo,setAmmo: The getter and setter for the ammo.

getType,setType: The getter and setter for the ammo.

weapon: The destructor for the class. It is virtual.

fire: This is the method that will re each of the weapons and produce a string of

the outcome. It is pure virtual here.

2.2.5 ionCannon

The ionCannon is dened as follows:

ionCannon

-strength:int

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

+ionCannon(s:int)

+~ionCannon()

+setStrength(s:int):void

+getStrength() const:int

+fire():string

The class variables are as follows:

strength: The strength of the ion cannon. Ion cannons get stronger the longer they

are red.

The class methods are as follows:

ionCannon: The class constructor. This receives an initial strength for the ion

cannon.

ionCannon: This is the destructor for the ion cannon. It prints out "Ion Cannon

Uninstalled!" without the quotation marks and a new line at the end when the class

is deallocated.

fire: If the cannon still has ammo, it must decrease the ammo by 1. It will also

increase the strength by 1. It will return the following string: "Ion Cannon red at

strength: X" where X represents the strength before ring. Do not add quotation

marks. If ammo is not available, instead throw the ammoOut exception. No new

lines should be added.

getStrength/setStrength: The getter and setter for the strength variable.

2.2.6 doomCannon

The doomCannon is dened as follows:

doomCannon

-charge:int

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

+doomCannon()

+~doomCannon()

+getCharge():int

+setCharge(s:int):void

+fire():string

The class methods are as follows:

doomCannon: This is the constructor for the class. It will set the charge to 0.

doomCannon: This is the destructor for the ion cannon. It prints out "Doom

Cannon Uninstalled!" without the quotation marks and a new line at the end when

the class is deallocated.

setCharge/getCharge: The getter and setter for the charge variable.

re: The cannon can only re if it has ammo and only charge if it has ammo as

well. The charging process does not require ammo. Firing it will reduce the ammo

by 1. However the doom cannon requires a charging up period. Since the doom

cannon starts with 0 charge, it will not re until it reaches 5 charge, inclusive of the

5. Therefore every time it is red, it will increase in charge by 1. If the charge is not

at 5, then return the string "DOOM CANNON CHARGING" without quotation

marks. If the cannon starts at 5 charge when red reset the charge back to 0 and

return the following string: "DOOM CANNON FIRED!". Do not add quotation

marks. If ammo is not available, instead throw the ammoOut exception. No new

lines should be added.

You will be allowed to use the following libraries: sstream,exception, cstring,string,

iostream. Your submission must contain weaponMount.h, weaponMount.cpp, ionCannon.h, ionCannon.cpp, doom-

Cannon.h, doomCannon.cpp,weapon.h, weapon.cpp, main.cpp

In: Computer Science

Respond to the following in a minimum of 175 words: Vulnerabilities can exist in both a...

Respond to the following in a minimum of 175 words:

Vulnerabilities can exist in both a business' software and hardware.

Discuss the differences between software and hardware vulnerabilities. How might these vulnerabilities impact a business

In: Computer Science

Recall the Kung and Robinson optimistic concurrency control algorithm. How can you modify that algorithm to...

Recall the Kung and Robinson optimistic concurrency control algorithm. How can you modify that algorithm to ensure that every transaction eventually completes?

In: Computer Science

All program should be in C Write its pseudocode and draw its flowchart) to prompt the...

All program should be in C

Write its pseudocode and draw its flowchart) to prompt the user to input the variables to solve the following problem:

X2 + X×Y/Z - W*V3

Note 1: You should ask the user to input 5 numbers to be able to do this calculation.

Note 2: You can use multiplication instead of power if you do not want to use it (as we have not officially covered it).

Write a program (compile and run), pseudocode, and draw a flowchart for each of the following problems:

a) Obtain three numbers from the keyboard, compute their product, and display the result.

Ans:

b) Obtain two numbers from the keyboard, and determine and display which (if either) is the smaller of the two numbers.

Ans:

c) Obtain a series of positive numbers from the keyboard, and determine and display their average (with 4 decimal points). Assume that the user types the sentinel value -1 to indicate "end of data entry."

Ans:

In: Computer Science

1D Array Function Write a function in MATLAB to convert miles to feet. This function should...

1D Array Function

Write a function in MATLAB to convert miles to feet. This function should work for one number, or an array of numbers to be converted.

In: Computer Science

For the following operations: write the operands as 2's complement binary numbers then perform the addition...

For the following operations: write the operands as 2's complement binary numbers then perform the addition or subtraction operation shown. Show all work in binary operating on 8-bit numbers.
7 + 3
7 - 3
3 - 7

In: Computer Science