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 To Use Yoast SEO In Blogger | Best SEO Method

  How to use Yoast SEO Plugin for Blogger to increase SEO. SEO is crucial if you want to rank on google. So before we get to know how to use the Yoast SEO plugin for Blogger, we need to know about SEO. Yoast SEO improves Ranking What is SEO? SEO, also known as Search engine optimization is the process of improving website quality to rank on google.  People get two types of traffic- 1. Paid traffic 2. Unpaid traffic, also known as organic traffic   There are other types of traffic too like direct and referral traffic .   Most of your traffic will be organic traffic. It is simply not worth it to put on Ads.  Another reason is that ads are expensive.  So how do we get organic traffic? Short answer- SEO Some methods to increase SEO- 1. Focusing on keywords Keywords are the words that describe the article. For example, the main keyword of the article that you are reading is SEO. However, it is difficult to rank on such keywords. So I use lon...

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!                                                                                                   ...

Three Pandemics in the Past and How They Ended

Contents [ hide ] How the Pandemics in the Past ended Pandemics have been troubling humanity for centuries. Overview Pandemics have been troubling humanity for centuries.  Though Covid-19 has caused loss of lives worldwide, it is not the deadliest Pandemic. In fact, its cousins, SARS and MERS are much more deadly.  History has seen even more ready diseases such are The Black Death and the infamous Spanish Flu pandemic. So I have prepared a list of how the pandemics in the past ended. Pandemics and Epidemics are also common now. What is Herd Immunity? Most pandemics end through a process called herd immunity. It is a process through which majority of pandemics end 1. The Black Death-Imposition of Quarantine Black Death, also known as Bubonic Plague was a pandemic caused by the bacterium Yersinia Pestis . It was a devastating Pandemic that started when 12 ships from the Black Sea docked at the port on Messina. When the people arrived, they saw a terrifying sight. Many sa...