Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: If Statements

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default If Statements

    What am I doing wrong.
    Attached Files Attached Files


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: If Statements

    What am I doing wrong
    Please explain in more detail.

    Please copy and paste the full text of any error messages and paste it here.
    Also post the full text of the code, be sure to wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    SANA4SPA (September 22nd, 2014)

  4. #3
    Junior Member
    Join Date
    Sep 2014
    Posts
    9
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: If Statements

    Quote Originally Posted by Norm View Post
    Please explain in more detail.

    Please copy and paste the full text of any error messages and paste it here.
    Also post the full text of the code, be sure to wrap your code with code tags:
    [code=java]
    YOUR CODE GOES HERE
    [/code]
    to get highlighting and preserve formatting.
    3.2 Write an if statement that multiplies payRate by 1.5 If hours are greater than 40


    import java.util.Scanner;

    /*
    * To change this license header, choose License Headers in Project Properties.
    * To change this template file, choose Tools | Templates
    * and open the template in the editor.
    */

    /**
    *
    * @author user
    */
    public class Payrate
    {
    public static void main(String[] args)
    // 3.2 Write an if statement that multiplies payRate by 1.5 If hours are greater than 40

    { //create scanner object to read input.

    Scanner keyboard = new Scanner(System.in);

    //String payRate;
    //String pay;
    //String hrs;
    int Payrate;
    int Pay;
    int Hrs;

    // GET USER INPUT
    //prompt user and get first name
    //System.out.println("Lets calculate your pay\n");
    System.out.print("Enter the hrs worked: \n");
    Hrs =keyboard.nextInt();

    System.out.print("Enter your pay rate: \n");
    Payrate =keyboard.nextInt();


    if (Hrs>40)
    Pay=(Hrs*Payrate);
    Pay =keyboard.nextInt();
    System.out.println("This is your" +Pay);


    }

    }

  5. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: If Statements

    As already requested and explained, please post your code using code or highlight tags as explained near the top of this topic.

Similar Threads

  1. Questions about if statements and if-else statements
    By chakana101 in forum Java Theory & Questions
    Replies: 5
    Last Post: March 23rd, 2014, 05:37 PM
  2. help with if statements
    By tonynsx in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 30th, 2013, 04:28 PM
  3. If Statements help
    By cowsquad in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 10th, 2013, 06:41 AM
  4. if else statements
    By mozyman in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 24th, 2010, 08:06 PM
  5. If statements
    By Scottj996 in forum Java Theory & Questions
    Replies: 1
    Last Post: August 16th, 2010, 10:09 AM