دنبال کننده ها

۱۳۹۶ مهر ۱۰, دوشنبه

java - When I run my program it doesn't use the for loop i set up to output the number changed

[ad_1]



 import java.io.*;
import java.util.*;

public class Unit2Lab3

public static void main(String [] arg)

Scanner input = new Scanner(System.in);

System.out.println("What is the initial level of organisms");
int org = input.nextInt();
System.out.println("What is the growth rate");
int gro = input.nextInt();
System.out.println("What is the time(hours) needed to achieve the growth rate");
int need = input.nextInt();
System.out.println("What is the observation time");
int obs = input.nextInt();

for(int i=org;i<obs/need;i++)

i = org*gro;


System.out.println("After 24 hours there will be " + org + " organisms");




It will output the amount of organisms the user put in rather than changing to the number changed by the for loop. Ex. If I type in 500,2,6,24 it will output 500 rather than 8000




[ad_2]

لینک منبع