Skip to main content

How to Create a Java Program for Division (With explanations)| Learn Java in 5 minutes

How to Create a Java Program for Division. (With explanations)

Java is a common Programming Language used nowadays. In this blog, I will show you how to create a simple Java Program for Division.

Java is easy to understand.

Java may look difficult but is very easy. If you are having problems in learning it, I have created a tutorial below on how to learn it. Believe me, it is very easy.

1.While writing a division program, you must start with
import java.util.*;
 
Note: don't forget to write ";". It acts as a full stop.
 
2.Now you need to write "class" and the name of your program.
3.After that, you have to write a command. It is "public static void main()"
4. Next write the scanner class. Just write "Scanner x= new Scanner (System.in);"
5. Next, write "int" and any character such as a,b and c. Int means integer.
6. Now you have to write the output which will be visible to the visitor. So if my characters are a,b,c then-  System.out.println("Please enter the value of a");
    a=x.nextInt();
    System.out.println("Please enter the value of b");
    b=x.nextInt();
 c=a/b;
    System.out.println("The answer is " +c);
}
}
And your program is complete!
This is how your program will look like-
import java.util.*; class Division { public static void main() { Scanner x= new Scanner (System.in); int a,b,c; System.out.println("Please enter the value of a"); a=x.nextInt(); System.out.println("Please enter the value of b"); b=x.nextInt(); c=a/b; System.out.println("The answer is " +c); } }
If you read the explainations carefully and practice it daily, then you will be able to program with Java easily.
If you want to create a program for addition, you just need to replace the / with +. You can do this also for subtraction and multiplication.
 That's all for today. I hope you liked my blog. If you liked it, then do share it. Also, Don't forget to follow my blog.
Thank You
Read more How did the Deadliest Pandemics in History end?

Comments

Popular posts from this blog

How Technology and Science is helping in Covid-19 pandemic

How Technology and Science is helping in Covid-19 Pandemic The covid-19 Pandemic has wreaked havoc on the whole world. Our lives, both personal and professional have been greatly impacted. During this time of fear and uncertainty, our willingness to adapt to Technology has been our lifeline. Technology is helping us in managing Pandemics Covid-19 has directly impacted close to 1.45 billion students as schools and colleges have shut down. Thanks to Technology ,  most educational institutions have started to offer online courses to make sure that education is not disrupted due to the pandemic. Individuals are inclining toward home conveyance to remain safe. Subsequently, the online market has seen gigantic development.   Online teaching and work from home is a blessing that comes due to technology and is the greatest solution that helps in social distancing. Work from home has ensured business continuity. But just like the sides of a coin, technology has its own minus points.

How to Overcome fear of Public Speaking| Best Methods to overcome Stage Fright

       How to overcome the fear of Public Speaking     Have you ever been on stage and got nervous? Did you start sweating? It is called "stage fright". In this blog, we will discuss how to overcome the fear of public speaking. Fear of public speaking is not something serious. It happens to all of us. However, it can stop you from giving your 100%. Many people have stage fright due to something unpleasant on stage. But in others, it happens even if they had not been on stage before. The main cause for it might be stress. Stress is not a bad thing. It keeps us on our toes, however, it can also make you underperform. Here are some tips about how to overcome stage fright. 1. Think positively Have positive thoughts. Think about the best that can happen. Be confident. Say "I can do it" because you can.  2. Don't memorize Memorizing will make your speech or dialogue bland. Add expressions. Understand what you are saying. 3. Don't be scared of that silence The thin

The Sequence of Fibonacci Numbers

          The Sequence of Fibonacci Numbers Fibonacci numbers are a unique type of number. Each number is the sum of the previous two numbers. They start with 0 and 1. Let us find more about them. Fibonacci numbers were invented by Leonardo Fibonacci (1170-1250). As I said before, they are the sum of the preceding two numbers. For ex.- 0,1,1,2,3,5,8,13,21,34. Here 1=0+1, 2=1+1, 3= 1+3 and so on. The diagram will give you some idea about Fibonacci Numbers. Fibonacci Numbers in Nature Fibonacci Numbers can be found in nature too. You can see them in a Sunflower, Seashells, Petals of a Flower, Galaxies and even on our faces!                                                                                                                                                                                This is another example of Fibonacci Numbers in Nature                                     Fibonacci Numbers were also used by Leonardo Da Vinci when he drew Mona Lisa!