Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, So I'm trying to build a currency converter that pulls from a .csv file and this is what I have so far, but I

Hello,

So I'm trying to build a currency converter that pulls from a .csv file and this is what I have so far, but I keep getting a "Cannot resolve method 'openstream' error. Nothing else in the code is raising a red flag. I'm lost. Any help would be greatly appreciated

import java.io.*; import java.util.*; public class convert { public static void main(String[] args) { System.out.println("US Dollar -->Euro: " + ExchangeRate("USD", "EUR", 1000)); System.out.println("Euro -->US Dollar: " + ExchangeRate("EUR", "USD", 1000)); System.out.println("Indian -->US Dollar: " + ExchangeRate("INR", "USD", 1000)); } private static Double ExchangeRate(String from, String to, int amount) { try { String csvFile = "/Users/csv/forex.csv"; BufferedReader reader = new BufferedReader(new InputStreamReader(csvFile.openStream())); String line = reader.readLine(); if (line.length() > 0 || line =="USD" || line =="EUR" line =="INR") { return Double.parseDouble(line) * amount; } reader.close(); } catch (Exception e) { System.out.println(e.getMessage()); } return null; } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Why do we need benefi ts to be measureable?

Answered: 1 week ago