java programming

java programming

Write a Java program that prompt user to input a number of students in a class. Then, prompt user to input the studentâ??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:

Mark Grade 85 -100 A+ 80 - 84 A 75 - 79 B+ 70 - 74 B 65 - 69 B- 60 - 64 C+ 55 â?? 59 C 50 - 54 C- 45 - 49 D+ 40 - 44 D 0 E

View Answers

October 18, 2011 at 10:53 AM

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));
            }
        }

October 18, 2011 at 6:16 PM

import java.util.Scanner;

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;
        int count2 = 0;
        int count3 = 0;
        int 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));
    }
}

October 18, 2011 at 6:16 PM

import java.util.Scanner;

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;
        int count2 = 0;
        int count3 = 0;
        int 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 Tutorials/Questions & Answers:
Java Programming
Java Programming  Hi, What is Java Programming? How I can learn Java Programming in one month? Thanks
java programming
java programming   Companies and people often buy and sell stocks... in question Implement the program described above using the Java programming language... programming method you want to accomplish this task. Both your stack and queue
Advertisements
java programming
java programming   Companies and people often buy and sell stocks... in question Implement the program described above using the Java programming language... programming method you want to accomplish this task. Both your stack and queue
programming - Java Beginners
programming for java beginners  How to start programming for java beginners
programming - Java Beginners
Start programming in Java  Programming in Java - Can any one please suggest how to start programming in Java
Java Programming
Java Programming  Write a Java program that prompt user to input a number of students in a class. Then, prompt user to input the studentÃ?¢ââ??‰â??¢s programming mark. Determine how many student get A+ and A for their grade
java programming
java programming  Write a Java program that prompt user to input a number of students in a class. Then, prompt user to input the studentâ??s programming mark. Determine how many student get A+ and A for their grade and how many
Java programming
Java programming  What is the Role of OOP in java
Java programming
Java programming  What is the Role of OOP in java
java programming
java programming  how to write a coding for simple login form in netbeans
java programming
java programming  what is taxonomy tree why we use that concept in java   hierarchical taxonomy is a tree structure of classifications for a given set of objects
Java Programming
Java Programming  Using Java Frame form, help me develop a GPA calculating device, able to show Grade and points together, and using MySQL database
Java Programming
Java Programming  Using Java Frame form, help me develop a GPA calculating device, able to show Grade and points together, and using MySQL database
JAVA PROGRAMMING
JAVA PROGRAMMING  Write an OVERLOADED FUNCTION in java that swaps(interchanges) 2 user given numbers.(one integer and one float value) and displays the result after swapping. Invoke the function in a class
java programming
java programming  how to count the no. of constants in a user given string?? plzz help
java programming
java programming  Write a complete Java Program that correctly does the following: prints out first 1000 numbers (not including 1000) with a statement indicating whether it is even or not.. Output: Example Number 0 - Even
java programming
java programming  Hi friends, if i create one project what are the step i can make...... i need step by step procedure
java programming
java programming  WAP to calculate the sum of: x + x(square)/2 + x(cube)/3 +.......... x(to the power n)/n
java programming
java programming  supose i have a text field in java (like in gmail home page u have username field ) so i want to fill that field automatically by taking record from the database so is there any mechanism in java to handle
java programming
java programming  Hi, do u have any idea about these lines? Hashtable<Integer,JLabel> labels = new Hashtable<Integer,JLabel>(); labels = new Hashtable<Integer,JLabel>
java programming
java programming  Hi friends i need simple login form coding using two labels,two textfields and two buttons in netbeans without using database connection. . if you know that logic please tell
java programming
java programming  Hi friend if you have any idea about this statement please tel me... String qry1="select * from custentry1 where custid='"+custno
java programming
java programming  Hi friends, i need a simple login form source code. in that program i have two labels,two text fields and two buttons namely ok and cancel buttons. how to write for that one using netbeans without database
java Programming
java Programming  Based on the following algorithm, write a Java Program Start defining the MyClass class. Declare the class?s myField data field. Initialize the data field. Start defining the SetField() method. Set
Java Programming
Java Programming  Assume that bank maintains two kinds of accounts...://www.roseindia.net/tutorial/java/core/bankAccountApplication.html   thnk...://www.roseindia.net/answers/viewqa/Java-Beginners/27008-q-in-java.html
java programming
java programming  How can be uesd in graphiclly view for user inter (x,y) cordinate and show the output shart point to end point. java code,,????   import org.jfree.chart.*; import org.jfree.chart.plot.PlotOrientation
java programming
java programming  How can be uesd in graphiclly view for user inter (x,y) cordinate and show the output shart point to end point. java code,,????   import org.jfree.chart.*; import org.jfree.chart.plot.PlotOrientation
java programming
java programming  How can be uesd in graphiclly view for user inter (x,y) cordinate and show the output shart point to end point. java code,,????   import org.jfree.chart.*; import org.jfree.chart.plot.PlotOrientation
Java programming
Java programming  Hello! Is anybody able to do this task: I need to find the percentage of words distribution between parts of speech. I have to mark nouns, verbs, adjectives and perpositions like that: to the end of noun
java programming
java programming  abstract class demo { void play() { System.out.println("hello"); } void play2() { System.out.println("hi there"); } } class abs extends demo { public static
Java Programming
Java Programming  A developer wants you to develop a simple take away restaurant order service. The system reads from a file containing information about the restaurants (such as the name, place and menu). The system then allows
JAVA PROGRAMMING
JAVA PROGRAMMING  WAP to generate the following Series * * * * * * * * * * * * * * *   class Pyramid{ public static void main(String[] args
Java programming
Java programming  To make a fraction to a representation base 16 (i.e. hexadecimal) we can multiply it by 16, and the resultant integer part is the first digit of the base-16 representation. Multiplying the fraction left over
java programming
java programming  A name is ALREADY in a string variable in memory. The string is called NAME or NAME$ . The variable holds a person's name with a space between the first and family name. WILLIAM (space) JONES
java programming
java programming  WAP to find the longest word from a user given string.   The given code finds the longest word from the string. import java.util.*; class LongestWord { Scanner input=new Scanner(System.in
java programming
java programming  WAP to accept 10 strings from the user and find out the string with maximum length and print the same.   Here is a code that accepts 10 strings from the string and stored into array and then find
java programming
java programming  Hi, now am analysing one project from that project the below module was came. why we use that module what is the use of this module........ public void Start_Clustering() { int Clusters
java programming
java programming  A computer is used to count the votes in an election. At the start of the election, the number of candidates standing is entered. Suppose this value is N â?? candidates will then be numbered 1 to N
programming - Java Beginners
How to programming in Java  How to start programming in Java? Please provide me the step by step guide.Thanks
java programming:generating series
java programming:generating series  WAP to print series: | + || + ||| + |||| + .......... n terms
Java Socket Programming
Java Socket Programming  Hi, What is Java Socket Programming? Can anyone give the examples of Java Socket Programming? Thanks   Hi, Please see the tutorial:Overview of Networking through JAVA Thanks
Java Programming Language
Java Programming Language  Hi, For beginner which programming concepts is important? Discuss the importance of Java programming language... please let's know how to use Java in developing web applications? Thanks
java programming problem - JDBC
java programming problem  Hi, Request you to provide the source code in Java for the following programming problem : upload .csv file data into oracle database. please send the solution to [email protected]
Java programming approch
Java programming approch  What are the approaches that you will follow for making a program very efficient
Programming problem - Java Beginners
it difficult to learn java programming? Based on my survey it seems that java programming is the hardest part of their studies.. I also want to know...Programming problem  Good afternoon Ma'am/Sir, Can you help me
programming java qus.
programming java qus.  write a import statement that import all the inner class of outer class .outer class must not be imported
programming java qus.
programming java qus.  write a import statement that import all the inner class of outer class .outer class must not be imported
programming java qus.
programming java qus.  write a import statement that import all the inner class of outer class .outer class must not be imported
programming java qus.
programming java qus.  write a import statement that import all the inner class of outer class .outer class must not be imported
programming java qus.
programming java qus.  write a import statement that import all the inner class of outer class .outer class must not be imported

Ads