Home Answers Viewqa Java-Interview-Questions Write a program to display grade message according to the marks

 
 


pritamkumar
Write a program to display grade message according to the marks
4 Answer(s)      11 months ago
Posted in : Java Interview Questions

pls give d answer how to Write a program to display grade message according to the marks

View Answers

July 5, 2012 at 11:27 PM


Write a program to display grade message according to the marks..........


July 6, 2012 at 2:57 PM


Here is a code that accepts the number of students and their marks and display the grade according to student's marks.

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class StudentGrade {
     double totalMarks;
     String grade;

    public void setTotalMarks(double totalMarks) {
        this.totalMarks = totalMarks;
        }

    public double getTotalMarks() {
        return totalMarks;
    }

    public void setGrade(String grade) {
        this.grade = grade;
        }

    public String getGrade(){
        return grade;
    }

    public static void main(String[] args){
        JLabel lab=new JLabel("Enter number of students in class: ");
        final JTextField text=new JTextField(20);

        JButton b=new JButton("Find");
        lab.setBounds(10,10,150,20);
        text.setBounds(180,10,100,20);
        b.setBounds(180,40,100,20);

        JFrame f=new JFrame();
        f.setLayout(null);
        f.add(lab);
        f.add(text);
        f.add(b);
        f.setSize(300,100);
        f.setVisible(true);
        b.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){

        int num = Integer.parseInt(text.getText());
        StudentGrade data[] = new StudentGrade[num];
        for(int a = 0; a < data.length; a++) {
           String input=JOptionPane.showInputDialog(null,"Enter student programming marks: ");

            double marks = Double.parseDouble(input);
            data[a] = new StudentGrade();
            data[a].setTotalMarks(marks);

            if (marks < 40){
                data[a].setGrade("E");
            }

            if (marks >= 40 && marks <= 44) {
                data[a].setGrade("D");
            }

            if (marks >= 45 && marks <= 49) {
                data[a].setGrade("D+");
            }

            if (marks >= 50 && marks <= 54) {
                data[a].setGrade("C-");
            }

            if (marks >= 55 && marks <= 59) {
                data[a].setGrade("C");
            }

            if (marks >= 60 && marks <= 64) {
                data[a].setGrade("C+");
            }

            if (marks >= 65 && marks <= 69) {
                data[a].setGrade("B-");
            }

            if (marks >= 70 && marks <= 74) {
                data[a].setGrade("B");
            }

            if (marks >= 75 && marks <= 79) {
                data[a].setGrade("B+");
            }

            if (marks >= 80 && marks <= 84) {
                data[a].setGrade("A");
            }

            if (marks >= 85 && marks <= 100)
                data[a].setGrade("A+");
        }

        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        int count4 = 0;
        int count5 = 0;
        int count6 = 0;
        int count7 = 0;
        int count8 = 0;
        int count9 = 0;
        int count10 = 0;
        int count11 = 0;

July 6, 2012 at 2:58 PM


continue..

for (int i = 0; i < num; i++) {
                StudentGrade show = data[i];
                String g = show.getGrade();
                if (g.equals("A+")) {
                    count1++;
                }
                if (g.equals("A")) {
                    count2++;
                }
                if (g.equals("B+")) {
                    count3++;
                }
                if (g.equals("B")) {
                    count4++;
                }
                if (g.equals("B-")){
                    count5++;
                }
                if (g.equals("C+")){
                    count6++;
                }
                if (g.equals("C")){
                    count7++;
                }
                if (g.equals("C-")){
                    count8++;
                }
                if (g.equals("D+")){
                    count9++;
                }
                if (g.equals("D")){
                    count10++;
                }
                if (g.equals("E")){
                    count11++;
                }

            }
            JOptionPane.showMessageDialog(null,"Number of student getting A+ and A grade: "
                    + (count1 + count2));
            JOptionPane.showMessageDialog(null,"Number of student getting B+ and B grade: "
                    + (count3 + count4));
            JOptionPane.showMessageDialog(null,"Number of student getting A and B+ grade: "
                    + (count2 + count3));
            JOptionPane.showMessageDialog(null,"Number of student getting B and B- grade: "
                    + (count4 + count5));
            JOptionPane.showMessageDialog(null,"Number of student getting B- and C+ grade: "
                    + (count5 + count6));
            JOptionPane.showMessageDialog(null,"Number of student getting C+ and C grade: "
                    + (count6 + count7));
            JOptionPane.showMessageDialog(null,"Number of student getting C and C- grade: "
                    + (count7 + count8));
            JOptionPane.showMessageDialog(null,"Number of student getting C- and D grade: "
                    + (count8 + count9));
            JOptionPane.showMessageDialog(null,"Number of student getting D and D- grade: "
                    + (count9 + count10));
            JOptionPane.showMessageDialog(null,"Number of student getting D- and E grade: "
                    + (count10 + count11));

                }
            });
        }
    }

July 6, 2012 at 2:59 PM


Here is a code that accepts the number of students and their marks and display the grade according to student's marks.

import java.util.*;

public class StudentMarks{

        double totalMarks;
        String grade;

        public void setTotalMarks(double totalMarks){
        this.totalMarks=totalMarks;
        }
        public double getTotalMarks(){
        return totalMarks;
        }
        public void setGrade(String grade){
        this.grade=grade;
        }
        public String getGrade(){
        return grade;
        }
        public static void main(String[]args){
                Scanner input=new Scanner(System.in);
                System.out.print("Enter number of students: ");
                int num=input.nextInt();
                StudentMarks data[]=new StudentMarks[num];
                for (int i=0; i<data.length; i++) {
                System.out.println("Enter marks");
                double marks=input.nextDouble();
                data[i] = new StudentMarks();
                data[i].setTotalMarks(marks);
                if(marks<40){
                    data[i].setGrade("E");
                }
                if(marks>=40&&marks<=44){
                    data[i].setGrade("D");
                }
                if(marks>=45&&marks<=49){
                    data[i].setGrade("D+");
                }
                if(marks>=50&&marks<=54){
                    data[i].setGrade("C-");
                }
                if(marks>=55&&marks<=59){
                    data[i].setGrade("C");
                }
                if(marks>=60&&marks<=64){
                    data[i].setGrade("C+");
                }
                if(marks>=65&&marks<=69){
                    data[i].setGrade("B-");
                }
                if(marks>=70&&marks<=74){
                    data[i].setGrade("B");
                }
                if(marks>=75&&marks<=79){
                    data[i].setGrade("B+");
                }
                if(marks>=80&&marks<=84){
                    data[i].setGrade("A");
                }
                if(marks>=85&&marks<=100)
                    data[i].setGrade("A+");
                }
                }
                int count1=0,count2=0,count3=0,count4=0;
                for(int i=0;i<num;i++){
                StudentMarks show = data[i];
                String g = show.getGrade();
                if(g.equals("A+")){
                    count1++;
                }
                if(g.equals("A")){
                    count2++;
                }
                if(g.equals("D")){
                    count3++;
                }
                if(g.equals("E")){
                    count4++;
                }
                }
                System.out.println("Number of student getting A and A+ grade: "+(count1+count2));
                System.out.println("Number of student getting D and E grade: "+(count3+count4));
            }
        }









