|
No, nobody here is going to help you cheat on a test.
If you can't answer the questions after taking the course, then go back and review the course again. If you still can't answer the questions, then find a better course.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My solution:
public class Exercise {
double a = 234.89;
double b = 789.456;
double c = 567.89;
double d = 78.345;
double e = System.out.println(((a+b) * (c-d)) / (a/d));
double f = System.out.println(((a*b) + (c/d)) - (a-d));
if(e>f):
println(e);
else:
println(f);
}
|
|
|
|
|
Your solution to what? Can you describe your problem? and no, I'm not going to follow a link.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
|
public class Exercise {
double a = 234.89;
double b = 789.456;
double c = 567.89;
double d = 78.345;
double e = System.out.println(((a+b) * (c-d)) / (a/d));
double f = System.out.println(((a*b) + (c/d)) - (a-d));
if(e>f):
println(e);
else:
println(f);
}
|
|
|
|
|
And what happens when you run this code?
|
|
|
|
|
It's going to crash as he cannot assign the result of his method to a variable like his trying to do with 'double e' and 'double f'.
For him to assign the result to variables, he need to separate his calculation and printing steps.
|
|
|
|
|
It won't crash, since it will not even compile.
|
|
|
|
|
Hello everyone, I need to develop a Java software that takes a .PDF file as input and signs it in PAdeS format using a CNS or a SmartCard containing one's own PIN-protected certificate.
I've been trying to understand how to do this for several days, but I can't figure out the correct workflow to follow. I also don't understand how to interact with the SmartCard, it's not clear to me whether I need to extract the certificates to load them into my Java application, or if it's possible to proceed simply by using the reader driver to access the card. In both cases, I don't know where to start.
Do you have any advice or code snippets/classes to share? Thanks.
|
|
|
|
|
Relative Sorting
Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion.
Can you help Ramesh achieve this task?
Input Format
First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively.
Second line contains n space separated integers denoting the array arr1.
Third line contains m space separated integers denoting the array arr2.
Output Format
Print the relatively sorted arr1
Example 1
Input
11 4
2 1 2 5 7 1 9 3 6 8 8
2 1 8 3
Ramesh is given two arrays, arr1 and arr2. He wants to sort arr1 in such a way that the relative order of arr2 is maintained in arr1. For elements that are not present in arr2, he wants to add the these elements at the end of the array in sorted fashion.
Can you help Ramesh achieve this task?
Input Format
First line contains two integers n and m denoting size of arrays arr1 and arr2 respectively.
Second line contains n space separated integers denoting the array arr1.
Third line contains m space separated integers denoting the array arr2.
Output Format
Print the relatively sorted arr1
Example 1
Input
11 4
2 1 2 5 7 1 9 3 6 8 8
2 1 8 3
|
|
|
|
|
I can help Ramesh achieve these tasks, if Ramesh is willing to pay for someone to do Ramesh's homework for Ramesh. Alternatively, Ramesh could do some studying, and thinking, and do this all for himself.
|
|
|
|
|
|
You gave the input but you didnt gave the output ,,for us to undertand exactly what he wants.
What does he mean with 'relative order'?
2 1 2 5 7 1 9 3 6 8 8
will become
1,1,2,2,3,5,6,7,8,8,9
But i dont undertand what we want arr2 to become...so to help as i am resting in summer.
|
|
|
|
|
So,,, even if he mean that
2 must be first ,1 second ,8 3rd and 3 4th,,,
then lets see steps from input 2 1 2 5 7 1 9 3 6 8 8
arr2[2 1 8 3]
2 ->[2]
1->[2,1] because 1 is after 2 in arr2
2->[2,2,1] or [2,1] depends if he wants/accept same that also didnt clarified.
5->[2,2,1,5] and now arr2->[21835] but if this is the case what will happen if after 5 come 0?
will again start from beginning?..because say
" add the these elements at the end of the array in sorted fashion"
'Sorted fashion' here mean sorted only for
NEW numbers like ar2[21835]->ar2[218305] ???
|
|
|
|
|
Given an array arr of size N. Your task is to determine that if by reversing any one subarray can the given array be sorted or not.
You have to complete solve function which consists of arr array of size N as inputs and you have to return boolean answer as output.
Input Format
The first line of input contains a single integer N.
The second line of input contains N space seperated integers.
Output Format
Return true, if by reversing any one subarray sorted array can be formed as else false , "Yes" or "No" will be taken care by driver code.
|
|
|
|
|
|
Member 16037934 wrote: Given an array arr of size N. Your task is The key words being Your task, not someone else's
|
|
|
|
|
I am making a web application using Java, Jsp and servlet on eclipse kepler. I am working on a online tutoring application on which students can search and hire teachers online. It will have a **online Class** function in which teachers can **upload videos ,pictures or announcements** ( simple strings). I've started learning java but I don't know how to make upload video functionality
It would be a great favor if u give some video or relevant code or website that will help me .
modified 11-Mar-23 12:47pm.
|
|
|
|
|
That is a generic question. It is not specific to Java.
Your question to me suggests you are asking about the entire process and not just the upload part.
Step 1. So your first research project would be how to run a video in a web page. Or even based on your question how to show an image. But you would need to answer both.
Then figure out how/where you store images/videos so your web site (not page) can effectively use them.
Step 2. So then you know where the videos go but how are you going to manage them. For example if 15 people all upload a image that is name 'teacher.jpg' with has a picture of a different teacher you certainly cannot store it using that name in the same directory. So you need to figure out how to handle that. This is a design problem not a code problem. It will probably involve a database because you will need to map from something to the actual image (or video.)
Step 3. Finally then you figure out how to upload a file from an web page and how to store that file in your web site. I use the term 'file' specifically because whether it is an image, video or even text it is still just a file as far as this process cares.
The last part of this is storing the file into whatever design you figured out for Step 2.
|
|
|
|
|
I was doing some Socket tests, and while using localhost everything ran as I wanted. But then I tried to switch it to IP address , and well then things got weird. While the code was in the same class (Code_1 bellow), the simplified test from below was running fine, but as soon as I moved the server code in another project, even another package or class in same package, then when I'm running client code I'm getting java.net.ConnectException: Connection timed out: connect . If when the server is in another project, and for client I'm switching to localhost , then this time it is working. It doesn't want to work when they are in different projects/packages, and the client is using IP address and not localhost , but they work if both are in same project even if client has IP address or localhost .
public static void main(String[] args) throws Exception {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
try {
ServerSocket server = new ServerSocket(port);
Socket socket = server.accept();
System.out.println(new ObjectInputStream(socket.getInputStream()).readObject());
socket.close();
server.close();
} catch (IOException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
});
thread.start();
Socket socket = new Socket("IP_ADDRESS", port);
new ObjectOutputStream(socket.getOutputStream()).writeObject("Test");
socket.close();
}
What is the problem, and what can I do to fix it?
|
|
|
|
|
I found the problem, and it was because the antivirus was blocking network not filtered. I reinstalled it and forgat to add the rule again. But that being said, why was it working when it was in the same class? Was it automatically using localhost in that situation even tho it had a specific IP given?
|
|
|
|
|
I think you are on the right track here.
In your ServerSocket, you did not bind to a specific address, so it likely defaulted to localhost on IPv4. This should also be addressable as 127.0.0.1 which is likely different than the IP used for your local network.
Try “127.0.0.1” for your IP_ADDRESS and see if it works.
There should be a variation of ServerSocket that will let you specify your local network IP address. Using the same IP for server and client should make it work.
Some important commands you can learn:
route print
netstat
ipconfig
|
|
|
|
|
Your client creates a new socket, writes some data to it, and closes it, but that is not how sockets should work. You need to establish a connection in the same way you make a telephone call: call - wait for an answer - talk - say goodbye - close. So both sides should establish the connection first, then run a loop that exchanges data. Only when both sides agree should you close the sockets.
|
|
|
|
|
Then how this signalling should be done? In that simple example the server was only expecting to receive a single object and then it knew it could close because that was all. And on client side the same thing, it knew it only had to send an object and it wasn't goin to receive anything back, so it could close it as that was all.
|
|
|
|
|
Most systems have a protocol that both ends use. So each message has some indicator or flag to tell the peer what type of message is contained in the payload. For example transferring a file between two systems then the receiving station needs to know when the last block is received.
|
|
|
|