catalogue
1, Download of java development tools and configuration of its environment
3, Code conversion is mentioned
4, Appendix (some quick input of IDEA)
preface
- How do programs help humans improve productivity? What does the program world consist of? If you want to be like a duck to water in JAVA, you must first understand the basic syntax of JAVA programs.
- I have studied Java for one year. This paper will write an article on how to realize salary conversion in java with the most basic syntax and easy to understand way.
- This article summarizes my problems in learning and downloading, hoping to help novice Xiaobai!
Current tasks
Realize salary conversion in Java
The user inputs the monthly salary and calculates the daily salary (22 working days per month) and annual salary (13 salary per year)
1, Download of java development tools and configuration of its environment
1.jdk configuration
Note: if you install the eclipse development tool, you must configure the JDK first, otherwise it will not open
about JDK I have packaged the download and its configuration as follows: Link: https://pan.baidu.com/s/1tOuN1NJUK83dzviuI9pfzA Extraction code: myql
2. Download of java development tools
The development tools I have used include eclipse and IDEA. Compared with IDEA, the function of IDEA is better and more perfect, and many plug-ins can be installed. Now the company basically uses IDEA for development.
Therefore, following the trend, it is recommended to download IDEA (sorry: due to limited time, please refer to the attached link)
1. about eclipse The installation package has been sorted as follows: Link: https://pan.baidu.com/s/1hKgt1XVMGQ9OGz6R31trJA extraction code: s3ch
Because Baidu network disk takes too much trouble
jdk installation and environment configuration and eclips e installation and configuration tutorial are attached: eclipse installation tutorial - the most detailed installation of java_ A Scorpio procedural ape - CSDN blog_ eclipse installation tutorial
2.IDEA Download of Link: https://pan.baidu.com/s/1WFa5d5zdAh3uI-jFmLoAcQ Extraction code: ojkq
Attach IDEA official website: Download IntelliJ IDEA: The Capable & Ergonomic Java IDE by JetBrains
3.about IDEA Download FAQ summary
-
Solutions to problems that cannot be opened on the official IDEA website:
Maybe Hosts The problem may also be dns Question:
See this link for details: The IDEA official website cannot be accessed. Solution_ Cat ♟ Blog - CSDN blog
-
How to modify DNS to solve the problem:
See this link: How to change dns - FAQ - PHP Chinese network
-
IDEA commercial edition has a trial period but does not want to buy a solution:
download IDE Eval Resetter The function of the plug-in is to reset the trial time and let you try unlimited Link: https://pan.baidu.com/s/1-7O7p7c2kWaZ-bKu9bkcFA Extraction code: gvkv
To install the plug-in, see the link: IDE Eval Resetter: JetBrains family bucket unlimited trial plug-in - Lao Wang blog
-
Activation method of IDEA commercial edition:
In the face of students and teachers in school, you can register and activate through the education mailbox
For activation method, see: idea commercial version activation code acquisition process (for students only), education email is required_ u014044032 blog - CSDN blog_ idea education email activation
-
jdk configuration in IDEA:
See this blog: Four ways of configuring jdk in IntelliJ IDEA_ Shang Moyi's blog - CSDN blog_ Idea configuring jdk
2, Java knowledge involved
1. Declaration and use of variables in Java
-
In a program, each variable must be declared before being used.
-
Variables can be defined at any time in Java language programs, which does not need to be concentrated before executing statements.
-
In addition to types, variables in the Java language also have modifiers to limit their use. Modifiers include public, protected, private and static. The general form of variable declaration is as follows: < modifier list > < variable type > < variable name list >; For example: static int b=1; The variable name must be a legal identifier. Variables can be initialized when declared. Mu lt iple variables of the same type are declared at a time, separated by commas.
-
A variable in a method must be assigned a value before use.
2. Usage of Scanner class in Java
-
The data entered by the keyboard, whether text or numbers, is regarded as a string in Java. Therefore, if you want to enter numbers by the keyboard, it must be converted again
-
In order to simplify the input operation, a new class named Scanner for input operation has been added to the java.util class library since Java SE 5. You can use this class to input an object
-
Use the Scanner class to input from the console and create its object to read the input from System.in: Scanner input = new Scanner(System.in); (the Scanner class is in the package java.util and needs to be imported in the first line) the object can call the nextDouble() method to obtain a double value, double d = input.nextDouble();
For more details, see: https://www.runoob.com/java/java-scanner-class.html
3.Java formatted output
-
System.out.printf(): java SE5 has introduced the C language printf() style formatted output function.
-
System.out.format(): the format() method introduced by Java SE5 imitates the printf() method of C and can be used for PrintStream or PrintWriter objects, including System.out objects. The usage is basically similar to System.out.printf().
-
Fomatter class: all formatting functions in Java are handled by the java.util.Formatter class. When you create a Formatter object, you need to pass some information to its constructor to tell it where the final result will be output.
-
String.format(): String.format() is a static method that receives the same parameters as Formatter.format(). Its return value is a string object, which is suitable for one-time output.
For more details, see: https://blog.csdn.net/qq_44111805/article/details/112850550
4. Main functions and usage of Java decimalformat
-
Keep a few decimal places and comply with the principle of rounding
-
Provides several ways to retain decimal places
1. use java.math.BigDecimal 2. use java.text.DecimalFormat 3. use java.text.NumberFormat 4. use java.util.Formatter 5. use String.format
For more details, see: https://blog.csdn.net/qq_36850813/article/details/80358075
3, Code conversion is mentioned
The idea is as follows:
-
Print out monthly salary first;
-
Enter monthly salary on the keyboard (realized by Scanner method);
-
Define monthly salary (the number you type) as mouthSalary;
-
Define annual salary and daily salary and perform salary conversion: daily salary = monthly salary / 22; Annual salary = monthly salary * 13;
-
Print the output result (through String.format, two decimal places are reserved).
Specific code:
import java.util.Scanner; // Introduce Scanner class public class Salary conversion { public static void main(String[] args) { // Enter title System.out.println("***Salary conversion tool v1.0***"); // Enter monthly salary System.out.print("Please enter monthly salary (RMB): "); Scanner sc = new Scanner(System.in); // Receive data from keyboard // Salary conversion: daily salary = monthly salary / 22; Annual salary = monthly salary * 13 double mouthSalary=sc.nextDouble(); // Define monthly salary (the number you type) as moushsalary double daySalary = mouthSalary/22; double yearSalary = mouthSalary*13; // Print the output result (two decimal places are reserved through String.format) System.out.println(String.format("Your daily salary: ¥%,.2f", daySalary)); // 1 System.out.print(String.format("Your annual salary: ¥%,.2f", yearSalary)); // 2 /*Replace daySalary at 1 with mouthSalary/22 2 Replace yearSalary at with mouthSalary*13 Code optimization eg: System.out.println(String.format("Your daily salary: ¥%,. 2F ", mouthsalary / 22); // one System.out.print(String.format("Your annual salary: ¥%,. 2F ", mouthsalary * 13); */ } }
design sketch:
There are many codes to realize this task. Here is the most basic method!
4, Appendix (some quick input of IDEA)
1. Fast writing of main method
input psvm You can import public static void main(String[] args) {} input sout You can import System.out.println();
2. Most commonly used shortcut keys
Alt+Enter Universal shortcut key for introducing error packages Ctrl+ Mouse left Quick transfer definition More short prompt completion statements Ctrl + J -------------Shortcut key view
3. See the following blog for other shortcut keys
https://www.cnblogs.com/weibanggang/p/9426989.html https://blog.csdn.net/weixin_42474930/article/details/81329776
5, Summary
Combined with myself, this paper summarizes the problems that novice Xiaobai may encounter. Thank you for your love and support, as well as the author of the blog I quoted!!!