Please help with this Q

Ads
 

Please help with this Q

Write a program that should allow a tutor to enter in various marks which students have been awarded, until the tutor enters in a mark exceeding 100. At this point the program should display a histogram. Each star represents a student who achieved a module mark in the range shown.

0-29 *
30-39 * 40-69 ** 70-100 **

20 students in total.

Your program should work with any number of student marks entered.

After the histogram, a variety of statistics should be displayed (e.g. average mark awarded, number of students passing, highest mark, and lowest mark)

View Answers

December 11, 2011 at 5:50 PM

The answer for the above question as i did is as follows

import java.util.*;

class ClassStatistics

{

public static void main(String args[])

{

float marks[]=new float[20];

int i,ctr=0,ctr1=0,ctr2=0,ctr3=0,passed=0;

float highest=0, lowest;

Scanner input=new Scanner(System.in);

for(i=0;i<20;i++)

{


System.out.println("Enter the marks of student");

System.out.println("Enter a mark greater than 100 to view results");

marks[i]=input.nextFloat();


if(marks[i]>=0&&marks[i]<=29)

ctr++;

else if(marks[i]>=30&&marks[i]<=39)

ctr1++;

else if(marks[i]>=40&&marks[i]<=69)

ctr2++;

else if(marks[i]>=70&&marks[i]<=100)

ctr3++;

if(marks[i]>100)

break;

if(marks[i]>=50)

passed++;

if(marks[i]>=highest)

highest=marks[i];

}

System.out.print("0-29 ");

while(ctr!=0)

{

System.out.print("*");

ctr--;

}

System.out.println("");

System.out.print("30-39 ");

while(ctr1!=0)

{

System.out.print("*");

ctr1--;

}

System.out.print("");

System.out.print("40-69 ");

while(ctr2!=0)

{

System.out.print("*");

ctr2--;

}

System.out.print("");

System.out.print("70-100 ");

while(ctr3!=0)

{

System.out.print("*");

ctr3--;

}

int j=0;

lowest=marks[j];

j++;

while(j<20)

{

if(marks[j]<=lowest)

lowest=marks[j];

j++;

}


System.out.println("Number of students passing "+passed);

System.out.println("Highest mark "+highest);

System.out.println("Lowest mark "+lowest);


}

}

Ads









Related Tutorials/Questions & Answers:
Please help with this Q ASAP
Please help with this Q ASAP  The University wants to make a basic graphical display to show how many people received different grades for a piece of work on a module. You are required to write a program in Java that achieves
Please help with this Q
Please help with this Q  Write a program that should allow a tutor to enter in various marks which students have been awarded, until the tutor enters in a mark exceeding 100. At this point the program should display a histogram
Advertisements
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 ?? this is the ouput..;;; i
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 ?? this is the ouput..;;; i
please help//
please help//  Number square cube 1 1 1 3 9 27 5 25 125 7 49 343 9 81 729 total 165 1225 ?? this is the ouput..;;; i
please help
please help  please send me the code of dynamic stack in java without using the built in functions
help please?
help please?  Define a class named Circle with the following properties: ? An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both data fields
help please?
help please?  Define a class named Circle with the following properties: List item ? An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
help please?
help please?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
java please please help
java please please help  Dear Friends plz help me to complete this program import java.util.*; public class StringDemo { static...[] to HashMap so that i can seperate key and value using Map.Entry.Please help me!  
Please help
Please help  Problem: Write a program that does addition, subtraction, multiplication and division operation on real numbers. The operation started with a user entered 2 numbers and click one of the operation buttons
help please?
help please?  Define a class named Circle with the following properties: ? An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both data fields
Please help
Please help  Problem: Write a program that does addition, subtraction, multiplication and division operation on real numbers. The operation started with a user entered 2 numbers and click one of the operation buttons
help please
help please  hi i am done with register application using jsps servlets htmls. But i couldnt imp one thing that.. Wen u login to ur account browser... file.. Or atleast help me with code here.. I tried checking session alive
please help
please help  public class AllContact extends javax.swing.JFrame { /** Creates new form AllContact */ public AllContact() { initComponents(); try{ Connection1 con =new Connection1(); Connection conobj
urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D
please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath
Please Help Now
Please Help Now  i want to put this map in ajax oriented codeigniter website thanks in advance plz help me now plz very urgent
please help me.
please help me.  How to move the edits.jsp in below link? http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
Please help me
Please help me  program for when a user enter his card number, it has to create default security pin in the database
PLEASE HELP WITH MY JAVA
PLEASE HELP WITH MY JAVA  Hey my name is Gavin and im a student... please help!!!!!!!! it is a for-loop question: Display the first 5 multiples... and average If u can please help...   
help me please
help me please   Hello I want helping for this question , Please Write a program that reads some friendsâ?? names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
need help please
need help please  Dear sir, my name is logeswaran. I have a big problem that I can't find the solution for a program. How can I block a user from enter a page second time. Please help me. By the way I'm using Access database
please help me
please help me  interface Test1 { String toString(); } public class Test { public static void main(String[] args) { System.out.println(new Test1() { public String toString() { return "test
please help me.
please help me.  I have a jsp page under that i add a list box under i get the countries through my database. so how can i do

Ads