I want to remove the unnecessary characteristics from json.
bad JSON
"{\n \"response\": {\n \"Id\": \"1234\",\n \"la\": [\n {\n \"op\": \"pic\",\n \"lbl\": \"33609\",\n
I want the json to be like this
{"response":{"Id":"1234","la":[{"op":"pic","lbl":"33609","
I have tried to used URLDecoder.decode(param1AfterEncoding, "UTF-8"); but it didn't fix it. I would apperciate any help
In: Computer Science
Java Coding
Background
You will create a Java class that simulates a water holding tank. The holding tank can hold volumes of water (measured in gallons) that range from 0 (empty) up to a maximum. If more than the maximum capacity is added to the holding tank, an overflow valve causes the excess to be dumped into the sewer system.
Assignment
The class will be named HoldingTank. The class attributes will consist of two int fields – current and maxCapacity. The fields must be private. The current field represents the current number of gallons of water in the tank. The maxCapacity field represents the maximum number of gallons of water that the tank can hold.
The class will contain the following methods:
Constructor – the constructor will initialize the two fields. If current is greater than maxCapacity, it will be set to maxCapacity.
Getters – there will be a getter for each field.
Setters – no setters will be defined for this class
void add(int volume) – add volume gallons to the tank. If the current volume exceeds maxCapacity, it will be set to maxCapacity.
void drain(int volume) – try to remove volume gallons from the tank. If resulting current volume is less than zero, set it to zero.
void print() – prints the current volume of the tank (in gallons)
Now create a Main class with a main method to test the HoldingTank class. Add the following code to the main method.
Example Output
The tank volume is 600 gallons
The tank volume is 850 gallons
The tank volume is 750 gallons
The tank volume is 175 gallons
How to connect two files?
My code:
package home;
public class Main { public static void main(String[] args) { HoldingTank tank = new HoldingTank(600,1000); tank.print(); tank.add(300); error tank.drain(50); tank.print(); tank.add(500); error tank.drain(250); tank.print(); tank.drain(1200); tank.add(200); error tank.drain(25); tank.print(); } }
package home; public class HoldingTank { private int current; private int maxCapacity; public HoldingTank(int current,int maxCapacity) { if (this.current > maxCapacity) { this.current = maxCapacity; } else { this.current = current; } this.maxCapacity = maxCapacity; } public int getCurrent(){ return current; } public int getMaxCapacity() { return maxCapacity; } public void drain(int volume){ if((this.current-volume)<0){ this.current = 0; }else{ this.current-= volume; } } public void print(){ System.out.println("The tank volume is "+this.current+"gallon"); } }
In: Computer Science
Java programming.
Purpose:
Problems:
Sample input:
7 30 15 40 5 20 35 45
Sample output:
in-order: 5 15 20 30 35 40 45 before rotation: pre-order: 30 15 5 20 40 35 45 after rotating left: pre-order: 40 30 15 5 20 35 45 after rotating right: pre-order: 30 15 5 20 40 35 45
USE THE BELOW TEMPLATE:
import java.util.*; | |
class Node <E> { | |
private Node<E> left; | |
private Node<E> right; | |
private E data; | |
Node(E data) { | |
this.data = data; | |
left = null; | |
right = null; | |
} | |
void setData(E d) { | |
data = d; | |
} | |
E getData() { | |
return data; | |
} | |
void setLeft(Node<E> i) { | |
left = i; | |
} | |
void setRight(Node<E> i) { | |
right = i; | |
} | |
Boolean hasLeft() { | |
return left != null; | |
} | |
Node<E> getLeft() { | |
return left; | |
} | |
Boolean hasRight() { | |
return right != null; | |
} | |
Node<E> getRight() { | |
return right; | |
} | |
} | |
class BST <E extends Comparable<?super E>> { | |
private Node<E> root; | |
BST() { | |
root = null; | |
} | |
Node<E> getRoot() { | |
return root; | |
} | |
void inOrder() { | |
System.out.print("in-order: "); | |
inOrder(root); | |
System.out.println(); | |
} | |
void inOrder(Node<E>root) { | |
if(root == null) return; | |
inOrder(root.getLeft()); | |
System.out.print(root.getData() + " "); | |
inOrder(root.getRight()); | |
} | |
void preOrder() { | |
System.out.print("pre-order: "); | |
preOrder(root); | |
System.out.println(); | |
} | |
void preOrder(Node<E>root) { | |
if(root == null) return; | |
System.out.print(root.getData() + " "); | |
if(root.hasLeft()) preOrder(root.getLeft()); | |
if(root.hasRight()) preOrder(root.getRight()); | |
} | |
void insert(E data) { | |
root = insert(root, data); | |
} | |
Node<E> insert(Node<E> root, E data) { | |
if (root == null) { | |
return new Node<E>(data); | |
} else { | |
Node<E> cur; | |
if (root.getData().compareTo(data) > 0) { | |
cur = insert(root.getLeft(), data); | |
root.setLeft(cur); | |
} else { | |
cur = insert(root.getRight(), data); | |
root.setRight(cur); | |
} | |
return root; | |
} | |
} | |
//apply left rotate to the root node | |
void rotateLeft() { | |
} | |
//apply right rotate to the root node | |
void rotateRight() { | |
} | |
} | |
public class RotationMain { | |
public static void main(String[] argv) { | |
int n; | |
Scanner in = new Scanner(System.in); | |
n = in.nextInt(); | |
BST<Integer> tree = new BST<Integer>(); | |
for(int i = 0; i < n; i ++) { | |
tree.insert(in.nextInt()); | |
} | |
in.close(); | |
//if BST is correctly built, items will be displayed in sorted order using | |
//in-order traversal | |
tree.inOrder(); | |
System.out.println("before rotation: "); | |
tree.preOrder(); | |
System.out.println("after rotating left: "); | |
tree.rotateLeft(); | |
tree.preOrder(); | |
System.out.println("after rotating right: "); | |
tree.rotateRight(); | |
tree.preOrder(); | |
} | |
} |
In: Computer Science
In: Computer Science
In: Computer Science
In Python please: Number the Lines in a File: Create a program that adds line numbers to a file. The name of the input file will be read from the user, as will the name of the new file that your program will create. Each line in the output file should begin with the line number, followed by a colon and a space, followed by the line from the input file.
In: Computer Science
In no more than 200 words, please identify what are the core components of a Cyber Incident Response plan? What groups / functions need to be involved in your cyber incident response? Write in details in your own analysis
In: Computer Science
In an asynchronous bus, what are the steps that a master device let a slave device do a job?
Please draw the circuit diagram of an SR latch using only NAND gates. Please also show its truth.
In: Computer Science
use c++
A right-angle triangle with integer sides a, b, c, such as 3, 4,
5, is called a Pythagorean triple. The condition is that hypotenuse
to power of 2 is equal to adding of square of the 2 other sides. In
this example 25 = 16 + 9. Use brute force approach to find all the
triples such that no side is bigger than 50.
For this you should first implement the following Triangle class
and its methods. Then use it in main() to find all pythagorean
triples and put then in a std::vector. Finally print them out as
triples, like
(3, 4, 5)
.....
Make sure your output contains a triple only once, and not any
reordered ones, this means (3, 4, 5) is the same as (4, 3, 5) and
so only the increasing order triple should be printed out. This
means only (3, 4, 5) shoud be printed.
You program should print out all possible pythogorean triples with
sides <= 50.
*/
class Triangle
{
public:
Triangle(int a, int b, int c) // constructor.
Implement this
{}
bool isPythagorean() const // implement this
properly
{
return false;
}
private: // what do you put in private section?
}
int main()
{
}
In: Computer Science
I am a student taking an introductory Unix / LInux shell programming course and need some help with an assignment.
Using the file CISED as input, write the sed command to do the following:
Change 2 or more occurrences of g to a single g
Add > to beginning of any line that begins with CIS132
Add < to the end of any line that ends in Tux or tux
Replace any five to eight digit number with XX
For every line that begins with CIS132, place the first 6 characters in the line at the end of the line and the last three characters at the beginning of the line. Leave the characters in between these characters as they were.
Change any non alphanumeric character to &
For any line that begins with CIS132 place the entire line inside of double quotes.
Thanks for your help.
In: Computer Science
1) How large are the blocks that get fed through the AES Encryption algorithm?
2) What are the three possible key sizes for AES? How many rounds are there for each key size? How large is the keyspace?
3) List five distinct differences between the AES and DES algorithms.
4) List the 16 elements of GF(16) as polynomials. What is 3x^2+6x+1 equal to in GF(16), when the coefficients are reduced appropriately?
5) Use the table on slide 17 of the Chapter 4 slides to compute the inverse of x^4+x^3+1 in GF(256). Then verify that the product of x^4+x^3+1 and the inverse you computed is, in fact, 1 modulo the polynomial indicated in red on slide 17.
6) List three separate known attacks on AES. Include the weakness(es) of AES that they exploit and include the year in which the attack was first discovered
#understanding cryptography
#asap
In: Computer Science
Write a function with the following prototype: int add_ok (int s, unsigned x, unsigned y); This function should return 1 if arguments x and y can be added without causing overflow, otherwise return 0. If s is 0, x and y are unsigned numbers. If s is 1, x and y are treated as signed numbers. I tried this code but it doesn't work. Does anyone help me please?
#include int add_ok(int s, unsigned x, unsigned y) {
s=x+y;
if ((s<x) || (s<y)) {
return 0; }
return 1;
}
int main()
{
int nums = new int[(sizeof(int))];
unsigned x = 3357162450;
unsigned y = 40;
printf("%d\n",add_ok(s, x, y));
scanf("%d\n", &nums);
return 0;
}
In: Computer Science
Consider the following scenario:
Your manufacturing company has operated with a mainframe IBM computer for more than 20 years. Recent technological advances have brought opportunities to replace that mainframe-based computing environment with a client/server environment. You have been tasked with responding to the senior management group about the security issues involved with replacing the existing mainframe computer environment with a client/server platform. The salespeople you deal with from each vendor believe that the current mainframe environment costs about $500K a year to maintain from a security standpoint, while a client/server environment would cost about $325K a year. But cost is not the only consideration. No PII or SPII data is contained in this manufacturing platform. It is strictly a final product for sale application.
Outline and review a typical mainframe enterprise security footprint. Do the same for a possible client/server environment. This could include the use of the cloud for distributed computing, but that would also include unique security concerns.
Discuss the following:
Respond to the following in a minimum of 175 words:
In: Computer Science
Convert the following C function to the corresponding MIPS
assembly procedure:
int count(int a[], int n, int x)
{
int res = 0;
int i = 0;
int j = 0;
int loc[];
for(i = 0; i != n; i++)
if(a[i] == x) {
res = res + 1;
loc [j] = i;
j = j+1}
return res, loc;
}
In: Computer Science
What is DNS Poisoning, Spoofing, Pharming and the differences and examples of each
In: Computer Science