Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:00:43+00:00 2026-06-03T06:00:43+00:00

// Week 3 Checkpoint1: Payroll Program Part 2 // Due May 04, 2012 //

  • 0
// Week 3 Checkpoint1: Payroll Program Part 2
// Due May 04, 2012
// Created by: Kennith Adkins

import java.util.Scanner;

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

        // Variables
        String employeeName = null;
        int hours;
        double rate;
        double pay;

        while ( employeeName != "stop")
        {
        // Request information from user
        System.out.print ( "Employee Name: ");
        employeeName = input.nextLine();
        System.out.print ( "Hourly Rate: ");
        rate = input.nextDouble();
        System.out.print ( "Number of Hours worked this week: ");
        hours = input.nextInt();

        // Calculate pay
        pay = rate * hours;

        // Display information
        System.out.printf ("%s will get paid $%.2f this week.\n", employeeName, pay);


        }
    }
}

When I run the program it runs fine. When it hits the loop and repeats, Employee Name: and Hourly Rate seem to bunch up. Also how would I get it to immediately stop after typing stop as employee Name?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:00:44+00:00Added an answer on June 3, 2026 at 6:00 am

    As this appears to be a homework question I’ll point you in a learning direction.

    So for the employee name question I will redirect you to How do I compare strings in Java?

    The scrunching issue is because when you reenter the loop and call scanner(input).nextLine it ends up actually reading the input text that it had not seen yet. So one option is to switch to something else lick a BufferedReader or move the scanner deceleration down in to the loop.

    More research

    I haven’t worked much with the scanner class and after seeing this I was somewhat confused. The issue is actually the nextInt and nextDouble. They dont claim the return charter and as such when you call next line next time it is picking up the leftover return character.

    So my option of reseting the scanner when reentering works in this specific case but you should either use 2 scanners or move off of scanners.

    Scanner txtinput = new Scanner(System.in);
    Scanner numberinput = new Scanner(System.in);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Last week, we created a program that manages sets of strings, using classes and
In the last week I've created two classes which my team expressed some concerns
This week I had to look into a Java WebService project which was using
Last week in our java course we were introduced the Object class and some
I have just one week experience in GAE/Java and trying to port an legacy
week DKK id=radio2 value=75 /> I have bunch of these div entry generated by
Last week we released Omniture's analytics code onto a large volume of web sites
Last week I implemented a date validation in our front end, a combination of
this week I'm having problems logging in LinkedIn using ruby mechanize. My code is
This week I have figured out how to modify form elements in the location

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.