Tag Archives: If

Java CurrencyTranslator

Program shows the exchange rate (Doesn’t show real rates) for a requested sum between euros and USD. Edit: Testing GitHub Gists Old: import java.util.Scanner; public class CurrencyTranslator { Scanner reader=new Scanner(System.in); boolean repeat=true; double euroTOdollar=1.18;//€->$ rate double dollarTOeuro=0.85;//$->€ rate private void run(){ System.out.println(“*******************\nCurrency translator 1.0”); while(repeat){ int requestedOperation=getOperation();//euro->dollar or dollar->euro or exit executeRequestedOperation(requestedOperation); } }… Read More »

Java sum odd numbers

This program counts the sum of odd numbers between two given numbers. SumOdds.java import java.util.Scanner; public class SumOdds { public void run() { Scanner reader = new Scanner(System.in); int lowLimit, upLimit, even, sum=0; System.out.println(“Enter lower and upper limit. The sum of odd numbers will be counted between the limits.”); lowLimit=reader.nextInt(); upLimit=reader.nextInt(); reader.close(); //swap places without… Read More »