Results 1 to 4 of 4
  1. #1
    MR bruto's Avatar
    MR bruto is offline Senior Member
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    130
    Rep Power
    0

    Default [HELP] with my code please.

    so yes this code (made by me) has already been posted several times now, but i need some help this time.
    i made a program that converts dollars to euros, and euros to dollars.
    since the course of the dollar changes everyday, i really want to let my application keep up with the real course. (so make it keep up with a website, so that the course in my program changes to the current course).

    this is the code:

    Java Code:
    import java.util.Scanner;
    
    class Eurodollar {
    	public static void main(String args []){
    		Scanner input = new Scanner (System.in);
    		System.out.println("press 1 for Euro > Dollar \t press 2 for Dollar > Euro");
    		int amount;
    		String eurodollar = input.nextLine();
    		switch(eurodollar){
    		case "1":
    		System.out.println("You chose for: Euro > Dollar ");	
    		System.out.println("\n");
    		System.out.println("Enter the amount: ");
    	    {
    		amount = input.nextInt();
    		System.out.println("Euro"+"\t"+"Dollar");
    		System.out.println(amount+ "\t" +(amount *  0.767636447));
    		}
    		break;
    		case "2":
    			System.out.println("You chose for: Dollar > Euro ");
    			System.out.println("\n");
    			System.out.println("Enter the amount: ");
    			amount = input.nextInt();
    			System.out.println("Dollar"+"\t"+"Euro");{
    			System.out.println(amount+ "\t" +(amount / 0.767636447));
    			
    			
    		
    			
    	
    		
    		}
    		}
    	}
    }

  2. #2
    monkeyjr97 is offline Senior Member
    Join Date
    Nov 2012
    Posts
    258
    Rep Power
    2

    Default Re: [HELP] with my code please.

    if you dont have a decent grasp on the basics, then i feel that connecting to a web source to retrive a value maybe difficult. i would say 9 decimal places is accurate enough, it wont fluctuate a huge amount. You could say at the start, accurate at : * show time of publication here *

  3. #3
    MR bruto's Avatar
    MR bruto is offline Senior Member
    Join Date
    May 2013
    Location
    The Netherlands
    Posts
    130
    Rep Power
    0

    Default Re: [HELP] with my code please.

    hmm i see...

    but i got all of the basics of java, but didnt learn how to get data off a website yet.

  4. #4
    monkeyjr97 is offline Senior Member
    Join Date
    Nov 2012
    Posts
    258
    Rep Power
    2

    Default Re: [HELP] with my code please.

    Unless you have a special data source to work on you would have to handle every bit of data on the website, the same way youd read a text file so its not exactly efficient. You could look up:

    its been a while since i messed with getting data from a host

    java - how to get data from a url - Stack Overflow

    Reading from and Writing to a URLConnection (The Java™ Tutorials > Custom Networking > Working with URLs)

    those are good starting points.

Similar Threads

  1. Replies: 1
    Last Post: 03-25-2012, 02:40 AM
  2. Replies: 16
    Last Post: 01-31-2012, 08:36 PM
  3. Replies: 0
    Last Post: 08-07-2011, 08:32 PM
  4. Replies: 0
    Last Post: 02-21-2011, 11:50 AM
  5. Replies: 1
    Last Post: 04-26-2007, 03:52 PM

Posting Permissions

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