# How To Solve Programming Questions In Less Than 24 Hours.

0
55

How To Solve Programming Questions In Less Than 24 Hours?

Welcome again, I will start from today to tell a small story, in which I helped a friend who asked that I solve a problem in the Java program, until I solved all his exercises to accept to pass the programming exams at Le Havre University in France, of course our friend is proficient in programming because the material did not It was never important for the student of the Engineering and Architectural Engineering Division.

Let’s in this tutorial show steps to solving a programming problem, and how to improve problem solving skills in any programming issue.

So as you know, algorithm is a set of logical and organized steps to solve a problem.

Algorithm is a general term and is not related to programming only, because when you arrange some logical steps for making something, then here you made an algorithm, and the programmer is not a programmer unless he knows how to make algorithms, because programming is simply a solution to problems, and to solve these problems you need steps Logical, these steps together are called an “algorithm” And an example of algorithms in programming,

In any case, I received the first exercise and it was a simple question, as follows:
Program a Java application or program that converts liters to gallons (US) and vice versa, and the quantity to be converted then the starting unit is entered by the user,

(If the user enters something else “liters” or “gallons” per unit in it will be required) The conversion rate from liters to gallons is 0.264172
Of course, I do not understand liters or gallons. What I did was a simple search on Google to understand the Formula, So it’s not necessarily as a programmer to be aware of all the sciences.
I will be using the IO java entry library.

Â

Â

well I create the getGallons method to extract gallons from liters, and getLiters function to extract liters from gallons.
The formula, of course, is that a gallon equals a liter multiplied by 0.264172052358148
Gallon = Liter * 0.264172052358148;

GetLiters’ formula is that a liter equals a gallon multiplied by 3.7854118.
Liter = Gallon * 3.7854118.

A simple math that solves the problem.

And so I finished my friend’s first exercise, of course he will later try it on his personal computer and test it, here the surprise will happen.

We can also create the same application case in C#, Javascript, C++, Python, it depends all on the algorithm.

This very briefly algorithms and problem solving, if you do not understand anything or just have any questions regading this topic, please ask us for comments.

Follow the rest of the story next time.

Â

``````import java.io.*;
import java.util.*;

class Main {

public static void main(String[] args)throws Exception{

System.out.println("Gallons is :" + getGallons(liter) + " G");

System.out.println("Liters is :" + getLiters(gallon) + " L");
}

/** Formule => Gallon = liter * 0.264172052358148 **/
public static double getGallons(int liter) throws Exception {
double gallon = liter * 0.264172052358148;
return gallon;
}

/** Formule => Liter = gallon * 3.7854118 **/
public static double getLiters(int gallon) throws Exception {
double liter = gallon * 3.7854118;
return liter;
}
}
``````