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 2 of 2

Thread: Whats going wrong here?

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

    Angry Whats going wrong here?

    Writing a inflation calc for class


    import java.util.Scanner;

    public class InflationCalculator {

    public static void main(String[] args){
    Scanner keyboard = new Scanner (System.in);
    RateOfInflation rateObject = new RateOfInflation();

    int cost, numberOfYears;
    double rateOfInflation;

    System.out.print("Enter the current cost of the item:");
    cost = keyboard.nextInt();

    System.out.println("Enter the expected inflation rate per year");
    System.out.print("(Enter as a percentage and do not include the percent sign");
    rateOfInflation = (keyboard.nextInt() * .01);

    System.out.print("Enter the whole number of years in the future to project cost:");
    numberOfYears = keyboard.nextInt();

    rateObject.calcMethod(cost, numberOfYears, rateOfInflation);


    }

    RateOfInflation.java <---- Error

    public class RateOfInflation {
    public double calcMethod(int cost, int numberOfYears, double rateOfInflation){
    int n = 0;
    double answer;
    while (n == numberOfYears){
    answer = (cost * rateOfInflation) + cost;
    n++;
    System.out.println( answer );
    }

    }
    }

    }


  2. #2
    Member
    Join Date
    Mar 2011
    Posts
    66
    My Mood
    Relaxed
    Thanks
    12
    Thanked 4 Times in 4 Posts

    Default Re: Whats going wrong here?

    First of all, you should wrap you code so that it is easily readable. Next, what is your problem specifically? You posted your code with a line that says "RateOfInflation.java <---- Error" yet fail to mention what the error is. What are you expecting your program to do and what is it doing? Is the RateofInflation.java actually inside of the InflationCalculator file or is it in a separate file?

Similar Threads

  1. WHATS WRONG
    By subodhkr in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 8th, 2012, 08:47 AM
  2. Whats wrong?
    By help2 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 4th, 2012, 05:22 AM
  3. whats wrong?
    By whattheeff in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 25th, 2011, 03:35 PM
  4. could you tell me whats wrong....
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 6th, 2010, 05:35 PM
  5. help whats wrong
    By silverspoon34 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 3rd, 2009, 02:41 AM