求帮写一个java程序
来源:学生作业帮 编辑:大师作文网作业帮 分类:综合作业 时间:2024/11/19 06:49:49
求帮写一个java程序
Write a programthat asks a user to provide the starting size of a population or organisms,their average daily increase as a percentage, and the number of days they willmultiply. The program should thendisplay the daily population of the organisms.
Input Validation:
· Do not accept a number less than 10 for thestarting size of the population.
· Do not accept a percentage less than 16% for average daily population increase
· Do not accept a number less than 3 or greaterthan 5 for the number of days they will multiply
package BaiduZhiDao;
import java.util.Scanner;
public class CountPopulation {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int popu = 0;
int rate = 0;
int day = 0;
while(true) {
System.out.println("Enter the starting size of the population");
System.out.println("Starting size of the popultion should be greater than or equal to 10");
popu = scan.nextInt();
if(popu >=10)
{
break;
}
}
while(true) {
System.out.println("Enter the average daily PERCENTAGE increase ");
System.out.println("Average daily increase should be greater than 15");
rate = scan.nextInt();
if(rate>=16)
{
break;
}
}
while(true) {
System.out.println("Enter the number of days the population will multiply");
System.out.println("Number of days should be 3, 4, or 5");
day = scan.nextInt();
if(day=3)
{
break;
}
}
double r = rate*1.0/100 + 1.0;
double p = popu * 1.0;
for(int i=1;i
import java.util.Scanner;
public class CountPopulation {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int popu = 0;
int rate = 0;
int day = 0;
while(true) {
System.out.println("Enter the starting size of the population");
System.out.println("Starting size of the popultion should be greater than or equal to 10");
popu = scan.nextInt();
if(popu >=10)
{
break;
}
}
while(true) {
System.out.println("Enter the average daily PERCENTAGE increase ");
System.out.println("Average daily increase should be greater than 15");
rate = scan.nextInt();
if(rate>=16)
{
break;
}
}
while(true) {
System.out.println("Enter the number of days the population will multiply");
System.out.println("Number of days should be 3, 4, or 5");
day = scan.nextInt();
if(day=3)
{
break;
}
}
double r = rate*1.0/100 + 1.0;
double p = popu * 1.0;
for(int i=1;i