score computation

Ads

 
 

Share on Google+Share on Google+

sassy
score computation
1 Answer(s)      9 years ago
Posted in : Java Beginners
Ads
View Answers

September 9, 2008 at 12:03 PM


Hi friend,

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
public class ReadLine {

public static void main(String[] args) throws Exception {
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader bufReader = new BufferedReader(isr);
System.out.println("Enter the number Student less then or equal to 50");
int studentNo = Integer.parseInt(bufReader.readLine());
Map map = new HashMap();
int score=0;
String studentName;
for(int i=1;i<=studentNo;i++)
{
System.out.println("Enter the Student");
studentName = bufReader.readLine().toString();
System.out.println("Enter the Score");
score = Integer.parseInt(bufReader.readLine());
map.put(score, studentName);
}
Iterator iterator = map.keySet().iterator();
int sum=0;
int max=0;
while( iterator. hasNext() ){
int s = Integer.parseInt(iterator.next().toString().trim());
if(max<s)
{
max=s;
}
sum+=s;
}
int totalsutdent = map.size();
int avg=Math.round(sum/totalsutdent);
System.out.println("avg " + avg);
System.out.println("max " + max);
Iterator lowItr = map.keySet().iterator();
String lowStudent="";
String highStudent="";
while(lowItr.hasNext()){
int sval= Integer.parseInt(lowItr.next().toString().trim());
if(sval<avg)
{
lowStudent+=map.get(sval)+",";
}
if(max==sval)
{
highStudent+=map.get(sval)+",";
}
}
System.out.println("Students whose test scores are below the class average = " + avg );
System.out.println( lowStudent.substring(0,lowStudent.lastIndexOf(",")));
System.out.println("Students whose test scores are highest = " + max );
System.out.println("" + highStudent.substring(0,highStudent.lastIndexOf(",")));
}
}


For read more information :
http://www.roseindia.net/java/

Thanks


Ads









