Need help writing Java Code
Hi everyone, I don't know if I am in the right forum, but I am new in writing Java coding and I am confuse on what to do and how to write the code.
I have this question and I just dont know what to do:
How can I write a java code in the following question?
The question:
40 hours normal salary
After the 40 horas, you will pay an addition 1.5 hours
Display the total salary.
how to I write a code for this? Thank you in advance. I know this may be very simple to you but its very hard to me. Thanks again... :)
hi i think this is what your looking for you didnt really make it to clear but here it is anyway hope it helps
class Hours
public static void main (String [] args)
//declare variables
double hours;
double overtime;
double totalhours;
System.out.println ("Enter hours worked");
hours = Console.readDouble ();
overtime = 1.5;
if (hours > 40)
totalhours = overtime + hours;
System.out.println("You are entitled to an additional 1.5 hours");
System.out.println("Your total hours are" + totalhours);
else
System.out.println ("Total hours worked are " + hours);
}//end main
}// End hours
Similar Messages
-
Need help writing Java program
I am a student conducting research as to the tolerance of users to a user interface. My idea is to take the existing tetris game but implement errors into it, so that on occasion the piece will not move in the direction you want it to. Also In the program there will need to be an introduction screen, 3 levels which end when you recieve a certain amount of points, a data table, for my use which collects information about time between moves, total time, par time( how long it would take if no errors occured), and levels completed. Also if a user fails to pass the level, at what point did they fail. The data will need to be organized in a logical order and finally there will need to be a way for me to retrieve the data. I already have the existing tetris code and I need to add to it, so if anyone could help me as I have no programming knowledge and I need this done as soon as possible, please contact me at [email protected] and I will be willing to pay for your time.
Thanks,
RossI am a student conducting research as to the
tolerance of users to a user interface. We call that Human Factors :-)
My idea is to
take the existing tetris game but implement errors
into it, so that on occasion the piece will not move
in the direction you want it to. So the idea is to piss the user off?!
Also In the program
there will need to be an introduction screen, 3
levels which end when you recieve a certain amount of
points, a data table, for my use which collects
information about time between moves, total time, par
time( how long it would take if no errors occured),
and levels completed. okay...
Also if a user fails to pass
the level, at what point did they fail. The data will
need to be organized in a logical order and finally
there will need to be a way for me to retrieve the
data. I already have the existing tetris code and I
need to add to it, so if anyone could help me as I
have no programming knowledge and I need this done as
soon as possible, please contact me at
[email protected] and I will be willing to
pay for your time.
Thanks,
RossFirst of all, it's probably not a good idea to post your email address, not that anyone will email you anyway. Second, I'm not sure how you're going to accomplish this programming task if you don't know how to program. See the problem? -
Need help writing a code for this program
Design a code that reads a sentence and prints each individual word on a different line
tsith's suggestion is excellent. Run it and see what happens. I just did that myself and doing so I learned something new about the Scanner class.
Before you run it, add a couple of extra System.out.println for (hopefully) illustrating debugging purposes:
import java.lang.String;
import java.util.Scanner;
public class Sentence {
// main line of program
public static void main(String[] args) {
boolean z;
String a;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter sentence: ");
z = keyboard.hasNext();
while (z) {
System.out.println("z = " + z + ". Fetching the next word...");
a = keyboard.next();
System.out.println(a);
System.out.println("Done!");
}Let us know if the program ever prints "Done!" to the console. While you are waiting, read what the javadocs has to say about the Scanner class, and pay extra attention to what it says about the hasNext() and next() methods:
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html -
Need help writing correct code for nested button
This is the code on the main timeline.
stop();
garage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void {
gotoAndPlay("open");
The movieClip gDoor is nested inside of garage and "open" is a label on that timeline. I know the gotoAndPlay("open"); isn't correct. How would i target the label on the nested timeline.
the link below is to dowload the fla
clienttestsite.x10.mx/beta/garage.flaThe problem is that you have an event listener assigned to the garage, which is blocking/overriding interaction with anything inside of it. When you click on the chest's button, you are still clicking on the garage, which does the gotoAndPlay("open")... where it stops at the stop();
One way to get around this is to assign an instance name to the door and assign the opening code to that....
stop();
garage.door.addEventListener(MouseEvent.CLICK, openHandler);
function openHandler(event:MouseEvent):void{
garage.play();
garage.chest.closeBtn.addEventListener(MouseEvent.CLICK, closeHandler);
function closeHandler(event:MouseEvent):void{
garage.gotoAndPlay("close");
Notes: as shown in the code above...
- use CLICK instead of MOUSE_DOWN.
- in the openHandler use play() instead of gotoAndPlay("open"). You are already in the "open" frame, and it is only because the stop() is used up that it actuallys works.
Doing what I explain above also makes it so that you can click the door to close things as well. -
How doest jdk docs help as in writing java code?
hi i wonder how does jdk docs help as in writing java code because if i google a java code the jdk docs always becomes the result of my search but in my experience jdk docs never helps me.
is there any one know how to use jdk docs? and how to get the code from there.
im telling about jdk docs from here http://download.oracle.com/javase/1.4.2/docs/api/
cross posted from http://www.thenewboston.com/forum/viewtopic.php?f=119&t=13778
Edited by: 871484 on Jul 18, 2011 4:18 PM871484 wrote:
ok can any one give me example how to use jdk docs? for example this code
Your question still does not make any sense, and you still haven't clarified what you're not understanding.
However, if you think that just by reading the API docs, with no other training or study, that you will be able to write that code, then you are seriously misunderstanding the purpose of the docs.
Obviously English is not your native language. You grew up speaking some other language at home and with your friends, and at some point in school or as private study, you started to learn English. You learned about the grammar and the alphabet and pronunciation, sentence structure, word order, etc. Now you have the basics of how the language works, and you know some words. When you want to learn new words to fit into the structure you have learned, you use a dictionary.
If you didn't study the grammar, sentence structure, etc., and just said, "I want to learn English. I will look at a dicationary," clearly that would not work.
Right?
So, since you now understand and agree with the English example, let me state something that I hope is obvious to you by now: The API docs are your dictionary. They are not a substitute for learning the language basics.
Furthermore, once you know the language basics in English and have your dictionary, you still won't know how to write a resume (which you may know as a CV). You will look at examples and perhaps take a course on resume (CV) writing. Just reading a dictionary won't help you write a resume(CV). Similarly, if you know some Java basics, you can't learn how to write a Swing app just by reading the Javadocs. You'll look at tutorials and examples. Then, once you know the basic structure of a Swing app, you'll look to the javadocs for more details about more kinds of GUI classes--different buttons and windows and panes and panels and layout managers, etc. -
Need help writing small program!
Hi. I'm learning Java programming, and I need help writing a small program. Please someone help me.
Directions:
Create a program called CerealCompare using an if-then-else structure that obtains the price and number of ounces in a box for two boxes of cereal. The program should then output which box costs less per ounce.class CerealCompare {
public static void main(String[] args) {
// your code goes here
}Hope that helps.
P.S. Java does not have an if-then-else statement. -
I need help with this code error "unreachable statement"
the error_
F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
int index;
^
F:\Java\Projects\Tools.java:71: missing return statement
}//end delete method
^
F:\Java\Projects\Tools.java:86: missing return statement
}//end getrecod
^
3 errors
import java.util.*;
import javax.swing.*;
import java.awt.*;
public class Tools//tool class
private int numberOfToolItems;
private ToolItems[] toolArray = new ToolItems[10];
public Tools()//array of tool
numberOfToolItems = 0;
for(int i = 0; i < toolArray.length; i++)//for loop to create the array tools
toolArray[i] = new ToolItems();
}//end for loop
}//end of array of tools
public int search(int id)//search mehtod
int index = 0;
while (index < numberOfToolItems)//while and if loop search
if(toolArray[index].getID() == id)
return index;
else
index ++;
}//en while and if loop
return -1;
}//end search method
public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
if(numberOfToolItems >= toolArray.length)
return 0;
int index;
index = search(id); <-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------HERE
if (index == -1)
toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
numberInStock ++;
return 1;
}//end if index
}//end if toolitem array
return -1;
}//end insert method
public int delete(/*int id*/)//delete method
}//end delete method
public void display()//display method
for(int i = 0; i < numberOfToolItems; i++)
//toolArray.display(g,y,x);
}//end display method
public String getRecord(int i)//get record method
// return toolArray[i].getName()+ "ID: "+toolArray[i].getID()
}//end getrecod
}//end class
Edited by: ladsoftware on Oct 9, 2009 6:08 AM
Edited by: ladsoftware on Oct 9, 2009 6:09 AM
Edited by: ladsoftware on Oct 9, 2009 6:10 AM
Edited by: ladsoftware on Oct 9, 2009 6:11 AMladsoftware wrote:
Subject: Re: I need help with this code error "unreachable statement"
F:\Java\Projects\Tools.java:51: unreachable statement <-----------------------------------------------------------------------------------------------------------------THIS
int index;
^
F:\Java\Projects\Tools.java:71: missing return statement
}//end delete method
^
F:\Java\Projects\Tools.java:86: missing return statement
}//end getrecod
^
3 errorsThe compiler is telling you exactly what the problems are:
public int insert(int id, int numberInStock, int quality, double basePrice, String nm)//insert method
if(numberOfToolItems >= toolArray.length)
return 0; // <<== HERE you return, so everyting in the if block after this is unreachable
int index;
index = search(id); //< -----------------------------------------------------------------------------------------------------------------HERE
if (index == -1)
toolArray[index].assign(id,numberInStock, quality, basePrice,nm);
numberInStock ++;
return 1;
}//end if index
}//end if toolitem array
return -1;
}//end insert method
public int delete(/*int id*/)//delete method
// <<== HERE where is the return statement?
}//end delete method
public String getRecord(int i)//get record method
// return toolArray.getName()+ "ID: "+toolArray[i].getID() <<== HERE you commented out the return statement
}//end getrecod
}//end class -
I need help with my code..
hi guys. as the subject says I need help with my code
the Q for my code is :
write a program that reads a positive integer x and calculates and prints a floating point number y if :
y = 1 ? 1/2 + 1/3 - ? + 1/x
and this is my code
This program that reads a positive integer x and calculates
and prints a floating point number y if :
y = 1 - 1/2 + 1/3 - ? + 1/x
import java.util.Scanner; // program uses class Scanner
class Sh7q2
// main method begins execution of Java application
public static void main( String args[] )
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
int i = 1; // i is to control the loop
int n = 2; // n is suppose to control the number sign
int x; // a positive integer entered by the user
int m;
System.out.println("Enter a positive integer");
x = input.nextInt();
do
m = (int) Math.pow( -1, n)/i;
System.out.println(m);
n++;
i++;
while ( m >= 1/x );
} // end method main
} // end class Sh7q2 when I compile it there is no error
but in the run it tells me to enter a positive integer
suppose i entered 5
then the result is 1...
can anyone tell me what's wrong with my codeThis program that reads a positive integer x and calculates
and prints a floating point number y if :
y = 1 - 1/2 + 1/3 - ? + 1/x
import java.util.Scanner; // program uses class Scanner
class Sh7q2
// main method begins execution of Java application
public static void main( String args[] )
// create Scanner to obtain input from command window
Scanner input = new Scanner( System.in );
int i = 1; // i is to control the loop
int n = 1; // n is suppose to control the number sign
int x; // a positive integer entered by the user
double m;
int a = 1;
double sum = 0;
System.out.println("Enter a positive integer");
x = input.nextInt();
for ( i = 1; a <= x; i++)
m = Math.pow( -1, n+1)/i;
sum = sum + m;
n++;
a++;
System.out.print("y = " + sum);
} // end method main
} // end class Sh7q2is it right :S -
Need Help Writing Server side to submit form via API
Hey
I need help writing a serverside application to submit
information via API to a separate server.
I have a client that uses constant contact for email
campaigns. We want to add to her website a form taht submits the
information needed to subscribe to her email list, to constant
contact via API.
FORM.asp :: (i got this one under control)
name
email
and submits to serverside.asp
SERVERSIDE.ASP
In serverside.asp i need to have
the API URL
(https://api.constantcontact.com/0.1/API_AddSiteVisitor.jsp)
username (of the constant contact account)
password (of the constant contact account)
name (submited from form.asp)
email (submitted from form.asp)
redirect URL (confirm.asp)
Can anyone help get me going in the right direction?
i have tried several things i found on the net and just cant
get anyone to work correctly.
One main issue i keep having is that if i get it to submit to
the API url correctly - i get a success code, it doesnt redirect to
the page i am trying to redirect to.
ASP or ASP.NET code would be find.
THANKS
sam> This does require server side programming.
> if you dont know what that is, then you dont know the
answer to my question. I
> know what i need to do - i just dont know HOW to do it.
If you are submitting a form to a script on a remote server,
and letting
that script load content to the browser, YOU have no control
over what it
loads UNLESS there is some command you can send it that it
will understand.
No amount of ASP on your server is going to change what the
remote script
does.
http://www.constantcontact.com/services/api/index.jsp
they only allow their customers to see the instructions for
the API so i
can't search to see IF there is a redirect you can send with
the form info.
But posts on their support board say that there is.
Alan
Adobe Community Expert, dreamweaver
http://www.adobe.com/communities/experts/ -
Hi All
I dont know which one of the following is more effective in JSP
writing java code like <% out.println("Hellooo "); %>
OR
writing like <%="hello" %>
I shall be very much thankful to all those who spare their valuable time to clarify my doubt. I hope my question is not a stupid one.
Thanks
Elishawhen both gives the same out put, why there are two for the same out put?Because it is easier to do this:
Hello <%= userName %>
than this:
Hello <% out.println("userName"); %>
Also there is a BIG difference in readability and maintainability of the JSP page. JSP pages are all about having html, and a few "fill in the blank" spots. The less <% scriptlet code %> you put on your JSP page, the better. If you want to run java code, do it in a servlet/bean.
With the advent of JSTL, scriptlet code in JSPs should be a thing of the past. -
Need help in transcation code ime0
I need help in transaction code ime0. I mean to say what is this TCode doing? What different Drill-down program means? Where I can use this report?
Regards,
SubhasishHi
Please check the link for help
<a href="http://help.sap.com/saphelp_47x200/helpdata/EN/5c/8db33f555411d189660000e829fbbd/frameset.htm">CA - Drilldown Reporting</a>
Hope it helps
Anirban -
Need help writing host program using LabView.
Need help writing host program using LabView.
Hello,
I'm designing a HID device, and I want to write a host program using National Instrument's LabView. NI doesn't have any software support for USB, so I'm trying to write a few C dll files and link them to Call Library Functions. NI has some documentation on how to do this, but it's not exactly easy reading.
I've written a few C console programs (running Win 2K) using the PC host software example for a HID device from John Hyde's book "USB by design", and they run ok. From Hyde's example program, I've written a few functions that use a few API functions each. This makes the main program more streamlined. The functions are; GetHIDPath, OpenHID, GetHIDInfo, Writ
eHID, ReadHIC, and CloseHID. As I mentioned, my main program runs well with these functions.
My strategy is to make dll files from these functions and load them into LabView Call Library Functions. However, I'm having a number of subtle problems in trying to do this. The big problem I'm having now are build errors when I try to build to a dll.
I'm writing this post for a few reasons. First, I'm wondering if there are any LabView programmers who have already written USB HID host programs, and if they could give me some advice. Or, I would be grateful if a LabView or Visual C programmer could help me work out the programming problems that I'm having with my current program. If I get this LabView program working I would be happy to share it. I'm also wondering if there might already be any USB IHD LabView that I could download.
Any help would be appreciated.
Regards, George
George Dorian
Sutter Instruments
51 Digital DR.
Novato, CA 94949
USA
[email protected]
m
(415) 883-0128
FAX (415) 883-0572George may not answer you. He hasn't been online here for almost eight years.
Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice -
I need help writing a script that finds the first instance of a paragraph style and then changes it
I need help writing a script that finds the first instance of a paragraph style and then changes it to another paragraph style. I don't necessarily need someone to write the whole thing, by biggest problem is figuring how to find just the first instance of the paragraph style. Any help would be greatly appreciated, thanks!
Hi,
Do you mean first instance of the paragraph style
- in a chosen story;
- on some chosen page in every text frames, looking from its top to the bottom;
- in a entire document, looking from its beginning to the end, including hidden layers, master pages, footnotes etc...?
If story...
You could set app.findTextPreferences.appliedParagraphStyle to your "Style".
Story.findText() gives an array of matches. 1st array's element is a 1st occurence.
so:
Story.findText()[0].appliedParagraphStyle = Style_1;
//==> this will change a paraStyle of 1st occurence of story to "Style_1".
If other cases...
You would need to be more accurate.
rgds -
Need Help on this Code Immediately
Hi Friends,
Iam very new to java.
I have a Java Code that iam trying to Run. The Code Compiles fine but it fails on its 3rd Loop where it is trying to Run a report.
I have the Code part that is errorring out. Can someone please look into the code and tell me if i need to make any changes to the Code.
The Code when Executed gives an Error "The Client Did Something Wrong".
Please Help Me!!!
* Execute a report.
*@param path This is the search path to the report.
*@param format The array that contains the format options (PDF,HTML,etc...)
public void executeReport(String path,String[] format)
ParameterValue pv[] = new ParameterValue[]{};
Option ro[] = new Option[3];
RunOptionBoolean saveOutput = new RunOptionBoolean();
RunOptionStringArray rosa = new RunOptionStringArray();
RunOptionBoolean burstable = new RunOptionBoolean();
// Define that the report to save the output.
saveOutput.setName(RunOptionEnum.saveOutput);
saveOutput.setValue(true);
// What format do we want the report in: PDF? HTML? XML?
rosa.setName(RunOptionEnum.outputFormat);
rosa.setValue(format);
// Define that the report can be burst.
burstable.setName(RunOptionEnum.burst);
burstable.setValue(true);
// Fill the array with the run options.
ro[0] = rosa;
ro[1] = saveOutput;
ro[2] = burstable;
try
SearchPathSingleObject spSingle = new SearchPathSingleObject();
spSingle.setValue(path);
// Get the initial response.
AsynchReply res = reportService.run(spSingle,pv,ro);
// If it has not yet completed, keep waiting until it is done.
// In this case, we wait forever.
while (res.getStatus() != AsynchReplyStatusEnum.complete && res.getStatus() != AsynchReplyStatusEnum.conversationComplete)
res = reportService.wait(res.getPrimaryRequest(), new ParameterValue[]{}, new Option[]{});
reportService.release(res.getPrimaryRequest());
// Return the final response.
catch (Exception e)
System.out.println(e);
}Guess I was too late. Sorry
Inestead of posting you need help on code immediately how about intest posting the particular topic that you are working on. It's quite doubtful that you would be here if you didn't have a question. -
i Need some help in Java Script,
am using the following code :
<script type="text/javascript">
var newwindow;
function poptastic(url)
newwindow=window.open(url,'name','height=300,width=400,left=100, top=100,resizable=yes,scrollbars=yes,toolbar=yes,status=yes');
if (window.focus) {newwindow.focus()}
else {newwindow.close()}
// if (window.focus) {newwindow.focus()}
</script>
In HTML,
thWorld Environment
Day, June 5<sup>th</sup>,2005
Am using onmouseover event, so that when my mouse in on the link, popup is opened....and when my mouse is out of the link, the new window should b closed....
but according to the above code, the new window is opened but have to close it manually....
Is there any other way to close the popup when my mouse is out of the linkPrawn,
This is not really a good way to make friends. With the cross posting and the posting in a wrong forum anyway thing you have going.
Please kindly take your question to an appropriate JavaScript forum.
Have a happy day.
Cross post from http://forum.java.sun.com/thread.jspa?messageID=3797201
Maybe you are looking for
-
My iPhone backs up only via iTunes to iCloud. When changing the option to "this computer" message says :Your iphone has never been backed up to this computer..Manually back up and restore functions are greyed out and not available. Any ideas how to f
-
I moved my entire Iphoto Library from my Macbook Pro to an external hard drive. (Prior to this, I also copied the entire library to a different ehd, plus I have 2 other ehdrives with backups). I was trying to get more space on my hd. It has a capacit
-
Scoring one of three button clicks on a single screen - can it be done
I have captured an Assessment simulation (in Captivate 5). On one screen there are three legitimate places a person can click to move to the next screen - any of them would be correct. At the moment, each is being tracked for a point on the Quiz, but
-
Input help required for parameter on the selection screen
hi all, i have created two parameters on the selection screen. 1. deptno 2.empname so my requirement is if i input any deptno then i should get all the empname corresponding to that deptno in the parameter empname ie for deptno 10 there should be f4
-
My new update to FF version 33 is installed LOCKED in full screen and I can not get to my desktop
I use a HDMI TV as a monitor. When I upgraded to ver 33.02(?), it locked in FULL SCREEN and my TV/Monitor is not adjustable so the option at the top "EXIT FULL SCREEN" is not showing or available and must be rolled off the top. I can not find any way