Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Java
  3. Question
Java

What is the significance of the currency converter java?

Asked by Maryann Reller Oct 11, 2022 1.1K views 1 answer
Share

About this question

This is my basic currency converter for my intro to Java class. I'm supposed to be able to convert between Yen, Dollars, Pounds and Euros using static rates. It works, but I was curious to know if I did it in the most efficient way possible. It seems quite long and looks like a huge mess. Just wanting some feedback.

import java.util.Scanner; public class currency { public currency() { char us_dollar_sym = 36; char pound_sym = 163; char yen_sym = 165; char euro_sym = 8364; String us_dollar = "Dollars"; String pound = "Pounds"; String yen = "Yen"; String euro = "Euros"; double rate = 0; // Interface System.out.println("Welcome to the Currency Converter Program n"); System.out.println("Use the following codes to input your currency choices: n 1 - US dollars n 2 - Euros n 3 - British Pounds n 4 - Japanese Yen n"); // System.out.println("Please choose the input currency:"); Scanner in = new Scanner(System.in); int choice = in.nextInt(); String inType = null; switch(choice) { case 1: inType = "US Dollars >> " + us_dollar_sym; break; case 2: inType = "Euros >> " + euro_sym; break; case 3: inType = "British Pounds >> " + pound_sym; break; case 4: inType = "Japanese Yen >> " + yen_sym; break; default:

Your answer

1 Answer

More Java discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Java Blogs

Guides, tips and career advice on Java from JanBask experts.