⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 poissonapp.java

📁 Produce Java classes to calculate and display the Poisson probability when input the value of the av
💻 JAVA
字号:
import java.util.*;
class PoissonApp
{

	//----------------FIELDS--------------
	private static Scanner input =
			new Scanner(System.in);

	//---------------METHODS---------------
	public static void main(String[] args)
	{
		//Input a
		System.out.print("Please input the average arrival rate of customers:");
		int a = input.nextInt(), i;
		long x;
		double poisson_X;

		//When A is greater than five
		if ((a > 5) && (a <= 10))
		{
			System.out.printf("\n==================================");
			System.out.printf("\n|   Number of   " + "|" + "     Poisson    |" + 
							  "\n|   Customers   " + "|" + "   Probability  |" +
							  "\n|      (X)" + "      |" + "\t\t |");
			System.out.printf("\n| --------------+--------------- |");

			for (i = a - 5; i <= a + 5; i++)
			{
				Poisson newPoisson = new Poisson(a,i);
				newPoisson.calcPoisson();
				poisson_X = newPoisson.getPoisson_X();

				System.out.printf("\n|\t" + i + "\t|");
				System.out.printf("   %.6f     |", poisson_X);
			}
			System.out.printf("\n==================================");
		}

		//When A is less than or equal to five
		else if((a>0)&&(a<=5))
		{
			System.out.printf("\n==================================");
			System.out.printf("\n|   Number of   " + "|" + "     Poisson    |" +
							  "\n|   Customers   " + "|" + "   Probability  |" +
							  "\n|      (X)" + "      |" + "\t\t |");
			System.out.printf("\n| --------------+--------------- |");

			for (i = 1; i <= a + 5; i++)
			{
				Poisson newPoisson = new Poisson(a, i);
				newPoisson.calcPoisson();
				poisson_X = newPoisson.getPoisson_X();

				System.out.printf("\n|\t" + i + "\t|");
				System.out.printf("   %.6f     |", poisson_X);
			}
			System.out.printf("\n==================================");
		}

		//When A is the integer out of the range
		else
		{
			System.out.print("\nError! Please check your input!\n");
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -