how to solve this..

Ads
 

how to solve this..

Given a list of students and their marks

Name | Science | Math | English | Computer

Ahmad | 28 | 100 | 66 | 34

Samad | 56 | 89 | 55 | 55

Johan | 78 | 77 | 34 | 100

John | 100 | 43 | 10 | 98

Suhana | 10 | 63 | 21 | 88

Grade :

A = 100 - 90

B = 89 - 70

C = 69 - 50

D = 49 - 40

F = 39 - 0

Create an array for students and two dimensional arrays for the marks. From this creation get :

a. Convert marks to grade for each marks of the subjects

b. List the student name that gets the highest in that class.

c. List the student name that gets the highest in that class.

d. List of student that get 100 in each subject.

View Answers

April 25, 2011 at 1:02 PM

public class Student {
    String name;
    int sub1;
    int sub2;
    int sub3;
    int sub4;
    int totalMarks;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setSub1(int sub1) {
        this.sub1 = sub1;
    }

    public int getSub1() {
        return sub1;
    }

    public void setSub2(int sub2) {
        this.sub2 = sub2;
    }

    public int getSub2() {
        return sub2;
    }

    public void setSub3(int sub3) {
        this.sub3 = sub3;
    }

    public int getSub3() {
        return sub3;
    }

    public void setSub4(int sub4) {
        this.sub4 = sub4;
    }

    public int getSub4() {
        return sub4;
    }

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

    public int getTotalMarks() {
        return totalMarks;
    }

    public static String setGrades(int marks) {
        if (marks >= 90 && marks <= 100) {
            return "A";
        }
        if (marks >= 70 && marks <= 89) {
            return "B";
        }
        if (marks >= 50 && marks <= 69) {
            return "C";
        }
        if (marks >= 40 && marks <= 49) {
            return "D";
        }
        if (marks < 40) {
            return "F";
        }
        return " ";
    }

April 25, 2011 at 1:03 PM

continue..

public static void main(String[] args) {
        int mm = Integer.MIN_VALUE;
        Student data[] = new Student[5];
        data[0] = new Student();
        data[0].setName("Ahmad");
        data[0].setSub1(28);
        data[0].setSub2(100);
        data[0].setSub3(66);
        data[0].setSub4(34);
        int sum1 = data[0].getSub1() + data[0].getSub2() + data[0].getSub3()
                + data[0].getSub4();
        data[0].setTotalMarks(sum1);

        data[1] = new Student();
        data[1].setName("Samad");
        data[1].setSub1(56);
        data[1].setSub2(89);
        data[1].setSub3(55);
        data[1].setSub4(55);
        int sum2 = data[1].getSub1() + data[1].getSub2() + data[1].getSub3()
                + data[1].getSub4();
        data[1].setTotalMarks(sum2);

        data[2] = new Student();
        data[2].setName("Johan");
        data[2].setSub1(78);
        data[2].setSub2(77);
        data[2].setSub3(34);
        data[2].setSub4(100);
        int sum3 = data[2].getSub1() + data[2].getSub2() + data[2].getSub3()
                + data[2].getSub4();
        data[2].setTotalMarks(sum3);

        data[3] = new Student();
        data[3].setName("John");
        data[3].setSub1(100);
        data[3].setSub2(43);
        data[3].setSub3(10);
        data[3].setSub4(98);
        int sum4 = data[3].getSub1() + data[3].getSub2() + data[3].getSub3()
                + data[3].getSub4();
        data[3].setTotalMarks(sum1);

        data[4] = new Student();
        data[4].setName("Suhana");
        data[4].setSub1(10);
        data[4].setSub2(63);
        data[4].setSub3(21);
        data[4].setSub4(88);
        int sum5 = data[4].getSub1() + data[4].getSub2() + data[4].getSub3()
                + data[4].getSub4();
        data[4].setTotalMarks(sum1);

        for (int i = 0; i < 5; i++) {
            Student show = data[i];
            System.out.println(show.getName() + "\t "
                    + setGrades(show.getSub1()) + "\t "
                    + setGrades(show.getSub2()) + "\t "
                    + setGrades(show.getSub3()) + "\t "
                    + setGrades(show.getSub4()));
        }
        for (int i = 0; i < 5; i++) {
            int m = data[i].getTotalMarks();
            if (m > mm) {
                mm = m;
            }
        }
        System.out.println("Student obtains highest marks: ");
        for (int i = 0; i < 5; i++) {
            if (mm == data[i].getTotalMarks()) {
                System.out.println(data[i].getName() + " "
                        + data[i].getTotalMarks());
            }
        }
        System.out.println("Student get 100 marks in each subject: ");
        for (int i = 0; i < 5; i++) {
            if ((data[i].getSub1() == 100) && (data[i].getSub2() == 100)
                    && (data[i].getSub3() == 100) && (data[i].getSub4() == 100)) {
                System.out.println(data[i].getName());
            } else {
                System.out.println("Not Found");
            }
        }
    }
}

Ads