Related Pages:
Write a program to display grade message according to the marks
Write a program to display grade message according to the marks  pls give d answer how to Write a program to display grade message according to the marks     Write a program to display grade message according
Write a JSP program to display the grade of a student by accepting the marks of five subjects.
Write a JSP program to display the grade of a student by accepting the marks of five subjects.  Write a JSP program to display the grade of a student by accepting the marks of five subjects
Student Marks
, and having trouble with it please help me. Write a program to compute the computer.... Then work out and display The average Final Grade for the ââ?¬Ë?Computer... of the students and store each in an array. The program should take the input
final grade
final grade  C. Write a JavaScript program that would input a student?s final grade from 50-100. Evaluate the Final grade and display the Point...? or ?Failed   C. Write a JavaScript program that would input a student
the grade of students
the grade of students  Write a Java program that prompt user to input...?¢s programming mark. Determine how many student get A+ and A for their grade and how many students get D and E based on the following table: Marks
Java Program for Calculating Marks
Java Program for Calculating Marks  Hi Everyone, I have a assignment that requires me to a write simple java program that will calculate marks for 10 students. I must use an array to ask user to key in the marks for the 10
Java Program for Calculating Marks
Java Program for Calculating Marks  Hi Everyone, I have a assignment that requires me to a write simple java program that will calculate marks for 10 students. I must use an array to ask user to key in the marks for the 10
Java Program for Calculating Marks
Java Program for Calculating Marks  Hi Everyone, I have a assignment that requires me to a write simple java program that will calculate marks for 10 students. I must use an array to ask user to key in the marks for the 10
Java Program for Calculating Marks
Java Program for Calculating Marks  Hi Everyone, I have a assignment that requires me to a write simple java program that will calculate marks for 10 students. I must use an array to ask user to key in the marks for the 10
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  Write program which accepts five students id,name,age,department,courses, taken and its grade. a. calculate its GPA . display all student information in ascending order
marks - Java Beginners
marks  the marks obtained by 100 students in a subject are tabulated as fallow:- NAME MARKS wap a program... applications. calculate the display:- *average marks in the subject of computer
array of students with marks list
and therefore no score available. Write a java program that will return the highest...array of students with marks list  There are 4 array of numbers or scores as below. They are called marks list and represent the scores individual
adding a method to calculate a students grade
a method to display the grade based on the mark of the student i cant seem... grade = 'E'; return grade; } public void display...adding a method to calculate a students grade  The Following program
how to write this program
or numerical grade. You will be submitting TWO versions of this program. Write one...how to write this program  Write a program in java which calculates...?¢s GPA. This program should take a studentââ?¬â?¢s First Name, Last Name a GPA
WRITE A PROGRAM IN JAVA
WRITE A PROGRAM IN JAVA  How do I write a program in Java, have the program display a message with your name in it and a number (Hello john Smith!1) The number must increment from zero to nine, or decrement fron nine to zero. You
to write a program to display the employee details..
to write a program to display the employee details..  To dipslay... running this program the new window has to be opened asking us to enter all...   not this one actually i wnat a very small program that displays all
write a java program to print marklist of "n " students. input Register number, name and marks of three subjects.
write a java program to print marklist of "n " students. input Register number, name and marks of three subjects.  write a java program to print marklist of "n " students. input Register number, name and marks of three subjects
write following program
is a java applet? Write a java applet to display "Hello JAVA". Also write the relation...write following program  Q1 What is the difference between single...-threading. Explain with examples Q2 Write a java applet that takes your name
program to print total marks
program to print total marks  program to input total marks out of 600 marks as an argument and print the stream allotted using the following criteria 401 & above - PCM 301-400 - ZBC 201-300- Commerce 101-200 - Arts
program to input marks
program to input marks  program to input marks ,name in computer application 7 annual fees to be paid .Decide the scholarship amount as per the given criteria Marks Scholarship(%)on Annual Fees =90
display
display  write a program that determines the limit of an integer
display
display  write a program that determines the limit of an integer
Write a question to display the follwing
Write a question to display the follwing  Write a Java program to display a pattern?   String str = ""; int count = 4; for( int i=9,j...++; } System.out.print(str);   class Display { public void
How to write Java Program
How to write Java Program  how to write a program to find average of 5 student marks
java program to exchange soap message
that how can I write the server side program in order to receive the message...java program to exchange soap message  Hi Friends, I want... a set of 15 parameters and program on web server side receives this 15 parameters
Write a java program to display the season given the month using switch case
Write a java program to display the season given the month using switch case  Write a java program to display the season given the month using switch case
Program
Program  hey please help me ... How can write multiple choice question paper using radio button.After submit calculate marks and display our marks... can any body help for me.using servlet,html   Here is a jsp test
Swing Program
Swing Program  Write a java swing program that takes name and marks as input with all validation. The name and marks will be displayed in message box when user clicks on a button
How to solve this java code by adding the student marks not in the list of the table. For example -10 and 156 in GUI?
How to solve this java code by adding the student marks not in the list... totalMarks; String grade; public void setTotalMarks(double totalMarks... totalMarks; } public void setGrade(String grade) { this.grade = grade
how to write the program - Java Beginners
how to write the program  WAP to create the report card user input Name, Class, Division, Roll no., Marks obtained in following subjects Lang Hindi History Geography Math Phy Chem. Bio Eve CSTA Also has a back up
Display Sorted data in TextArea
and grade. The data is not properly arranged in the file. Now we have to display... marks; String grade; public void setId(int id) { this.id = id... getMarks() { return marks; } public void setGrade(String grade
how to display the email message in jsp
how to display the email message in jsp  hi every one .. i am new from this industry please help me to display the email message in jsp page please send me sample code
A Message-Driven Bean Example
A Message-Driven Bean Example   ... messages asynchronously,  a Message-driven bean is used. Message driven..., email or IM messages). In message driven beans, the messaging service
java program
and use document.write command to display the output. Write a JavaScript program that would input a student's final grade from 50-100. Evaluate the Final Grade and display the Point Equivalent based on the table below. Indicate also the remarks
java program
and use document.write command to display the output. Write a JavaScript program that would input a student's final grade from 50-100. Evaluate the Final Grade and display the Point Equivalent based on the table below. Indicate also the remarks
write a program
write a program  write a program add 2 no.s without use arithmetic,unary operaters in java
Show message and confirm dialog box
are provided here. When your run the program, it will display a frame with three buttons... Show Message and Confirm Dialog Box - Swing Dialogs       This section show you how to display several
Interactive program
of the details.Name of student,registration number, marks obtained per subject,grade per... number, marks per subject.then this program will calculate grades per subject..."); System.out.print("Marks in Maths: "+mar2+"\n"); System.out.print("Grade in Maths
To Display the 'Last Modified' message in JSP
To Display the 'Last Modified' message in JSP  I have to display the "Last Modified" auto save message in a portlet page at the right end corner... Modified' Message should be displayed
Write a java program that prints out the following menu???
Write a java program that prints out the following menu???  Write a java program that prints out the following menu. Auser can interact with the menu... string. 4. Enter 5 marks in array and send it to function that returns the max mark
swing program
swing program  Write a java swing program to getname and email id. Display the message if email id contains the name of theuser
program to display the first ten terms of the series
program to display the first ten terms of the series  Write a program to display the first ten terms of the following series : 1) 1,-3,5,-7,9..... 2) 3,6,12,24..... 3) 2,5,10,17....... 4) 0,1,2,3,6............ 5) 0,3,8,15
how do i write a java program for this??
how do i write a java program for this??  â??Ask the user... in human years. Display the output. If â??noâ?? ask the user their age and compute the users age in dog years. Display the output. (Use the table from
Sort file data and write into another file
and grade. The data is not properly arranged in the file. Now, we have to display... implements Comparable { int id; String name; int marks; String grade; public... = "", marks = "", grade = ""; for (int i = 0; i < splitSt.length; i
Display error message if data is already inserted in database
Display error message if data is already inserted in database   Display error message if data is already inserted in database Pls help me Thanks
java program - Java Beginners
java program  m postin a program...hv 2 create a class,wid 6 data membr havin name,no,grade,n marks n 3 sub..........dere vil b 3 membr function.d.........1st wil tak input n display...2nd wil pas parametrs.....(name,no,wid marks n 3
Write a program named InternetCharge_YourLastName that do the following:
Write a program named InternetCharge_YourLastName that do the following: ... per month unlimited access is provided. Write a program named InternetCharge_YourLastName that do the following: *display the menu as follow: 1. Package A 2
write program have product - using loops
write program have product - using loops  Write a program for a grocery that reads products data and determine and display the product that has...), name (String) and price (double). Your program should continue reading new
Marks
Marks       Giving score to article as Digg does. Read full Description
depending on the form name i have to display the message
on the form name i have to display the message. for example, i have 3 jsp pages... on contact us after entering all details page has to display message like"thank u for contacting us" if user clicks on suugest display message like"thank u