0
해수면을 2100 년까지 계산하는 프로그램을 개발하려고합니다. 연구 결과에 따르면 해수면은 2.5 피트 (30 인치) - 6.5 피트 (78 인치). 내 프로그램은 사용자에게 해수면이 몇 센티미터 올라 갔는지 계산할 것을 요청하지만, 정보가 연간 3488과 .9069 인치 사이의 임의의 숫자가되기를 원한다. 해발 2.5 피트 및 6.5 피트. 그래서 내 질문은 해수면이 얼마나 상승했는지 갤런 수로 출력 할 수 있도록 사용자가 입력 한 해마다 난수를 생성 할 수있는 방법입니다.해수면 Java 프로젝트
/takes the input from the user of all the way up to which year
/they want to know the number of inches/ gallons the sea level has risen
/using reiman summs and a chart
/
/
/*******************************************************************************/
import java.util.Random;
import java.util.Scanner;
public class CalcProject
{
public static void main(String[] args)
{
//variables for the program
int year;
int numOfYears;
double leastRise = .3488; //y = .3488x , x is the inches of rainfall
double highRise = .9069; //y= .9069x , x is the inches of rainfall
double seaLevel1;
double seaLevel2;
//Describing what the program does to the user
System.out.println("This program caluclates the number of gallons/inches" +
"the sea level will rise based on your input." + "\n");
//Asking for the users year they want to calculate
System.out.println("Please enter which year you wish to know how much the water level will have risen since 2014");
Scanner scan = new Scanner(System.in);
year = scan.nextInt();
if(year <= 2014 || year > 2100)
{
do
{
System.out.println("Please enter a valid year between 2015 and 2100");
year = scan.nextInt();
} while((year <= 2014 || year > 2100));
}
//puts the year into a number of years from 2014
numOfYears = year-2014;
System.out.println("The number of years between now and the year you chose is: " + numOfYears);
//uses the least inches of sealevel
seaLevel1 = numOfYears * leastRise;
System.out.println("The total sealevel in inches is " + seaLevel1 + " for " + year);
//uses the most inches of seaLevel
seaLevel2 = numOfYears * highRise;
System.out.println("The total sealevel in inches is " + seaLevel2 + " for " + year);
//calculating radnom numbers for each year
와우 감사합니다. 이것은 부차적 인 질문이며 당신이 이것을 할 수 있는지 확실하지 않지만이 프로그램에서 미적분을 포함 할 수있는 어떤 방법이 있습니까? 곡선 아래의 영역 또는 어떤 유형의 시퀀스? – gainz
@jay가 있어야합니다. 수학 라이브러리를 확인하십시오. 이것은 매우 모호한 질문입니다. 그래서 당신이하고 싶은 일에 대해 더 구체적으로 생각한다면 우리는 아마도 당신을 더 도울 것입니다. –