473,473 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

java

1 New Member
Thisn is my HW
Write a program that prompts the user to enter five scores and then prints the average test score... Can someone help start this programming. I'm new with java
Nov 9 '06 #1
3 1118
sicarie
4,677 Recognized Expert Moderator Specialist
Thisn is my HW
Write a program that prompts the user to enter five scores and then prints the average test score... Can someone help start this programming. I'm new with java
You know that you're only going to be getting 5 scores, so I would use a for loop to iterate over your variables and inputs.

here's a link on reading data in:
http://www.cs.wisc.edu/~cs302/io/JavaIO.html

and here's one on loops:
http://mindprod.com/jgloss/forloop.html

If you have any more questions, post whatever code you have, and whatever error messages you get, and we'll do what we can to help.
Nov 9 '06 #2
roshancaptain1
14 New Member
Use a scanner:
import java.util.Scanner;
class prompt2 {
public static void main(String[] args)
throws java.io.IOException {
Scanner scan = new Scanner(System.in);
int p[] = new int[4];
int avg[]=0;
for ( int i = 0; i < 6; i++) {
System.out.print("Enter the values " + i + " :");
p[i] = scan.nextInt() ;
avg1[]=avg+p[i];
System.out.println();
}
int avg[];
avg=avg1/5;
System.out.println("the average: " +avg);
}
}
Nov 11 '06 #3
r035198x
13,262 MVP
Use a scanner:
import java.util.Scanner;
class prompt2 {
public static void main(String[] args)
throws java.io.IOException {
Scanner scan = new Scanner(System.in);
int p[] = new int[4];
int avg[]=0;
for ( int i = 0; i < 6; i++) {
System.out.print("Enter the values " + i + " :");
p[i] = scan.nextInt() ;
avg1[]=avg+p[i];
System.out.println();
}
int avg[];
avg=avg1/5;
System.out.println("the average: " +avg);
}
}
We prefer to let people attempt their problems first before dumping solutions on them. Now your code doesn't even compile. If you want to help people just check to see that your suggestions are correct first before posting them.
Nov 12 '06 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
1
by: ptaz | last post by:
Hi I'm trying to run a web page but I get the following error. Ca anyone please tell me a solution to this. Thanks Ptaz HTTP Status 500 - type Exception report
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
0
by: mailkhurana | last post by:
Hii , I am trying to use a type 2 driver to connect to DB2 0n AIX 5 I have a small java test to class to establish a conneciton with the db .. I am NOT using WAS or any appserver When I try to...
1
by: David Van D | last post by:
Hi there, A few weeks until I begin my journey towards a degree in Computer Science at Canterbury University in New Zealand, Anyway the course tutors are going to be teaching us JAVA wth bluej...
12
by: Mark Fink | last post by:
I wrote a Jython class that inherits from a Java class and (thats the plan) overrides one method. Everything should stay the same. If I run this nothing happens whereas if I run the Java class it...
0
by: jaywak | last post by:
Just tried running some code on Linux (2.4.21-32.0.1.EL and Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_04-b05)) and Windows XPSP2 (with Java HotSpot(TM) Client VM (build...
1
by: jaimemartin | last post by:
hello, I want to validate an xml by means of a schema (xsd). To do that first of all I´m using a SchemaFactory. The problem is that if I run the code in Windows all works fine, but If I run it in...
0
oll3i
by: oll3i | last post by:
package library.common; import java.sql.ResultSet; public interface LibraryInterface { public ResultSet getBookByAuthor(String author); public ResultSet getBookByName(String name);
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.