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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:57:58+00:00 2026-06-15T09:57:58+00:00

I have the user enter their location. and based on their location there is

  • 0

I have the user enter their location.
and based on their location there is a pay difference.
the if statements doesn’t change the variable “pay”
can someone help me?

import java.util.HashMap;
import javax.swing.*;

public class TimeSheet {

    public static void main(String[] args) {

        String loc;
        String[] startday = new String[7];
        String[] endday = new String[7];
        int x = 0;
        int y = 0;
        int num = 1;
        int location;
        double starttime;
        double endtime;
        double hour = 0;
        double total = 0;
        double pay = 0;
        double totalpay;

        loc = JOptionPane.showInputDialog(null, "Enter your Work Location");
        location = Integer.parseInt(loc);

        if (location == 100 && location < 200 ) {
            pay = 10.00;
        }
        else if (location == 200 && location < 300) {
            pay = 7.50;
        }
        else if (location == 300 && location < 400) {
            pay = 9.25;
        }
        else if (location == 400 && location < 500) {
            pay = 13.50;
        }
        else if (location == 500 && location < 600) {
            pay = 8.00;
        }

        HashMap<String, Double> map = new HashMap<String, Double>();
        map.put("1",9.0);
        map.put("2",9.5);
        map.put("3",10.0);
        map.put("4",10.5);
        map.put("5",11.0);
        map.put("6",11.5);
        map.put("7",12.0);
        map.put("8",12.5);
        map.put("A",13.0);
        map.put("B",13.5);
        map.put("C",14.0);
        map.put("D",14.5);
        map.put("E",15.0);
        map.put("F",15.5);
        map.put("G",16.0);
        map.put("H",16.5);
        map.put("I",17.0);

        while (x < 7 && y < 7) {

            startday[x] = JOptionPane.showInputDialog(null, "Enter Day "+num+" 's Starting code");
            endday[y] = JOptionPane.showInputDialog(null, "Enter Day "+num+" 's Ending code");

            starttime = map.get(startday[x]);
            endtime = map.get(endday[y]);

            hour = endtime - starttime;
            total = total + hour;
            totalpay = total*pay;

            JOptionPane.showMessageDialog(null, "total hour" + total);
            JOptionPane.showMessageDialog(null, "total pay for the week is " + totalpay);

            x++;
            y++;
            num++;


        }

    }

}
  • 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-15T09:57:59+00:00Added an answer on June 15, 2026 at 9:57 am

    your conditions are like:

    else if (location == 200 && location < 300) {
    

    translate to english

    if location is exactly 200 and less than 300.

    You probably want to change it to

    if location is greater or equals than 200 and less than 300.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very small form where a user can enter their zip code
I have a form a user can enter their name, then it will add
I have this change password request form.In which the user enter their oldpasswords. this
in my application i have an form where user enter their username first .
I have implemented a LoginAccess class that prompts the user to enter their active
I want to have two input with one button for user to enter their
I have a content editable div where users can enter their bio and then
I have created one Login Screen where user enter their mail id. But i
1. HTML I have an input requesting the user to enter their PIN code:
I have a form that asks the user to enter their Google Analytics code

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.