Related Tutorials/Questions & Answers:
score computation - Java Beginners
score computation  Hello maam and sir its ok with you that you... * highest test score and the names of all the students havinng the highest score (thank you so much for your time,hope you will gonna help me)  Hi
computation code - Java Beginners
computation code  "Helo man&sir can you share or gave me a java code hope its ok?"thank you Design a program that records and reports the weekly sales amount for the salespeople of a company. Each of the (n) salepeople
Advertisements
Version of com.madgag>string-score dependency
List of Version of com.madgag>string-score dependency
Version of com.madgag>string-score dependency
List of Version of com.madgag>string-score dependency
Version of com.eharmony>aloha-avro-score-java dependency
List of Version of com.eharmony>aloha-avro-score-java dependency
SCORE Embedded Ada
SCORE Embedded Ada       SCORE (Safety Critical, Object-oriented, Real-time, Embedded) supports a variety of target processors and languages, individually or integrated
Highest average score among 25 students
Highest average score among 25 students  a program that prompts the user to enter grades of 25 students in a class and grade them into 4 lessons (grades should range between 10 and 20, otherwise the user is prompted to enter
Maven Dependency string-score >> 0.0.1-UNOFFICIAL-ROBERTO-RELEASE
You should include the dependency code given in this page to add Maven Dependency of com.madgag >> string-score version0.0.1-UNOFFICIAL-ROBERTO-RELEASE in your project
Maven Dependency aloha-avro-score-java >> 4.0.0
You should include the dependency code given in this page to add Maven Dependency of com.eharmony >> aloha-avro-score-java version4.0.0 in your project
Maven Dependency aloha-avro-score-java >> 4.1.0
You should include the dependency code given in this page to add Maven Dependency of com.eharmony >> aloha-avro-score-java version4.1.0 in your project
Maven Dependency aloha-avro-score-java >> 4.1.1
You should include the dependency code given in this page to add Maven Dependency of com.eharmony >> aloha-avro-score-java version4.1.1 in your project
Maven Dependency aloha-avro-score-java >> 4.1.2
You should include the dependency code given in this page to add Maven Dependency of com.eharmony >> aloha-avro-score-java version4.1.2 in your project
Maven Dependency aloha-avro-score-java >> 4.1.3
You should include the dependency code given in this page to add Maven Dependency of com.eharmony >> aloha-avro-score-java version4.1.3 in your project
Maven Dependency aloha-avro-score-java >> 4.2.0
You should include the dependency code given in this page to add Maven Dependency of com.eharmony >> aloha-avro-score-java version4.2.0 in your project
Maven Dependency string-score >> 0.0.1-UNOFFICIAL-ROBERTO-RELEASE
You should include the dependency code given in this page to add Maven Dependency of com.madgag >> string-score version0.0.1-UNOFFICIAL-ROBERTO-RELEASE in your project
SCORE Mixed Language Development System
SCORE Mixed Language Development System       The SCORE real-time Ada development... is required. The SCORE run-time system is built on top of VxWorks and will support
How to show database values in Graph.(Like Cricket score board Graph)
How to show database values in Graph.(Like Cricket score board Graph) ....(Like Cricket score board Graph)   import java.sql.*; import... ("Match Score", "Runs", "Overs", xyDataset, PlotOrientation.VERTICAL, true
SQL Aggregate Functions
SQL Aggregate Functions       SQL Aggregate Functions is built in function that is used for the computation of records in a table. Understand with Example The Tutorial
Sports Score Applications ? Get The Latest Scores No Matter Where You Are
Sports Score Applications – Get The Latest Scores No Matter Where You... on games and sports teams. With the sports score applications you can keep up to date... for it. With your mobile sports score applications you can get results of your
Horizontal Bar Chart Example using JFreeChart
score of two teams .  Code Description:  In the code given below we...", "Match", "Score", dataset,   PlotOrientation.HORIZONTAL
Stacked 3d Bar Chart Example using JFreeChart
a Stacked 3d bar chart using JFreeChart. Bar chart will represent the score...;Chart ", "Match", "Score",   dataset
Java Training Online Class
training classes score over the classroom training. It first starts
hi.. please give me a java coding for the following question
??s name and score, and finally displays the name of the students with the highest score
Marks
Marks       Giving score to article as Digg does. Read full Description
problem - Java Beginners
problem  A sample run follows: Enter Doc?s score: 90 Enter Grumpy?s score: 50 Enter Happy?s score: 70 Enter Sleepy?s score: 40 Enter Dopey?s score: 30 Enter Sneezy?s score: 60 Enter Bashful?s score: 80 The average
problem - Java Beginners
problem  A sample run follows: Enter Doc?s score: 90 Enter Grumpy?s score: 50 Enter Happy?s score: 70 Enter Sleepy?s score: 40 Enter Dopey?s score: 30 Enter Sneezy?s score: 60 Enter Bashful?s score: 80 The average
java - Java Beginners
java   Q: In a certain diving even a score is awarded by each of the 10 judges. the highest and the lowest score are neglected and the average of the rest is found to get the final score. Design a flochart to input the 10 score
java program - Java Beginners
add some codes to make the names and score i input it will display the name... HashMap(); int score=0; String studentName; for(int i=1;i<=studentNo;i...().toString(); System.out.println("Enter the Score"); score = Integer.parseInt
what is wrong in this program......
extends Test implements Sports { float Score; public void getScore() { System.out.println("Enter Sports Score"); Score=Float.parseFloat(ob.readLine()); } float total; void getTotal() { total=m1+m2+Score
java programming - Spring
the user for his score in the first exam // TODO, ask the user for his score...(); System.out.println("Enter score of first subject: "); int sub1=input.nextInt(); System.out.println("Enter score of second subject: "); int sub2
booleens
: A grade point average of 3.0 or higher and an entrance score of 60 or higher, an entrance score of 85 or higher and any grade point avarage. Also i need to write... 0.0 and 4.0 or if the entrance score is not between 0 and 100, then print

Ads

 
Advertisement null

Ads