enters an integer, and then a floating point number (the number with the decimal point).
summation of two Numbers, and output. And then take the square root of theta and theta and print it out.
then converts the output value to a String (you can use the string.valueof ()
function), truncating the first six characters (with decimal points).
input format :
integer x floating-point number y
output format :
integer and the sum of floating point Numbers
and the square root of
and the square root of the first six characters
input sample :
2
3.141592654
output sample :
5.141592654
2.2675080273286796
2.2675
The answer
h3>
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num1 = scanner.nextInt();
double num2 = scanner.nextDouble();
System.out.println(num1 + num2);
System.out.println(Math.sqrt(num1 + num2));
System.out.println(String.valueOf(Math.sqrt(num1 + num2)).substring(0,6));
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int num1 = scanner.nextInt();
double num2 = scanner.nextDouble();
System.out.println(num1 + num2);
System.out.println(Math.sqrt(num1 + num2));
System.out.println(String.valueOf(Math.sqrt(num1 + num2)).substring(0,6));
}
}
div>
Read More:
- How to use scanner to accept char type characters in Java
- Java was started but returned exit code = 13
- Java was started but returned exit code = 13 problem solving
- yaml.scanner.ScannerError: mapping values are not allowed here
- Why namenode can’t be started and its solution
- Error: not found; no service started
- After Nacos started, the client worker log was printed all the time
- No such file or directory error when redis is started under Windows
- Hadoop datanode using JPS to view the solution that can’t be started
- This program cannot be started because the computer is missing COpenGL.dll
- The web application [ROOT] appears to have started a thread named [RxIoScheduler-1 (Evictor)] but ha
- Oracle reports an error and lsnrctl listening cannot be started
- Error occurred when Oracle started controltc. Startservicectrldispatcher failed with err 1063
- The main class could not be found or loaded when springboot started
- Kibana was degraded from 7.0 to 6.8 and started to report an error
- Systemctl command doesn’t exist. How to solve the problem that the service can’t be started
- MAMP failed to start: Apache could’t be started. Please check your MAMP installation and configuration
- [Solved] Appium Android, Appium settings and Unclock method will be installed every time the phone is started
- When vivado2017 is started, the “error when launching” dialog box will pop up vivado.bat : Launcher time out”
- When the docker of win10 subsystem is started, the port is not available