This article describes the simple input calculation function of Java based on Scanner objects. Share it for your reference, as follows:
Questions and codes:
/**Copyright (c)2015, Southwest University School of Planning and Information Technology*All rights reserved.*File name: Computearea.java*Author: Gaoshuo*Completion date: October 14, 2015*version number: v1.0*Problem description: Enter the radius to find area. *Program input: Radius. *Program output: area. */package practice_01;import java.util.Scanner;//Scanner is the java.util packagepublic class Computearea { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("Wulin.com test result:"); //create a new Scanner object Scanner input=new Scanner(System.in); //enter the radius System.out.println("please input the radius"); double radius=input.nextDouble(); double area=radius*radius*3.14; System.out.println("the raisus is"+ radius +"the area is "+area); }}Running results:
Summary of knowledge points:
Create a Scanner object for input. and nextInt() nextDouble() reads into different types.
Experience:
It's very troublesome to input Java. Read the Scanner package first and then create the object. Also pay attention to the spaces when println output.
PS: Here are a few calculation tools for you to refer to:
Online unary function (eq) solution calculation tool:
http://tools.VeVB.COM/jisuanqi/equ_jisuanqi
Scientific Calculator Online Use_Advanced Calculator Online Calculator:
http://tools.VeVB.COM/jisuanqi/jsqkeexue
Online Calculator_Standard Calculator:
http://tools.VeVB.COM/jisuanqi/jsq
For more information about Java algorithms, readers who are interested in this site can view the topics: "Java Data Structure and Algorithm Tutorial", "Summary of Java Operation DOM Node Tips", "Summary of Java File and Directory Operation Tips" and "Summary of Java Cache Operation Tips"
I hope this article will be helpful to everyone's Java programming.