| | |
help hw
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 0
I have a homework that only uses loops and selections. I do not know how to do it. Here is the topic:
Write a program that prompts the user to enter the number of students and each student's name, score. Finally, display two students have the highest scores.
Thank you.
Write a program that prompts the user to enter the number of students and each student's name, score. Finally, display two students have the highest scores.
Thank you.
Last edited by linhngoc2100; Apr 4th, 2009 at 5:00 pm.
•
•
Join Date: Apr 2009
Posts: 2
Reputation:
Solved Threads: 0
I know how to find the first highest, but can not find the second.
System.out.println("Enter a name of student: ");
String namea=input.next();
System.out.println("Enter a student score: ");
double scorea = input.nextDouble();
System.out.println("Enter the number of student: ");
int numberstudent=input.nextInt();
for( int i=0;i<= numberstudent-1; i++)
{
System.out.println("Enter the student name: ");
String name1 =input.next();
System.out.println("Enter the student score: ");
double score1=input.nextDouble();
if (score1>scorea)
{ namea=name1;
scorea=score1;
}
System.out.println("Enter a name of student: ");
String namea=input.next();
System.out.println("Enter a student score: ");
double scorea = input.nextDouble();
System.out.println("Enter the number of student: ");
int numberstudent=input.nextInt();
for( int i=0;i<= numberstudent-1; i++)
{
System.out.println("Enter the student name: ");
String name1 =input.next();
System.out.println("Enter the student score: ");
double score1=input.nextDouble();
if (score1>scorea)
{ namea=name1;
scorea=score1;
}
Last edited by linhngoc2100; Apr 4th, 2009 at 5:44 pm.
![]() |
Other Threads in the Java Forum
- Previous Thread: How to detect circle in a directed graph?
- Next Thread: Java Inventory problem
| Thread Tools | Search this Thread |
account android api applet application array arrays automation bidirectional binary birt bluetooth chat class classes client code columns component data database designadrawingapplicationusingjavajslider draw eclipse editor error errors event exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance input integer intellij j2me java javaprojects jlabel jme jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source plazmic print problem program programming project property recursion ria scanner screen search server set size sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree windows





