In: Computer Science
Create JAVA PROGRAM, and write comment for codes also.
2) Every extra 3500 calories means gaining a pound. Falling short by 3500 means losing a pound. Get the base amount of calories the person needs in a day (BMR). Then have the user enter in calorie totals for each day and display their weight every week. They might eat more than once in a day.
import java.util.*;
class BMI
{
public static void main(String args[])
{
int calories[] = new int[10];
int basic_calories;
Scanner sc = new
Scanner(System.in);
System.out.println("enter minimum
calories required per day:");
basic_calories =
sc.nextInt();
int sum = 0;
for(int i = 0;i <7;i++)
{
System.out.println("enter the calories per day:\t");
calories[i] =
sc.nextInt();
sum +=
calories[i];
}
int gain = 0, loss = 0;
if(sum > 3500)
{
gain = gain +
(int)(sum/3500);
System.out.println("The weight gain is "+ gain +"pounds\n");
}
else
{
loss = loss +
(int)(3500/sum);
System.out.println("The weight loss is "+ loss +"pounds\n");
}
}
}
If you have any doubts please comment and please don't dislike.