|
When posting your question please:- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-fou
|
|
|
|
|
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?
|
|
|
|
|
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 5 days ago.
|
|
|
|
|
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;
|
|
|
|
|
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
|
|
|
|
|
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.
|
|
|
|
|
Make a program that takes n numbers and computes the sum of
positive numbers. If the entered number is 0, the program will
terminate
|
|
|
|
|
Sorry, this site does not provide code to order. If you do not understand how to write a simple Java sample then take a look at Java Tutorials Learning Paths[^].
|
|
|
|
|
|
There are many excellent books that you could use to learn Java. Alternatively, you could look at courses and training videos on places like Pluralsight, Udemy and so on.
|
|
|
|
|
Use the link in my message above yours. It is a well presented tutorial which takes you from the basics right through to many of the advanced concepts.
|
|
|
|
|
import java.io.*;
public class SumOfPositive{
public static void main(String args[])throws Exception{
int sum=0;
System.out.println("Enter how many you need to add");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n=br.readLine();
for(int i=0;i<n;i++)
{
if(a[i])="=0)
" system.exit(0);
="" if(a[i]="">0)
sum=sum+a[i];
}
System.out.println("Sum of positive numbers:"+sum);
}
}
|
|
|
|