Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class valuteConverter {
- String dollars;
- Document doc;
- double dollarRubleCuourse = Double.parseDouble(usd());
- public String usd(){
- try{
- doc = Jsoup.connect("http://www.cbr.ru/").get();
- Element dollar = doc.select(".weak").first();
- dollars = dollar.text();
- }catch(IOException e){
- e.printStackTrace();
- }
- dollars = dollars.substring(5, dollars.length()).replace(',', '.');
- return dollars;
- }
- public static void main(String[] args) {
- String s= JOptionPane.showInputDialog("Что конвертировать? Доллары/рубли?");
- if(s.toLowerCase().equals("доллары")){
- String z = JOptionPane.showInputDialog("Введите сумму");
- double a = Integer.parseInt(z)*new valuteConverter().dollarRubleCuourse;
- JOptionPane.showMessageDialog(null, a + " " + "рублей");
- }else if(s.toLowerCase().equals("рубли")){
- String z = JOptionPane.showInputDialog("Введите сумму");
- double a = Integer.parseInt(z)/new valuteConverter().dollarRubleCuourse;
- JOptionPane.showMessageDialog(null, a + " " + "рублей");
- }else{
- JOptionPane.showMessageDialog(null, "Выбранная валюта мне неизвестна:(");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement