Whole numbers are great, but I think we should also pay attention to decimal numbers, too.
So, how about we make a program that involves a lot of decimals?
Instructions:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
float sum = 0;
float n;
do {
System.out.print("Next float: ");
n = in.nextFloat();
sum += n;
} while (sum < 100 && n >= 0);
}
}
Comments
Leave a comment