Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please anyone I need help with my homework. I'm so desperate.

 
mimi ventimiglia
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It will mean so much to me if any of you guys can help me. I'm so stupid at this.I learn real quick when I look at them. i don't want to waste any of you guys time by explaining it to me. The fact that anyone can do this is amazing. Here it is:



1.)Write a program that asks the user for 5 test scores in a loop and keeps track of their sum. You should NOT store all of the individual test scores. (do not make 5 variables)

Sample:
Enter a test:99
Enter a test:100
Enter a test:101
Enter a test:50
Enter a test:55
The total is 405

2.) Modify the program so that it prints the average instead of the sum.

Sample:
Enter a test:99
Enter a test:100
Enter a test:101
Enter a test:50
Enter a test:50
The Your average is 80.0

3.) Modify the program so that it asks for 10 test scores, then 15 test scores. Can you make this any number?

4.) Modify the program so that in the beginning of the program it asks the user "How many tests did you take" and then will ask the user for THAT many test scores.

Sample:
Enter a test:99
Enter a test:98
Enter a test:98
Your test average is 98.3333333333333.


Sample:
How many tests did you take? 6
Enter a test:80
Enter a test:80
Enter a test:80
Enter a test:80
Enter a test:81
Enter a test:81
Your test average is 80.5
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Do Your Own Homework. We will guide you where needed but we will not give you full solutions.

I'll give you a few hints:
- solution 2 is basically solution 1 with a divide operation added (average == sum / count). Take care though that integer division may not result in what you expect. You may need to cast some values to float or double.

- use a loop; for is probably the easiest

- if you are allowed to, check out java.util.Scanner for reading the values. Otherwise you will need to use System.in combined with Integer.parseInt. You can make life a bit easier by wrapping System.in in an InputStreamReader in a BufferedReader.
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12097
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by mimi ventimiglia:
i don't want to waste any of you guys time by explaining it to me.
But that is exactly what we DO here, is explain things. If all you want is someone to write it for you, you can post in Jobs Offered or try some of the rent-a-coder sites.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic