Giter Club home page Giter Club logo

Comments (5)

sotiriszogos avatar sotiriszogos commented on August 31, 2024

Hello, could you please assign it to me?

from java-hacktoberfest23.

Milind-Palaria avatar Milind-Palaria commented on August 31, 2024

hey @chetannihith , can you assign me?

from java-hacktoberfest23.

swapniltake1 avatar swapniltake1 commented on August 31, 2024
`
public class School {
    // Data Members
    private int rollNo;
    private String name;
    private String address;
    private String branch;
    private double[] marks; // Marks in 4 subjects
    private double percentage;
    private char grade;

    // Constructor to initialize the data members
    public School(int rollNo, String name, String address, String branch, double[] marks) {
        this.rollNo = rollNo;
        this.name = name;
        this.address = address;
        this.branch = branch;
        this.marks = marks;
        calculatePercentageAndGrade();
    }

    // Method to calculate the percentage and grade
    private void calculatePercentageAndGrade() {
        double totalMarks = 0;
        for (double mark : marks) {
            totalMarks += mark;
        }
        percentage = totalMarks / 4.0;

        if (percentage >= 90) {
            grade = 'A';
        } else if (percentage >= 80) {
            grade = 'B';
        } else if (percentage >= 70) {
            grade = 'C';
        } else if (percentage >= 60) {
            grade = 'D';
        } else {
            grade = 'F';
        }
    }

    // Method to display student information
    public void displayStudentInformation() {
        System.out.println("Roll No: " + rollNo);
        System.out.println("Name: " + name);
        System.out.println("Address: " + address);
        System.out.println("Branch: " + branch);
        System.out.println("Marks in 4 Subjects: ");
        for (int i = 0; i < marks.length; i++) {
            System.out.println("Subject " + (i + 1) + ": " + marks[i]);
        }
        System.out.println("Percentage: " + percentage);
        System.out.println("Grade: " + grade);
    }

    public static void main(String[] args) {
        // Example usage
        double[] studentMarks = {85.5, 92.0, 78.5, 89.0};
        School student = new School(101, "John Doe", "123 Main St", "Science", studentMarks);
        student.displayStudentInformation();
    }
}

`

from java-hacktoberfest23.

Harshada305 avatar Harshada305 commented on August 31, 2024

import java.util.Scanner;

class School {
private int rollNo;
private String name;
private String address;
private String branch;
private double[] marks;
private double percentage;
private char grade;

// Constructor to initialize student information
public School(int rollNo, String name, String address, String branch, double[] marks) {
    this.rollNo = rollNo;
    this.name = name;
    this.address = address;
    this.branch = branch;
    this.marks = marks;
    this.calculatePercentage();
    this.calculateGrade();
}

// Calculate percentage based on marks
private void calculatePercentage() {
    double totalMarks = 0;
    for (double mark : marks) {
        totalMarks += mark;
    }
    this.percentage = (totalMarks / (marks.length * 100)) * 100;
}

// Calculate grade based on percentage
private void calculateGrade() {
    if (percentage >= 90) {
        this.grade = 'A';
    } else if (percentage >= 80) {
        this.grade = 'B';
    } else if (percentage >= 70) {
        this.grade = 'C';
    } else if (percentage >= 60) {
        this.grade = 'D';
    } else {
        this.grade = 'F';
    }
}

// Display student information
public void displayStudentInfo() {
    System.out.println("Student Information:");
    System.out.println("Roll No: " + rollNo);
    System.out.println("Name: " + name);
    System.out.println("Address: " + address);
    System.out.println("Branch: " + branch);
    System.out.println("Marks (Subject-wise):");
    for (int i = 0; i < marks.length; i++) {
        System.out.println("Subject " + (i + 1) + ": " + marks[i]);
    }
    System.out.println("Percentage: " + percentage + "%");
    System.out.println("Grade: " + grade);
}

public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    // Input student information
    System.out.print("Enter Roll No: ");
    int rollNo = scanner.nextInt();
    scanner.nextLine(); // Consume the newline
    System.out.print("Enter Name: ");
    String name = scanner.nextLine();
    System.out.print("Enter Address: ");
    String address = scanner.nextLine();
    System.out.print("Enter Branch: ");
    String branch = scanner.nextLine();
    System.out.print("Enter Marks in 4 Subjects (space-separated): ");
    double[] marks = new double[4];
    for (int i = 0; i < 4; i++) {
        marks[i] = scanner.nextDouble();
    }

    // Create a School object with the entered information
    School student = new School(rollNo, name, address, branch, marks);

    // Display student information
    student.displayStudentInfo();
}

}

from java-hacktoberfest23.

gopalkrishna2004 avatar gopalkrishna2004 commented on August 31, 2024

@chetannihith can u plz assign this to me

from java-hacktoberfest23.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.