Java simple calculator
This is how to create a simple calculator using java.
Link to download JDK
http://allinone-nsr.blogspot.com/p/jdk.html
The code:
import java.util.Scanner; //imports scanner to get user input
class cal{ //this is the class file name and it should match the file name that we given to save the file
public static void main(String[] args){ //this is the main method
int total=0; //declare a variable for get total
System.out.println("Enter Number 1:-"); //display this
Scanner a = new Scanner(System.in); //create a new user input and name it a
int num1=a.nextInt(); //declare a variable name num1 and get the value of user input
System.out.println("Enter Number 2:-"); //display this
Scanner b = new Scanner(System.in); //create a new user input and name it b
int num2=b.nextInt(); //declare a variable name num2 and get the value of user input
System.out.println("Enter Mark:-"); //display this
Scanner c = new Scanner(System.in); //create a new user input and name it c
String choise=b.next(); //declare a variable name choise and get the value of user input
switch (choise){ //checks the inputs of choise variable
case ("+"): //if input equals +
total=num1+num2; //pass the addition of num1 and num2 into variable total
break; //finish the statement
case "-": //if input equals -
total=num1-num2; //pass the sub of num1 and num2 into variable total
break; //finish the statement
case "/": //if input equals /
total=num1/num2; //pass the division of num1 and num2 into variable total
break; //finish the statement
case "x": //if input equals x
total=num1*num2; //pass the multipication of num1 and num2 into variable total
break; //finish the statement
default: //if input equals anything else
System.out.println("Choose +,-,x,/"); //display this
break; //finish the statement
}
System.out.println("Total = "+total); //display Total = and value of total variable } }
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Java simple calculator», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.