I understood. So, that exercise is wrong: the type of variables isn't correctly used. Thank you, so much.
On 17 ene, 04:58, Steffani Trinitra Setyasari <[email protected]> wrote: > Maybe I can help you to explain what happened.... > The type of variables "mathGrade", "historyGrade" and "scienceGrade" is > integer. The divider of "average" is "3" that its type is integer,too. Both > the numerator and denominator are integer so the result will be integer too. > Although the result of "average " is 73.66.., it will be rounded off to 73. > But because the type of "average" is "double" so the result is 73.0 > > If you want to get the exact result of "average" maybe you can change the > divider "3" to "3.0" or change the type of "mathGrade", > "historyGrade","scienceGrade" to double. > > Cheers! > > --- On Sat, 17/1/09, Adrián E. Córdoba <[email protected]> wrote: > > From: Adrián E. Córdoba <[email protected]> > Subject: [java programming] Wrong average in LAB-1034 > To: "Free Java Programming Online Training Course By Sang Shin" > <[email protected]> > Date: Saturday, 17 January, 2009, 2:38 AM > > I think something is wrong in LAB-1034, Exercise 1 if/else control > structure, "(1.1) Build and run a Java program that uses if/else > control structure". > If you follow the directives in that LAB, and build an run > MyGradesProject and enter the math, history, and science grades (78, > 56 and 87 respectively) like the figures show, the program compute and > display that the average is "73.0" as Figure-1.15 shows. > But, if you compute the same average: > > (78+56+87) / 3 > > in a calculator (like Windows Calculator), the average is "73.66..". > What's wrong? > > Thank you in advance. > > Importing contacts has never been easier. Bring your friends over to > Yahoo! Mail today!http://www.trueswitch.com/yahoo-sg --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaprogrammingwithpassion?hl=en -~----------~----~----~----~------~----~------~--~---
