本文整理汇总了C#中Scanner.nextDouble方法的典型用法代码示例。如果您正苦于以下问题:C# Scanner.nextDouble方法的具体用法?C# Scanner.nextDouble怎么用?C# Scanner.nextDouble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scanner
的用法示例。
在下文中一共展示了Scanner.nextDouble方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(String[] args)
{
Options options = new Options();
if (!options.parse(args)) {
//return;
}
Scanner scanner = new Scanner();
// Take all the parameters from the input
double a, b;
int N;
int fx;
int _realN;
// ------ lower limit input -----
Console.Write("Ingrese a: ");
if (options.isASet) {
a = options.a;
Console.WriteLine(a);
} else {
a = scanner.nextDouble();
}
// ------ upper limit input -----
Console.Write("Ingrese b: ");
if (options.isBSet) {
b = options.b;
Console.WriteLine(b);
} else {
b = scanner.nextDouble();
}
// ------ number of partitions input -----
Console.Write("Ingrese N: ");
if (options.isNumPartitionsSet) {
N = options.numPartitions;
Console.WriteLine(N);
} else {
N = scanner.nextInt();
}
_realN = 3 * N;
Console.WriteLine("Seleccione la funcion a integrar (1 - {0}):", functions.Length);
for (int i = 0; i < functions.Length; i++) {
Console.WriteLine(" opcion #{0}: {1}", i, functions[i].GetName());
}
// ------ function index input ------
if (options.isFxSet) {
Console.Write(" ingrese la opcion: ");
fx = options.fx;
Console.WriteLine(fx);
} else {
do {
Console.Write(" ingrese la opcion: ");
fx = scanner.nextInt();
} while (fx < 0 || fx >= functions.Length);
}
Console.WriteLine();
// ----- begin to calculate the final results -----
double h = (b - a) / _realN;
Console.WriteLine("Resultado Integracion:");
Console.WriteLine("==========================");
Console.WriteLine();
Console.WriteLine("Funcion a integrar : {0}", functions[fx].GetName());
Console.WriteLine("Numero de particiones : 3 * (N={0}) = {1}", N, _realN);
Console.WriteLine("Limite inferior : {0}", a);
Console.WriteLine("Limite superior : {0}", b);
Console.WriteLine("Paso (h = (b-a)/N) : {0}", h);
// ----- solve and print the final result -----------
MainSolver solver = new MainSolver(a, b, h, _realN, functions[fx]);
double result = solver.ExecuteThreads();
Console.WriteLine("Resultado de integracion: {0}", result);
}