/*
* import three integer ,and then output the average, retain three fraction
*/
package algorithm;
import java.util.*;public class Average {
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
double average = (a + b + c) / 3;
System.out.print(average);
}}
在Java除法中,想要保留几位小数,该怎么办,哪位大哥指点一下
* import three integer ,and then output the average, retain three fraction
*/
package algorithm;
import java.util.*;public class Average {
public static void main(String [] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
double average = (a + b + c) / 3;
System.out.print(average);
}}
在Java除法中,想要保留几位小数,该怎么办,哪位大哥指点一下
System.out.println(df.format(100/3.0));ctrl+c去吧!