|
Looking at his profile and message history, he's a spammer trying to push his food delivery app.
Spammer (nithin sethu)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thanks. And I have a feeling I flagged him already the other day.
|
|
|
|
|
Which part?
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
1) Un negocio de perfumería efectúa descuentos en sus ventas según el importe de éstas, con la siguiente escala:
- Si el importe es menor a $100 corresponde un descuento del 5%
- Si el importe es de entre $100 (inclusive) y hasta $500 (inclusive) corresponde un
descuento del 10%
- Si el importe es mayor a $500 corresponde un descuento del 15%
El dueño le solicitó a Ud., futuro programador, un programa donde se deba ingresar el importe original a pagar por el cliente y que luego se calcule e informe por pantalla el precio final con el descuento que corresponda ya aplicado.
2) Hacer un programa para ingresar por teclado la nota obtenida por un alumno en una determinada materia y luego emitir el cartel aclaratorio que corresponda, de acuerdo a las siguientes condiciones:
- “Sobresaliente”, si la nota fue 10.
- “Distinguido”, si la nota fue 9 ó 8.
- “Bueno”, si la nota fue 7 ó 6.
- “Aprobado”, si la nota fue 5 ó 4.
- “Insuficiente”, si la nota fue 3, 2 ó 1.
- “Ausente”, si la nota fue 0.
7) Hacer un programa para ingresar por teclado las cuatro notas de los exámenes parciales obtenidas por un alumno en una determinada materia y luego emitir el cartel aclaratorio que corresponda, de acuerdo a las siguientes condiciones:
- “Promociona”, si obtuvo en los cuatro exámenes nota 7 o más.
- “Rinde examen final”, si obtuvo nota 4 o más en por lo menos tres exámenes.
- “Recupera Parciales”, si obtuvo nota 4 o más en por lo menos uno de los exámenes.
- “Recursa la materia”, si no aprobó ningún examen parcial.
modified 3-Dec-22 19:11pm.
|
|
|
|
|
We won't do your home work for you, but you could at least write it in English.
|
|
|
|
|
I have this problem where I solved it when my array is not empty.
My issue is whem the array is empty. I tried to put an condition but it's useless.
I got this error "[ERROR] CycleSwapTest.testCycleSwapEmptyCaseShift:44 � ArrayIndexOutOfBounds Index 0 o..."
Proceed to CycleSwap class and implement its static methods:
void cycleSwap(int[] array)
Shifts all the elements in the given array to the right by 1 position.
In this case, the last array element becomes first.
For example, 1 3 2 7 4 becomes 4 1 3 2 7.
void cycleSwap(int[] array, int shift)
Shift all the elements in the given array to the right in the cycle manner by shift positions.
Shift value is guaranteed to be non-negative and not bigger than the array length.
For example, 1 3 2 7 4 with a shift of 3 becomes 2 7 4 1 3.
For a greater challenge, try not using loops in your code (not mandatory).
Note that input array may be empty.
Examples
Code Sample:
int[] array = new int[]{ 1, 3, 2, 7, 4 };
CycleSwap.cycleSwap(array);
System.out.println(Arrays.toString(array));
Output:
[4, 1, 3, 2, 7]
Code Sample:
int[] array = new int[]{ 1, 3, 2, 7, 4 };
CycleSwap.cycleSwap(array, 2);
System.out.println(Arrays.toString(array));
Output:
[7, 4, 1, 3, 2]
Code Sample:
int[] array = new int[]{ 1, 3, 2, 7, 4 };
CycleSwap.cycleSwap(array, 5);
System.out.println(Arrays.toString(array));
Output:
[1, 3, 2, 7, 4]
My code is:
<pre>class CycleSwap {
static void cycleSwap(int[] array) {
int shift = 1;
reverse(array, 0, array.length - 1);
reverse(array, shift, array.length - 1);
}
static void cycleSwap(int[] array, int shift) {
reverse(array, 0, array.length - 1);
reverse(array, 0, shift - 1);
reverse(array, shift, array.length - 1);
}
private static void reverse(int[] nums, int i, int j) {
while (i < j) {
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
i++;
j--;
}
}
public static void main(String[] args) {
{
int[] array = new int[]{1, 3, 2, 7, 4};
CycleSwap.cycleSwap(array,2);
System.out.println(Arrays.toString(array));
}
{
int[] array = new int[]{};
CycleSwap.cycleSwap(array);
System.out.println(Arrays.toString(array));
}
{
int[] array = new int[]{};
CycleSwap.cycleSwap(array, 3);
System.out.println(Arrays.toString(array));
}
}
}
Output:
[7, 4, 1, 3, 2]
[]
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at com.epam.rd.autotasks.CycleSwap.reverse(CycleSwap.java:22)
at com.epam.rd.autotasks.CycleSwap.cycleSwap(CycleSwap.java:16)
at com.epam.rd.autotasks.CycleSwap.main(CycleSwap.java:43)
Do you know what is the problem?
|
|
|
|
|
Why are you trying to access elements of an empty array? But either way you can use the length property of the array to test whether it is empty or not.
|
|
|
|
|
"
Why are you trying to access elements of an empty array? "
Because is in the statement description. I have some failed tests and I thought maybe because of that.
Note that input array may be empty.
I tried like this, but still it's not working.
<pre>class CycleSwap {
static void cycleSwap(int[] array) {
int shift = 1;
reverse(array, 0, array.length - 1);
reverse(array, shift, array.length - 1);
}
static void cycleSwap(int[] array, int shift) {
reverse(array, 0, array.length - 1);
reverse(array, 0, shift - 1);
reverse(array, shift, array.length - 1);
}
private static void reverse(int[] nums, int i, int j) {
while (i < j) {
int temp = nums[i];
nums[i] = nums[j];
nums[j] = temp;
i++;
j--;
}
}
public static void main(String[] args) {
{
int[] array = new int[]{};
if (array.length == 0) {
System.out.println(0);
} else {
CycleSwap.cycleSwap(array, 2);
System.out.println(Arrays.toString(array));
}
}
}
}
I get this result:
[ERROR] CycleSwapTest.testCycleSwapEmptyCaseShift:44 � ArrayIndexOutOfBounds Index 0 o...
How can I fix that?
|
|
|
|
|
Probably because your test for zero length is in the wrong place. You need to test it at the beginning of each of the methods cycleSwap and reverse , since those are the places where the error can occur.
|
|
|
|
|
Yeah! You're right! I don't know why I didn't think about that!
|
|
|
|
|
Hello. I'm modifying the code below for my project. I just need help in Address Book GUI wherein:
1. I need to add "Enter Email Address" input in Add Record Button and
2. I need to insert another button, which is "Update Record" wherein I need to Update any existing records by typing his/her name and edit the the records of it including his/her name.
When I'm trying to modify this, I usually get an error in the codes. Please help me in this code. Thanks. No SQL Database needed and I'm using Apache Netbeans in here.
Link of my code:
https://drive.google.com/drive/folders/17PhFr3QYgiCQ8Z5tDcmZWxjbawvCGmY4?
|
|
|
|
|
If you have problems in your code then please edit your question above, and add complete details of what is not working.
|
|
|
|
|
Very few people are going to follow a link to an offsite google drive. Post the relevant code here in your post and give full details of the error, including which line it is thrown from
|
|
|
|
|
i am trying develop an algorithm to solve a Travelling Salesman Problem similar case where the goal is to find the best route with the highest attractiveness score (sum of scores for all visited sites/nodes) within a fixed time frame.
to illustrate this more:
a tourist wants to visit N attraction sites in a city and he only has 8 hours to visit as many attraction sites as possible. every site has an attractiveness score and the time spent to visit it.
example:
- site A with ID 0 has an attractiveness score of 90 and requires 10 minutes to visit it ([0, 90, 10])
- site B with ID 1 has an attractiveness score of 69 and requires 7 minutes to visit it ([1, 69, 7])
- site C with ID 2 has an attractiveness score of 72 and requires 7 minutes to visit it ([2, 72, 11])
- site D with ID 3 has an attractiveness score of 116 and requires 16 minutes to visit it ([3, 116, 16])
.
.
.
and so on.
Now we have a time matrix T where T[i][j] represents the necessary time to go from site i to site j. finally we consider site 0 as both the start site and the end site, i.e. the tourist starts his journey at site 0 and returns to site 0 (a hotel for instance).
so the task is to find an itinerary for the tourist to visit as many attractions as possible with a maximum sum score of attractiveness.
example of T matrix for sites A,B,C and D (it could be 50 sites):
T = [0, 40, 35, 90]
[30, 0, 25, 130]
[67, 83, 0, 75]
[45, 79, 130, 0]
The TSP has been solved using different algorithms or methods but i am stuck with this one as it's a little bit different in the sense that the goal is to find the maximum attractiveness score for an itinerary within a time frame, and not the shortest route.
your help is much appreciated
I thought of methods like greedy algorithm, dynamic programming used in TSP but couldn't find a way to solve this particular problem.
|
|
|
|
|
Hi. Is there a build-in function like in C# to scroll the child into viewport of ScrollPane ?
If not, how to achieve that using setVvalue() method of ScrollPane ?
I use below method to scroll, but it scrolls every control to the top of the viewport, but I want to scroll controls which are in the bottom of viewport to the bottom.
Bounds bounds = scrollPane.getViewportBounds();
scrollPane.setVvalue(flowPane.getChildren().get(3).getLayoutY() * (1/(flowPane.getHeight()-bounds.getHeight())));
|
|
|
|
|
Be careful of integer arithmetic.
1/(anything except 1) will yield 0.
Use more intermediate variables with precise names to help you via debugger.
|
|
|
|
|
I am trying to find the path of resource using Paths like below and then copying some files at runtime. While at runtime it works perfectly fine. However while running locally for junit testing, it throws below error at the below first line while trying to get Path using URI. I am not using any zip/jar file so why I am getting the below stack trace. Am I missing something?
Path path= Paths.get(ABCD.class.resource("/").toURI());
String mockFileName="cacerts";
File mockFile= new File(path+File.seperator+mockfileName);
Error
java.nio.file.FileSystemNotFoundException
at com.sun.nio.zipfs.ZipFileSystemProvider.getFileSystem(ZipFileSystemProvider.java:171)
at com.sun.nio.zipfs.ZipFileSystemProvider.getPath(ZipFileSystemProvider.java:157)
at java.nio.file.Paths.get(Unknown Source)
|
|
|
|
|
The message is clear, the path it is trying to access does not exist. You need to use the debugger to find out exactly what paths it is trying to find. That is the only way to discover what causes the problem.
|
|
|
|
|
saurabh jasmeen mehta wrote: Path path= Paths.get(ABCD.class.resource("/").toURI());
Presumably in your test code.
Modify your test code to collect that path first, as a string, then wrap that line in a try/catch and if the exception occurs throw an exception which includes that name.
saurabh jasmeen mehta wrote: ABCD.class.resource("/")
You might also want to just create some local code to test exactly what that means. I did that years ago and the way it does that is not simple.
|
|
|
|
|
Q1. Write a program using methods to find whether a point (x1,y1) lies on a circle of radius 2 cm and h = 5; the equation of circle is given by 〖(x-h)〗^2+〖(y-h)〗^2=r^2 . The method returns a Boolean value.
|
|
|
|
|
You have all the necessary information in the question, so you need to show us what you have written and where you are stuck. We are not going to write your assignment for you.
|
|
|
|
|
[httpGet]
public string ApplyGroupOperation (string values , string op)
{
string[]valueList = values.Split(Values , ',');
var result=0;
for (int i=0 ; i<valuelist.count ;="" i++)
switch(op)
{
case"+":
result+="int.parse(ValueList[i]);
break;
case"*":
result*=int.parse(ValueList[i]);
break;
default:
break;
}
}
return" result;
}
<pre="">
|
|
|
|
|
You forgot to ask a question.
|
|
|
|
|
There is somthing wrong in this code , i need to know it
|
|
|
|
|
Then you need to explain what it is and where it occurs. We cannot guess what you see on your screen.
|
|
|
|
|