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

Thread: Converter

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Converter

    Hello there

    i was wondering if someone is able to help me,
    im kinda trying to make converter between 2 parameters which the user need to type,
    and compare them ,same about the amount (the user needs to insert that parameter (the amount of the value))
    im kinda getting confused how to write it right, i've made a start and not sure how to continue it, and i would gladly take any offers
    suggestion about it

    Thanks

    import java.util.*;
    public class Converter
    {
    	static Scanner reader=new Scanner (System.in);
    	public static void main (String[]args)
    	{
    		int amount=0, insertGold, insertCPs;
    		double cpsPrice, goldPrice;
    		System.out.println("What do you want to convert (cps silver)");
    		int cp=reader.nextInt();
    		int silver=reader.nextInt();
     
    		if ((silver==1)&&(cp==0))
    			System.out.println("Type in the amount of the silver that u want to convert into cps");
    			insertGold=reader.nextInt();
    			System.out.println("Type in the amount of the cps that u want to buy");
    			insertCPs=reader.nextInt();
     
    		if ((silver==0)&&(cp==1))
    			System.out.println("Type in the amount of the cps that u want to convert into silver");
    			insertCPs=reader.nextInt();
    			System.out.println("Type in the amount of the silver that u want to buy");
    			insertGold=reader.nextInt();
     
    	}
    }

    Yeah as you can see ima newbie
    i was thinking maybe it's possible to make boolean access to those ifs...


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

    Default Re: Converter

    Can you explain what the program is supposed to do? Also could give an example of the input to the program and what it is supposed to output with that input.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Converter

    technically it should work as a converter that the user inputs the parameters,
    with the price, and amount of each side.

    i kinda getting confused by my self right now....
    that based idea is like you want to buy 10apples.
    the price (the user need to input) x
    output how many he can buy in that amount ,and will something be left. Something like that... .
    hope it's enough to understand the idea that im trying to explain.

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

    Default Re: Converter

    Can you give some specific examples of the input to the program and what it is supposed to output with that input
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Converter

    well for example:
    Amount: 1cp
    buyPrice: lets say 100,000
    sellPrice: 110,000
    Ratio of the gaining: (output) 110%
    profit: 10% (10k)

    and the opposite ..
    amount 1m (gold)
    buyPrice: 10cps
    sellprice: 12 (per those 100k)




    well something like that, it's for trading .... .i hope that the idea is now more understandable

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

    Default Re: Converter

    Your example does not show:
    Which data is the input
    what is the output?

    Can you make two lists? One of the input and one of the output.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Converter

    as i've said before the input includes Amount, buyPrice, and sellPrice, all the other things are the output such as profit, and ratio, right now im thinking of any other parameters ... .

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

    Default Re: Converter

    , right now im thinking of any other parameters ... .
    That's good that you are trying to work on the details of the design before trying to write the code.

    When you get a design and need help writing code for it, post the code and ask your questions about the problems you are having.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Converter

    Quote Originally Posted by Norm View Post
    That's good that you are trying to work on the details of the design before trying to write the code.

    When you get a design and need help writing code for it, post the code and ask your questions about the problems you are having.
    Thanks for the support... .
    but i like to code the stuff i need , and just improve it, and by mistakes. but i came here because i'm lost and not sure how to continue that... i got the idea but im stuck...
    i would appreciate it, if someone could help me to continue ...

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

    Default Re: Converter

    Can you explain what you are stuck on?
    So far you have said:
    The input is: Amount, buyPrice, and sellPrice
    what other things does the program need for input? Are there dependencies between the inputs?

    What will the program's output be? Make a list.
    How does the output depend on the input? Are there formulas?
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Converter

    im stuck on the output of the programs, I'm not sure how to put things out so it will make the calculating stuff, how to make the percentage that i mentioned before. and something like boolean rule of:
    Convert in or convert out as the code is written till now,and now as i wrote it.
    about the in put, for now i can't think about anything.

    output is gonna be different for both of sides, but it should be based on:
    How much did the user spend:
    How much the user won on that deal : (example)
    Ratio of the gaining: (output) 110%
    profit: 10% (10k)

    basicly it should me like merchanting stats , if u know what i mean.

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

    Default Re: Converter

    Sounds like you need to spend more time thinking about the problem.
    If you don't understand my answer, don't ignore it, ask a question.

  13. #13
    Junior Member
    Join Date
    Nov 2013
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Converter

    ... i wonder why i came here now. for help or ... im thinking about it ,around 3days , and there is a reason i came here, if i could i wasn't coming here.

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

    Default Re: Converter

    If you don't know specifically what you want the program to do, how can anyone help you write the program?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. temperature converter
    By pranavk26 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 11th, 2013, 06:38 AM
  2. Military time converter
    By ebone in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 12th, 2011, 02:56 AM
  3. J2ME converter program
    By sackling in forum What's Wrong With My Code?
    Replies: 0
    Last Post: December 6th, 2010, 09:13 AM
  4. phonetic to cyrillic converter
    By Brt93yoda in forum Java Theory & Questions
    Replies: 1
    Last Post: September 5th, 2010, 02:26 PM
  5. Piglatin Converter
    By jross21 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 14th, 2010, 12:09 PM