Results 1 to 3 of 3
  1. #1
    toomanypaces is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default Need help with algorithms in looping

    Had issues with looping percentages, trying to increment a certain value by ten percent untill it reaches a certain point. HELP PLEASE!!!!!





    package sampleTest;

    import java.util.Scanner;
    public class random {
    public static void main(String[]args){
    int level = 1;
    //double bash = 15;
    double increment_bash;
    Scanner input = new Scanner(System.in);
    System.out.println("Enter the percentage: ");
    double percentage = input.nextDouble();

    System.out.println("Enter the damage: ");
    double bash2 = input.nextDouble();



    while(level <= 45){
    double bash3;
    bash3 = ((bash2 * percentage) + bash2);

    System.out.println("Current level " + level);
    System.out.println("Current damage for that level is: " + bash3);
    level++;


    }











    }


    }

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Need help with algorithms in looping

    Moved from 'Algorithms'

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: Need help with algorithms in looping

    In the body of your loop, that values of bash and percentage never change, so the value of bash3 never changes, i.e. the same value is calculated over and over again.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Are these well written algorithms?
    By dharav in forum New To Java
    Replies: 3
    Last Post: 01-12-2012, 08:27 AM
  2. Sorting Algorithms
    By fam2315 in forum New To Java
    Replies: 7
    Last Post: 07-27-2011, 05:55 AM
  3. Threaded algorithms
    By TerTer in forum Threads and Synchronization
    Replies: 0
    Last Post: 04-20-2010, 02:58 PM
  4. Compression Algorithms
    By kishan in forum Advanced Java
    Replies: 1
    Last Post: 09-21-2009, 09:13 AM
  5. Iterative Algorithms
    By Zosden in forum Algorithms
    Replies: 1
    Last Post: 07-05-2008, 06:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •