当前位置: 首页>>代码示例>>Java>>正文


Java Scanner.hasNextDouble方法代码示例

本文整理汇总了Java中java.util.Scanner.hasNextDouble方法的典型用法代码示例。如果您正苦于以下问题:Java Scanner.hasNextDouble方法的具体用法?Java Scanner.hasNextDouble怎么用?Java Scanner.hasNextDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Scanner的用法示例。


在下文中一共展示了Scanner.hasNextDouble方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printAverage

import java.util.Scanner; //导入方法依赖的package包/类
public static void printAverage(Scanner sf, int N) {
  DelayLine<Double> temp = new DelayLine<Double>(N, 0.0);
  out.printf("Temperaturas hora-a-hora e média das últimas %d horas.\n", N);
  out.printf("(As primeiras %d médias não são exatas!)\n", N);
  out.printf("%3s %4s %7s %7s\n", "dia", "hora", "temp.", "média");
  int t = 0;
  while (sf.hasNextDouble()) {
    double nova = sf.nextDouble();
    // Calcula soma das últimas N horas:
    temp.in(nova);
    double somaN = 0.0;
    for (int hora = -N; hora < 0; hora++) {
      somaN += temp.get(hora);
    }
    out.printf("%3d   %02d %7.1f %7.1f\n", t/24, t%24, nova, somaN/N);
    t++;
  }
}
 
开发者ID:ZePaiva,项目名称:Prog2,代码行数:19,代码来源:P103.java

示例2: printAverage

import java.util.Scanner; //导入方法依赖的package包/类
public static void printAverage(Scanner sf, int N) {
  DelayArray<Double> temp = new DelayArray<Double>(N, 0.0);
  out.printf("Temperaturas hora-a-hora e média das últimas %d horas.\n", N);
  out.printf("(As primeiras %d médias não são exatas!)\n", N);
  out.printf("%3s %4s %7s %7s\n", "dia", "hora", "temp.", "média");
  int t = 0;
  while (sf.hasNextDouble()) {
    double nova = sf.nextDouble();
    // Calcula soma das últimas N horas:
    temp.in(nova);
    double somaN = 0.0;
    for (int hora = -N; hora < 0; hora++) {
      somaN += temp.get(hora);
    }
    out.printf("%3d   %02d %7.1f %7.1f\n", t/24, t%24, nova, somaN/N);
    t++;
  }
}
 
开发者ID:ZePaiva,项目名称:Prog2,代码行数:19,代码来源:E1003.java

示例3: scannerDemo2

import java.util.Scanner; //导入方法依赖的package包/类
public static void scannerDemo2() {
	Scanner scan = new Scanner(System.in);

	double sum = 0;
	int m = 0;
	System.out.println("输入数字求平均,输入非数字结束!");
	while (scan.hasNextDouble()) {
		double x = scan.nextDouble();
		m = m + 1;
		sum = sum + x;
	}

	System.out.println(m + "个数的和为" + sum);
	System.out.println(m + "个数的平均值是" + (sum / m));
}
 
开发者ID:leon66666,项目名称:JavaCommon,代码行数:16,代码来源:ScannerDemo.java

示例4: main

import java.util.Scanner; //导入方法依赖的package包/类
public static void main(String[] args) {
    int i = 0, t = 0;
    double a[] = new double[999999];
    Scanner x = new Scanner(System.in);
    a[i++] = Math.sqrt(x.nextDouble());
    t++;
    while (x.hasNextDouble()) {
        double d = x.nextDouble();
        a[i++] = Math.sqrt(d);
        t++;
    }
    for (int j = t - 1; j >= 0; j--) {
        System.out.printf("%.4f\n", a[j]);
    }
}
 
开发者ID:bakhodirsbox,项目名称:AlgoCS,代码行数:16,代码来源:ReverseRoot_1001.java

示例5: isDouble

import java.util.Scanner; //导入方法依赖的package包/类
private static boolean isDouble(String string) {
    Scanner scanner = new Scanner(string);
    boolean b = scanner.hasNextDouble();
    scanner.close();

    return b;
}
 
开发者ID:protViz,项目名称:deisotoper,代码行数:8,代码来源:ReadMGF.java


注:本文中的java.util.Scanner.hasNextDouble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。