Related Tutorials/Questions & Answers:
how to solve
how to solve   log4j:WARN No appenders could be found for logger (org.apache.struts.util.PropertyMessageResources). log4j:WARN Please initialize the log4j system properly
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
Advertisements
how to solve this..
how to solve this..  Given a list of students and their marks Name | Science | Math | English | Computer Ahmad | 28 | 100 | 66 | 34 Samad | 56 | 89 | 55
How to solve the Hibernate Common Exceptions?
How to solve the Hibernate Common Exceptions?  How to solve the Hibernate Common Exceptions
i dont no how to solve it pls
i dont no how to solve it pls   Calculate and display the sum of all prime number from 1 to 100 covert in java system codes
how to solve an internet connection problem
how to solve an internet connection problem  when i run my application it give me this error: Exception in thread "AWT-EventQueue-0... how to implement
how to solve this problem for oracle connectivity
how to solve this problem for oracle connectivity  Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap ter could not establish the connection
how do i solve this problem?
how do i solve this problem?  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
how do i solve this question?
how do i solve this question?  1.Define a class named Circle with the following properties: a) An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier
how should i can solve
how should i can solve  Web based program - Input - Person's contact details with Passport Number as Unique Key. Save data in to oracle / MySQL. Output - List of Persons saved in the database. Technology to be used - JSP
Solve it
Solve it  How to calculate the value which contains oparator and operand both using command line argument
Small Bug How to solve in my code
Small Bug How to solve in my code  String season=""; pst = con.prepareStatement("SELECT DISTINCT(Season) season FROM specialdates where Regid...") + ","; it shows bug in findbugs tool.. but it executes successfully how to solve
how to solve 'Stop Running This Script' Error ?
how to solve 'Stop Running This Script' Error ?  Hi.. When opened the page on IE browser(version : 8.0),it gives an java script error (i.e.Stop Running This Script). I have used jsp/servlet for this. Please help to resolved
how to solve this kind of error in Eclipse IDE?
how to solve this kind of error in Eclipse IDE?   i'm creating the Simple CRUD Using Jsp, Servlet and MySQL program and i'm using the eclipse, and i all most done it, finally i'm going to run myself, it can't be run. i
How can we solve this puzzle using java ?
How can we solve this puzzle using java ?  Sachin likes sweets a lot. So, he goes to a market of sweets. There is a row of sweet stalls. Every sweet... someone help how can we write the code
solve this
solve this   Create a student class. The student object should have studentid, studentname, subject and marks as properties. Also generate the getter and setter methods. Create 5 objects of this class and populate values
how to solve error like'java.lang.NumberFormatException: For input string: "7600113411"' this
how to solve error like'java.lang.NumberFormatException: For input string: "7600113411"' this  java.lang.NumberFormatException: For input string: "7600113411"    java.lang.NumberFormatException: For input string
How to solve concurrency issue when an application is running on two machine to fetch record from one database
How to solve concurrency issue when an application is running on two machine to fetch record from one database  I have developed an application in java to run on two machines. Program will fetch a record from database and process
solve this pbm
solve this pbm  sir rows are also inserting i have checked in the database also the rows are not affected in the table . The first pbm wich i have sent to you is not yet solved.......... pls give me detail explaination how we
solve this pbm
solve this pbm  its not working the code for databae access using servlets
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 of the table. For example -10 and 156 in GUI?  import java.awt.*; import javax.swing.*; import java.awt.event.*; public class MarkStudent { double
ModuleNotFoundError: No module named 'solve'
ModuleNotFoundError: No module named 'solve'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'solve' How to remove the ModuleNotFoundError: No module named 'solve'
Solve
solve this problem
solve this problem  I typed this program and compiled.The program is compiled but when i eneterd url in tomcat server. Its not giving error but only blank page is coming the text is not displaying and row is also inserted
ModuleNotFoundError: No module named 'flood-solve'
'flood-solve' How to remove the ModuleNotFoundError: No module named 'flood-solve' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'flood-solve'  Hi, My Python
ModuleNotFoundError: No module named 'flood-solve'
'flood-solve' How to remove the ModuleNotFoundError: No module named 'flood-solve' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'flood-solve'  Hi, My Python
ModuleNotFoundError: No module named 'magiceye_solve'
named 'magiceye_solve' How to remove the ModuleNotFoundError: No module named 'magiceye_solve' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'magiceye_solve'  Hi, My
ModuleNotFoundError: No module named 'solve-instrument'
named 'solve-instrument' How to remove the ModuleNotFoundError: No module named 'solve-instrument' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'solve-instrument'  Hi, My
ModuleNotFoundError: No module named 'sudoku-solve'
'sudoku-solve' How to remove the ModuleNotFoundError: No module named 'sudoku-solve' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'sudoku-solve'  Hi, My Python
ModuleNotFoundError: No module named 'sudoku-solve'
'sudoku-solve' How to remove the ModuleNotFoundError: No module named 'sudoku-solve' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'sudoku-solve'  Hi, My Python
A Program To Solve In Java
A Program To Solve In Java  x!/x+(x+2)!/x+(x+4)!/x ... (x+n)!/x

Ads