## Java program to reverse a sentence

Problem Write a java program to: Reverse a sentence by letters Reverse a sentence by words Reverse Sentence by letters Code  public class Main {      public static void main(String[] args) {          String sentence=“Welcome to java”;          System.out.println(reverseByLetters(sentence));      }      public static String reverseByLetters(String sentence){          char[] c=sentence.toCharArray();          String out=“”;          for (int i=c.length–1;i>=0;i—){              out+=c[i];          }          return out;      }  }   Output avaj ot emocleW Explanation First, we broke the String sentence into characters by calling the toCharArray() function on the string. … Read more Java program to reverse a sentence

## Set EditText to input Numbers only

The input type of EditText in Android can be restricted. We can set it to input numbers only. There are the following types of numbers that we can set the EditText to input Unsigned Integer Signed Integer Unsigned Decimal Signed Decimal We will learn how to do this using XML and programmatically using java code. … Read more Set EditText to input Numbers only

## Java program to convert Binary to Decimal

I am going to discuss three different ways to convert binary to decimal in java. Using the built-in Integer.parseInt() method Building our own logic when the binary number is given as a String variable Building our own logic when the binary number is given as an int variable Basic Concept of Conversion Let’s say we … Read more Java program to convert Binary to Decimal

## Java Program to convert decimal to binary

Problem We are required to write a program to find the binary representation of a number. Designing Algorithm To design the logic to do the job, let’s first recall how we convert decimal numbers to binary on paper. Let’s say, we have a number 27. We will write it on paper: Now divide this number … Read more Java Program to convert decimal to binary

## Minimum Cost Problem – Java

Problem You are given a matrix of size m by n. You have to travel from the corner (0,0) to (m-1,n-1) of the matrix. Each entry of the matrix represents the cost to step on it. You are required to find the minimum possible cost to complete the journey. Example Code /**  *  * @author … Read more Minimum Cost Problem – Java

## Word Counter source code

This is the source code for the application “Word Counter”. For more information, visit: http://umersoftwares.blogspot.com/2018/06/word-counter-by-umer-softwares.html Source Code: View project on github Download project as zip file View code files: data.java hist.java infor.java mainscreen.java result.java setting.java  You may not copy, modify or redistribute it without prior permission from Hafiz Muhammad Umer ([email protected]). The application itself can … Read more Word Counter source code

## Least Perimeter Problem

Here is a slightly edited version of the problem I got: Given an array of integers, considering the integers as the lengths of sides of a triangle, write a function that returns the minimum perimeter of any triangle possible with these set of integers by using any three of them as the lengths of sides … Read more Least Perimeter Problem

## Date to Calendar source code

This is the source code for my application “Date to Calendar”. For more information about the program and download visit: https://umersoftwares.blogspot.com/2017/11/date-to-calendar-by-umer-softwares.html File: MainClass.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 … Read more Date to Calendar source code

## Mystery of this code is explained

I am going to discuss about the output of this code: It has different outputs in different IDEs: In NetBeans: In eclipse: Also see its output in JShell:  The reason for different outputs in different platforms is discussed below: Let us consider a code to input a number from the user and display the ASCII … Read more Mystery of this code is explained

## Simple Calculator Android Application Code

This is the code for a simple android application, made in android studio. It is no more than a simple calculator. You can see its interface in the screenshot below: You can download its apk from the button below: Code: activity_main.xml: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 … Read more Simple Calculator Android Application Code