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 7840441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:47:05+00:00 2026-06-02T15:47:05+00:00

I’m just really learning Java, going through tutorials in book Java how to Program

  • 0

I’m just really learning Java, going through tutorials in book “Java how to Program” by Deitel and Deitel, so please forgive any basic mistakes I’m making. I understand my methodology might not be the best but I hope to improve this.

My problem is I believe I have constructed my program wrongly. Both the IF and ELSE options are being outputted when I execute the program.

If anyone could tell me why both options are executing it would be very much appreciated

Deepend

package controlStatments;
import java.util.Scanner;

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

        //Declare Variables
        double employeeOneRate;
        double employeeOneHours;
        double employeeTwoRate;
        double employeeTwoHours;
        double employeeThreeRate;
        double employeeThreeHours;
        int calculator;
        double employeeOneTotalPay;
        double employeeOneNormalPay;
        double employeeOneTotalPayOverTime;
        double overTimeRate;

        //Initiate Variables
        employeeOneRate = 0;
        employeeOneHours = 0;
        employeeTwoRate = 0;
        employeeTwoHours = 0;
        employeeThreeRate = 0;
        employeeThreeHours = 0;
        calculator = 0;
        employeeOneTotalPay = 0;
        employeeOneTotalPayOverTime = 0;
        overTimeRate = 1.5; 
        employeeOneNormalPay = 0;

        //Create While Loop
        while (calculator != -1)
        {   
            //Prompt user to input details
            System.out.print("\n\nPlease input the first employees rate");
            employeeOneRate =input.nextDouble();

            System.out.print("Please input the first employees Hours");
            employeeOneHours =input.nextDouble();

            if (employeeOneHours <= 40)
            {
                employeeOneTotalPay = employeeOneHours * employeeOneRate;
                System.out.printf("\nNormal time pay is: %.2f", employeeOneTotalPay);
            }
            else 
                employeeOneNormalPay = employeeOneRate * 40;
            employeeOneTotalPayOverTime = (employeeOneHours - 40) * (employeeOneRate * overTimeRate) + employeeOneNormalPay;                            
            System.out.printf("\n\nTotal Pay including Overtime is: %.2f", employeeOneTotalPayOverTime);
        }
    }
}
  • 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-02T15:47:06+00:00Added an answer on June 2, 2026 at 3:47 pm

    Change

    if (employeeOneHours <= 40)
            {
                employeeOneTotalPay = employeeOneHours * employeeOneRate;
                System.out.printf("\nNormal time pay is: %.2f", employeeOneTotalPay);
            }
            else 
                employeeOneNormalPay = employeeOneRate * 40;
            employeeOneTotalPayOverTime = (employeeOneHours - 40) * (employeeOneRate * overTimeRate) + employeeOneNormalPay;                            
            System.out.printf("\n\nTotal Pay including Overtime is: %.2f", employeeOneTotalPayOverTime);
    

    With:

    if (employeeOneHours <= 40)
            {
                employeeOneTotalPay = employeeOneHours * employeeOneRate;
                System.out.printf("\nNormal time pay is: %.2f", employeeOneTotalPay);
            }
            else 
           {
                employeeOneNormalPay = employeeOneRate * 40;
            employeeOneTotalPayOverTime = (employeeOneHours - 40) * (employeeOneRate * overTimeRate) + employeeOneNormalPay;                            
            System.out.printf("\n\nTotal Pay including Overtime is: %.2f", employeeOneTotalPayOverTime);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just learning how to program in Ruby on Rails, and I'm really impressed
This program reads emails (really just a .txt file structured like an email) and
I've got a small program that displays third-party generated HTML pages. It's really just
This is probably a really stupid error but iv'e just started learning the .awt
I'm pretty new to java and really enjoying learning about it. I have made
I have just started learning java and i have about 8 months time. My
My problem is in trying to solve a Binary Integer Program through Java. I
Greetings, I am learning rapidly about Java, however something I can really break my
I'm a novice programmer with basic Java experience, and currently learning Python. I've stumbled
I'm just learning Java... I have 2 custom classes. One is a Fraction and

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.