help me..how to print a sum and average of grades using Java?
rhoxart faye
0
Newbie Poster
Recommended Answers
Jump to Posthelp me..how to print a sum and average of grades using Java?
Start a new thread with your question and your code. Don't expect anyone to do your homework.
You should use a for loop
Jump to Posthelp me..
Why it is having an error?
please help me to fix this my assignment..class Example1 { public static void main(String[] args) { double total grade = int Korean(90) + English(85) + Mathematics(78) + Biology(65) + Chemistry(83); average= total/5; { System.out.println("total grade :" …
Jump to PostTry something like this:
import java.util.ArrayList; public class AverageGrade { private ArrayList<Double> grades = new ArrayList<Double>(); public void addGrade(double grade) { grades.add(grade); } public double getTotal() { double sum = 0; for (double grade : grades) sum += grade; return sum; } public double getAverage() { return getTotal() …
All 11 Replies
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
rhoxart faye
0
Newbie Poster
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
ztini
commented:
Why be nasty? You asked to see their code, they showed...you told them to go study.
+0
Nick Evan
commented:
This does not deserve neg-rep
+16
ztini
Nick Evan
commented:
Don't give away complete homework solutions. We're here to help people understand, not to make them pass their class without effort
-3
jon.kiparsky
commented:
Are you having fun doing people's homework for them?
+0
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
ztini
frankel81
0
Newbie Poster
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
peter_budo
commented:
Equalizer
+16
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
javaAddict
900
Nearly a Senior Poster
Team Colleague
Featured Poster
ztini
commented:
This does not contribute constructively to the thread.
+0
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.