@State var value1 = 25.8711
@State var value2 = 30.6234
@State var value3 = 90.2534
@State var value4 = 87.3232
@State var value5 = 87.2334
var body: some View
{
let finalGrade = (value1 + value2 + value3 + value4 + value5) / 5
Section(header: Text("Average Grade")){
Text("\(finalGrade)")
.foregroundColor(.blue)
}
}
.navigationTitle("Grade Calculator")
}
In this block of code how would I get so that finalGrade variable is rounded off into two decimals, and outputs ie: 92.80 versus 92.801232 in the Text() box. The variables 'value' obviously do not calculate to that number but that is just an example.