|
I put that up instead of "Google java versus vb".
I was first going to post that "java is like c#". And whatever that might imply.
But I liked the reference to "multi-platform".
Sometimes I just post something "positive" as a balance.
(My actually experiences are not relevant in this case).
I also wanted to keep it short.
"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
|
|
|
|
|
Kanel Roath wrote: VB6 and VB.Net
VB6 in that is more relevant than the other.
If you have done VB6 for years then you will have an idea of what libraries a programming language might support so that experience can help.
If you have been using Object Oriented concepts in VB6 in a rigorous fashion even for a couple of years then that is going to help. If not then that is going to be a problem. Took me about 18 months to actually get OO when I went from C to C++. Although to be fair these days I see a lot less strict OO in Java (and C#) in enterprise applications versus long ago.
|
|
|
|
|
Instructions:
1. Provide the flowchart, complete code and sample output for all of the questions.
A medium sized company has two types of
employees which are hourly workers and commission workers. Each type of employee
has its own pay code:
Pay Code Employee Type
1 Hourly Worker
2 Commission Worker
The hourly worker is paid RM50 per hour for the first 40 hours he/she works and
"time-and-a-half" (1.5 times the hourly rate of RM50) for each of the hours above 40
hours (overtime hours). The commission worker receives RM500 plus 5.5% of their
weekly sales (e.g. 5.5% of RM1000 is RM55).
You are asked by the company to write a Java program that can determine the salary
for both employee types. The program must implement TWO (2) methods, namely
calculatePayHourlyWorker() and calculatePayCommWorker() to perform
the salary calculations for the respective types of employees. Each of the methods
displays the calculated salary amount.
The input for the program is the pay code and the appropriate information needed to
calculate each employee’s salary based on the pay code. If the pay code entered is a
negative value, the program will terminate. If it is invalid (other than 1 or 2), display
an appropriate error message. The output is the calculated salary, which must be
printed to TWO (2) decimal places.
The format of the input and output is as follows:
The format of the input and output is as follows:
Enter pay code: 1
Enter the number of hours worked: 40
Salary is RM2000.00
Enter pay code: 1
Enter the number of hours worked: 50
Salary is RM2750.00
Enter pay code: 2
Enter the amount of weekly sales: 1000
Salary is RM555.00
Enter pay code: 3
Invalid product code!
Enter pay code: -1
Note: The underline texts are the input to the program
a) Complete the program main() method based on the given description.
b) Complete the calculatePayHourlyWorker() method.
c) Complete the calculatePayCommWorker() method.
You can use this as a guideline:
import java.util.Scanner;
public class SalaryApp {
static Scanner read = new Scanner(System.in);
static int hours;
static double salary;
public static void main(String[] args) {
int paycode;
}
public static void calculatePayHourlyWorker() {
}
public static void calculatePayCommWorker() {
double sales = 0;
}
}
|
|
|
|
|
...and you have a question you forgot to ask?
[EDIT]
DO NOT post your question in multiple forums. Once is enough. You posted the exact same thing in Quick Answers, and even there, you never asked a qeustion.
|
|
|
|
|
Answer:
Go to class.
Listen to teacher.
Read book.
Think about the problem.
Write the code.
|
|
|
|
|
Wouldn't it be nice if they all did that?
|
|
|
|
|
But then there would be one less easy question for me to answer.
|
|
|
|
|
I am trying to follow the Teradata documentation to run a jar file. I have tried both ways manual and eclipse plugins for Teradata.
When I use the plugin and try to deploy the file I see the error " The user does not have the EXECUTE PROCEDURE access to SQLJ.REPLACE_JAR "
When I tried to run the codes manually via Teradata studio I see the error " Java XSP/UDF passed an unacceptable signature. Correct the signature
Can you please tell me what did I do wrong? Can you please share with me any working examples?
Thanks a lot.
modified 27-Jan-22 15:35pm.
|
|
|
|
|
Read the stuff at the top of the page: the Lounge is not for coding questions. Post it here instead: Ask a Question[^]
Ignoring the rules and annoying people you want free help from is not a good idea ...
In addition, when you post your question give us just the relevant code fragments, and paste them directly into the question. Without it, we have no idea what you have tried, and it saves us teh effort of trying to work out which bits of your whole code are important.
The more you help us to help you, the better the answer you can get.
But in this case, you are probably best off talking to Teradata support than a generic development site like this one. They produced the documentation, so they will have a better idea what document you are reading and trying from - we don't even know that!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
Chris and team really should create a way for you guys to move these type of posts in the lounge to the Q&A forum. Perhaps dump them into a special directory, etc. Where the user will then get an email to take their question, issue that is most likely not formatted and format it into a proper question/problem.
|
|
|
|
|
Sorry guys, I am new to this platform, I will change the question.
|
|
|
|
|
Unfortunately that isn't really a question about java either.
So presumably you have in fact tested that the jar is an executable jar and that you can run it locally OUTSIDE of Terradata.
Might suggest also that you look into ways of logging from that jar. Can't tell you how that works in Terradata but there are plenty of results on googling on how to add logging to a java app. You need logging, probably, to see what is going on in the code once it does run in Terradata.
So after that you need to read the error message.
Tauqeer Ahmad 2022 wrote: The user does not have the EXECUTE PROCEDURE access to SQLJ.REPLACE_JAR
So for example this error message.
The jar is running under a user. That is exactly what it says.
You need to figure out what that user is.
You need to give the specified permission to the user.
That is all Terradata stuff.
Tauqeer Ahmad 2022 wrote: I see the error " Java XSP/UDF passed an unacceptable signature. Correct the signature
And besides reading the error message you can google for it. And googling for that exact error I find specific Terradata documents that mention that error. So you start with that.
|
|
|
|
|
Hi, Thanks a lot for your help. I managed to fix the "
The user does not have the EXECUTE PROCEDURE access to SQLJ.REPLACE_JAR " I created a new question in the correct place. I visit the documentation and didn't manage to fix the signature error. Even I have tried the example of Teradata and still face the same error.
|
|
|
|
|
If I pass the url=http/market/state/update,I need the output as MARKET_STATE_UPDATE but now I am getting MARKET _UPDATE.
please share your thoughts to help me to solve the issue
String[] tokens = requestUrl.getPath().split("/", -1);
for (String tokens1 : tokens) {
switch (tokens1)
case "market":
if (requestType.equals("put")) {
if (tokens.equals("state")) {
return RecordDto.EventTypeEnum.MARKET_STATE_UPDATE;
} else if (tokens.equals("chain")) {
return RecordDto.EventTypeEnum.MARKET_CHAIN_UPDATE;
} else {
return RecordDto.EventTypeEnum.MARKET_UPDATE;
}
} else if (requestType.equals("delete")) {
if (tokens.equals("chain")) {
return RecordDto.EventTypeEnum.MARKET_CHAIN_DELETE;
}
break;
Case "value":
if (requestType.equals("put")) {
if (tokens.equals("level")) {
return RecordDto.EventTypeEnum.Value_LEVEL_UPDATE;
} else if (tokens.equals("period")) {
return RecordDto.EventTypeEnum.Value_PERIOD_UPDATE;
} else {
return RecordDto.EventTypeEnum.VALUE_UPDATE;
}
} else if (requestType.equals("delete")) {
if (tokens.equals("period")) {
return RecordDto.EventTypeEnum.VALUE_PERIOD_DELETE;
}
}
break;
|
|
|
|
|
I would highly encourage using the URL parameterization in whichever HTTP development framework you're using. That would simplify a lot of things.
- The HTTP request methods should not be checked in the method body itself. It makes very less sense. If you're going to run a logic based on the HTTP verb, create a separate handler for that verb. Most frameworks support that—Spring Boot, for example, does support HTTP verb-based routing.
- The URL itself can be created as a parameterized URL, then you can capture the values inside the parameters for the action.
You can create a request handler like,
@PutMapping("/http/{market}/{state}/{update}")
@ResponseBody
public RecordDto.EventTypeEnum putUpdate(
@PathVariable String market,
@PathVariable String state,
@PathVariable String update) {
if (state.equals("state") {
return RecordDto.EventTypeEnum.MARKET_STATE_UPDATE;
} else {
}
}
This way you leave a lot of processing and parsing to the framework itself. Read more about @PathVariable on Baeldung.
For a basic Java application, it might make sense to write the conditional blocks within the method body, but as your application scales, it becomes difficult to understand the flow of a program. That is why keep everything separated; that's one of the SOLID principles.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Gostaria de saber como fazer para abrir um extrato bancario em pdf em uma tabela pelo java. Isso se faz através de alguma aplicação q faz a leitura desse pdf e joga para essa tabela?
Google Translate: I would like to know how to open a bank statement in pdf in a table using java. Is this done through some application that reads this pdf and plays to this table?
|
|
|
|
|
This is an English language site, and we can only accept and answer questions in that language.
I have run this through Google Translate to produce a probably-good version, but you should check it and make sure it does say what you are actually asking.
Yes. You would need to read the PDF file into your Java app - this may help: How to Read and Write PDF file in Java - Studytonight[^]
Then extract the table info you need - we have no idea how the PDF file is organised, so that's going to be all your problem - and display it as normal.
Google Translate: Este é um site em inglês e só podemos aceitar e responder a perguntas nesse idioma.
Eu executei isso no Google Tradutor para produzir uma versão provavelmente boa, mas você deve verificar e certificar-se de que diz o que você está realmente perguntando.
sim. Você precisaria ler o arquivo PDF em seu aplicativo Java - isso pode ajudar: Como ler e gravar arquivo PDF em Java - Studytonight[^]
Em seguida, extraia as informações da tabela que você precisa - não temos ideia de como o arquivo PDF está organizado, então esse será todo o seu problema - e exiba-o normalmente.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
import java.io.File;
import java.io.IOException;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.text.PDFTextStripper;
public class NewClass {
public static void main(String[] args) throws IOException{
try {
// Creating file instance
File file = new File("test.pdf");
// Loading pdf file
PDDocument document = PDDocument.load(file);
PDFTextStripper pdfStripper = new PDFTextStripper();
// Fetching PDF document
String text = pdfStripper.getText(document);
System.out.println(text);
// Closing the document
document.close();
}catch(Exception e) {
System.out.println(e);
}
}
}
/PDDocument document = PDDocument.load(file);/ In this line there is an error in load, and I can't run the project
|
|
|
|
|
Daniel Carvalho 2022 wrote: In this line there is an error in load, And that error would be what? I suspect it has to do with the file's relative path (which defaults to current [i.e., "./test.pdf"] if none is provided), but only you know for sure.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I've tried changing the path and it still has the same error. Is there any other way to perform the same function?
|
|
|
|
|
As David said:
➡️ And that error would be what? ⬅️
It's no use repeatedly telling us you have "the same error" when you've never told us what the error is.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Error?
FileNotFound
ClassNotFound
PdfFormatException
Full stack trace helps
|
|
|
|
|
The URL of the site is:
https://www.lowes.com/pd/7-16-CAT-PS2-10-OSB-Sheathing-Application-as-4-x-8/50382768[^]
The information that I am trying to obtain is the price. Using Chrome's Inspect view, I was able to drill down to the price element in question. The Xpath of that element looks like:
/html/body/div[3]/section/div/div[7]/div[1]/div[2]/div[1]/span/div[1] I really wanted to see that in some "tree" form, so I walked the HTML backward from that element back to the top. That looks like:
<html>
<body>
<div id="app">
<section role="main" id="main" class="app__Container-PDP__sc-9tcy1n-0 bglOQr">
<div class="style__ProductDetailsWrapper-PDP__sc-4buzay-0 fwCYaB">
<div class="style__Wrapper-PDP__sc-1a0l1ro-1 hiRMxh product-info">
<div class="style__ProductDescDeskWrapper-PDP__sc-1a0l1ro-6 fpGRzR">
<div class="style__ProductTitleWrapper-PDP__sc-1a0l1ro-11 fUmbqY">
<div tabindex="0" class="styles__PriceWrapper-sc-1c3t51u-0 ZQLLV priceWrapper">
<span class="finalPrice">
<div class="sc-hGPBjI eomYbK">$30.65 </div> I was able to throw some Java code together (read: ugly) to drill down to that level but got stopped at the next-to-last DIV element.
...
Elements elements = element.getElementsByAttributeValue("class", "style__ProductTitleWrapper-PDP__sc-1a0l1ro-11 fUmbqY"); This returns a 1-item collection as it should. If I then follow that with:
Element element = elements.get(0);
elements = element.getElementsByAttributeValue("class", "styles__PriceWrapper-sc-1c3t51u-0 ZQLLV priceWrapper"); It returns an empty collection. I assume this is because no such class could be found. However I can plainly see that DIV element in the Inspect view.
I can get the sibling elements to the one in question. I even tried searching for getElementsByAttributeValue("tabindex", "0") , and while it correctly found 2 elements, neither are the one I want.
Any idea(s) as to what I'm missing (or not understanding)?
Thanks.
DC
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
modified 20-Jan-22 16:23pm.
|
|
|
|
|
Did you try to skip the random in the middle?
Go straight for “class”, “finalPrice”
The extract the nested text node to skip the last div
|
|
|
|
|
Make a program that takes n numbers and computes the sum of
positive numbers. If the entered number is 0, the program will
terminate
|
|
|
|