Skip to content

Instantly share code, notes, and snippets.

@bijay-shrestha
Created May 28, 2021 09:38
Show Gist options
  • Save bijay-shrestha/ef514d18b227778629c37cab11fb00ac to your computer and use it in GitHub Desktop.
Save bijay-shrestha/ef514d18b227778629c37cab11fb00ac to your computer and use it in GitHub Desktop.
/**
* Calculate an array of 5 floats and calculate their sum.
*/
package com.hawa.practice;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class PracticeSetOne {
public static void main(String[] args) {
float sum = 0f;
float[] floatNumbers = {1.0f, 2.14f, 3.15f, 4.0f, 5.12f};
for (float num : floatNumbers) {
sum += num;
}
log.info("The sum of float numbers in a array {} is {}", floatNumbers, sum);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment