Bob Spaulding

Greenhorn
+ Follow
since Oct 07, 2009
Merit badge: grant badges
For More
Canton OH.
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Bob Spaulding

Thanks for your help guys I am still trying to figure out the whole name thing I have tried a while loop a do while loop my brain is melting and this is only one assignment lol after I figure out the name problem then I have tofigure out how to total all the wages paid but im hung up on the name thing.
14 years ago
Ok I added the nextLine() statements and it is just skipping adding the name in the second time around and adding the first name automatically... I even tried using last name thinking with one word it wouldnt double up.

here is the code now:


14 years ago
I marked line 30 and it is an inputMisMatch error code. I tried deleting one of the name next()'s and that caused an error and if I put nextLine in it skips the name on the second loop and goes straight to hours lol...
14 years ago
Thank you for your advice and the suggestion to check out the other post! Ok after I have worked on this all day I have studied her way of writing this similar program.
I have rearranged my code using her structure as an example. We are only in chapter 3 of Absolute Java by Savitch so I wasnt familiar with some of her input but structuring is what I am having problems with. I got my code to compile and run through the first time and then when you get to enter the second name and you press enter there is an exception.
Here is my new code:

[b][/b]

The exception is at line 30 hourlyRate input statement im kind of stumped because it went through the loop once but gets an error when it goes through the second time.
I marked line 30 and it is an inputmismatch error code.
14 years ago
well I tried it still cant get it to work. We are only up to chapter 3 in the book so we are still in basic loops and structuring. it says to use sentinel logic to solve the problem.
14 years ago
its not working at the moment getting one error:

E:\ECA223\payRateCalc.java:29: cannot find symbol
symbol : variable ZZZZ
location: class payRateCalc
while(fullName != ZZZZ);


as for knowledge of java not so much. I think I am trying to hard im all over the book and still cant figure it out. lol
14 years ago
Ok here is my story. this is my first java course... I am not looking for someone to do my homework for me. I would like someone to tell me what I am doing wrong and what to do to correct it. so I can learn from my mistakes. I am writing code that takes employees name, pay, hours and overtime snd outputs it and then loops for multiple employees until a name of "ZZZZ" is entered. Here is what I have so far.



{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);


String fullName;
double rate = 0;
double pay;
double hours;
double regpay;
double ovtpay;

do
{
System.out.print( "Enter full name ");
fullName = keyboard.next();

}
while(fullName != ZZZZ);


{
do
{
System.out.print( "Enter total hours worked. ");
hours = keyboard.nextInt();
if(hours <=0)
System.out.print( "Must enter a quantity:");
} while(hours <=0);

while(hours <=0)

do
{
System.out.print( "Enter pay rate per hour. ");
pay = keyboard.nextDouble();
if(pay <=0)
System.out.print( "Must enter a pay rate:");
} while(pay <=0);

if (hours < 40);

pay = hours * rate;
ovtpay = 0;
regpay = pay;

if (hours > 40)

pay = regpay + ovtpay;
ovtpay = (hours - 40)* 1.5 * rate;
regpay = 40 * rate;
}
{
System.out.print("The employees name is:"+ fullName);
System.out.printf("The hourly rate is:%n$%6.2f%n"+ rate);
System.out.print("The hours are"+ hours);
System.out.printf("The regular pay is:%n$%6.2f%n"+ regpay);
System.out.printf("The overtime pay is:%n$%6.2f%n"+ ovtpay);
System.out.printf("The employee's total pay is:%n$%6.2f%n"+ pay);
}




}

}


Thanks to anyone that takes the time to help me. When I ask the instructor he corrects the issues himself without explaining what I did wrong...which doesnt really help me.
14 years ago