上传了实验五,已确认无敏感信息
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"java.project.sourcePaths": ["src"],
|
||||||
|
"java.project.outputPath": "bin",
|
||||||
|
"java.project.referencedLibraries": [
|
||||||
|
"lib/**/*.jar"
|
||||||
|
]
|
||||||
|
}
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
## Getting Started
|
||||||
|
|
||||||
|
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||||
|
|
||||||
|
## Folder Structure
|
||||||
|
|
||||||
|
The workspace contains two folders by default, where:
|
||||||
|
|
||||||
|
- `src`: the folder to maintain sources
|
||||||
|
- `lib`: the folder to maintain dependencies
|
||||||
|
|
||||||
|
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||||
|
|
||||||
|
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||||
|
|
||||||
|
## Dependency Management
|
||||||
|
|
||||||
|
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
||||||
Executable
+25
@@ -0,0 +1,25 @@
|
|||||||
|
//Main.java
|
||||||
|
package task1;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Scanner;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
SimpleDateFormat in = new SimpleDateFormat("yyyy M dd");
|
||||||
|
Date d = new Date();
|
||||||
|
try {
|
||||||
|
d = in.parse(input.nextLine());
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
SimpleDateFormat out = new SimpleDateFormat("yyyy MMMM dd EEEE", Locale.ENGLISH);
|
||||||
|
String formattedDate = out.format(d);
|
||||||
|
System.out.println("今天是" + out.format(d).toUpperCase());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+27
@@ -0,0 +1,27 @@
|
|||||||
|
//Main.java
|
||||||
|
package task2;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner input = new Scanner(System.in);
|
||||||
|
Date inDate = new Date();
|
||||||
|
SimpleDateFormat inFormat = new SimpleDateFormat("yyyy年M月d日", Locale.CHINA);
|
||||||
|
System.out.print("请输入您家孩子的出生日期(格式为yyyy年M月d日):");
|
||||||
|
try {
|
||||||
|
inDate = inFormat.parse(input.nextLine());
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
long inTimeStamp = inDate.getTime();
|
||||||
|
long outTimeStamp = inTimeStamp + (long) 100 * 24 * 60 * 60 * 1000;
|
||||||
|
Date outDate = new Date(outTimeStamp);
|
||||||
|
SimpleDateFormat outFormat = new SimpleDateFormat("yyyy年M月dd日 EEEE", Locale.CHINA);
|
||||||
|
System.out.println("经计算,您家孩子的百日宴应该设在" + outFormat.format(outDate));
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package task3;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class StringLearning {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
String stringExample = scanner.next();
|
||||||
|
String endStr = " end";
|
||||||
|
// ---------------------Begin------------------------
|
||||||
|
System.out.println(stringExample);// 1.输出原字符串
|
||||||
|
System.out.println(stringExample.length());// 2.求出字符串长度
|
||||||
|
// 3.字符串转换成相应的大/小写
|
||||||
|
System.out.println(stringExample.toUpperCase());
|
||||||
|
System.out.println(stringExample.toLowerCase());
|
||||||
|
// 4.截取指定位置的字符串(3-7)
|
||||||
|
System.out.println(stringExample.substring(3, 7));
|
||||||
|
// 5.字符串相加具体输出要求请看测试说明。
|
||||||
|
System.out.println(stringExample + endStr);
|
||||||
|
// ---------------------End------------------------
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+15
@@ -0,0 +1,15 @@
|
|||||||
|
//Main.java
|
||||||
|
package task4;
|
||||||
|
|
||||||
|
import java.lang.Math;
|
||||||
|
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
double value1 = 2, value2 = 0;
|
||||||
|
System.out.println("绝对值:\t" + Math.abs(value1));
|
||||||
|
System.out.println("3次幂:\t" + Math.pow(value1, 3));
|
||||||
|
System.out.println("二次方根:\t" + Math.pow(value1, 0.5));
|
||||||
|
System.out.println("sin值:\t" + Math.sin(value1));
|
||||||
|
System.out.println("较大者:\t" + Math.max(value1, value2));
|
||||||
|
}
|
||||||
|
}
|
||||||
Executable
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package task5;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class Roster {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Scanner scanner = new Scanner(System.in);
|
||||||
|
/********** Begin *********/
|
||||||
|
String roster1 = "张三,李四,王五";
|
||||||
|
String roster2 = scanner.nextLine();
|
||||||
|
if (roster1.equals(roster2)) {
|
||||||
|
System.out.println("相同");
|
||||||
|
} else {
|
||||||
|
System.out.println("不同");
|
||||||
|
}
|
||||||
|
/********** End *********/
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user